Example usage for com.google.gwt.user.client.ui CheckBox getValue

List of usage examples for com.google.gwt.user.client.ui CheckBox getValue

Introduction

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

Prototype

@Override
public Boolean getValue() 

Source Link

Document

Determines whether this check box is currently checked.

Usage

From source file:com.google.api.explorer.client.auth.AuthView.java

License:Apache License

/**
 * Rebuild the popup from scratch with all of the scopes that we have from the last time we were
 * presented.//ww w. j a  va  2s.co  m
 */
private void buildScopePopup() {

    scopePanel.clear();
    additionalScopePanel.clear();

    Set<TextBox> oldEditors = Sets.newLinkedHashSet(freeFormEditors);
    freeFormEditors.clear();

    // Hide the service scopes label if there aren't any.
    hasScopesText.setVisible(!scopesFromDiscovery.isEmpty());
    noScopesText.setVisible(scopesFromDiscovery.isEmpty());

    // Show different text on the free-form scopes section when there are discovery scopes.
    optionalAdditionalScopes.setVisible(!scopesFromDiscovery.isEmpty());

    for (final Map.Entry<String, AuthScope> scope : scopesFromDiscovery.entrySet()) {
        // Add the check box to the table.
        CheckBox scopeToggle = new CheckBox();

        SafeHtmlBuilder safeHtml = new SafeHtmlBuilder();
        safeHtml.appendEscaped(scope.getKey()).appendHtmlConstant("<br><span>")
                .appendEscaped(scope.getValue().getDescription()).appendHtmlConstant("</span>");
        scopeToggle.setHTML(safeHtml.toSafeHtml());

        scopeToggle.addStyleName(style.discoveryScopeSelector());
        scopePanel.add(scopeToggle);

        // When the box is checked, add our scope to the selected list.
        scopeToggle.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                CheckBox checkBox = (CheckBox) event.getSource();
                if (checkBox.getValue()) {
                    selectedScopes.add(scope.getKey());
                } else {
                    selectedScopes.remove(scope.getKey());
                }
            }
        });

        // Enable the check box if the scope is selected.
        scopeToggle.setValue(selectedScopes.contains(scope.getKey()));
    }

    // Process any scopes that are extra.
    for (TextBox editor : oldEditors) {
        if (!editor.getValue().trim().isEmpty()) {
            addFreeFormEditorRow(editor.getValue(), true);
        }
    }

    // There should always be one empty editor.
    addFreeFormEditorRow("", false);
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Possibly display the MIT App Inventor "Splash Screen"
 *
 * @param force Bypass the check to see if they have dimissed this version
 *//*from w ww .j  av  a2 s .c om*/
private void createWelcomeDialog(boolean force) {
    if (!shouldShowWelcomeDialog() && !force) {
        openProjectsTab();
        return;
    }
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.createWelcomeDialogText());
    dialogBox.setHeight(splashConfig.height + "px");
    dialogBox.setWidth(splashConfig.width + "px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(splashConfig.content);
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button ok = new Button(MESSAGES.createWelcomeDialogButton());
    final CheckBox noshow = new CheckBox(MESSAGES.doNotShow());
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            if (noshow.getValue()) { // User checked the box
                userSettings.getSettings(SettingsConstants.SPLASH_SETTINGS).changePropertyValue(
                        SettingsConstants.SPLASH_SETTINGS_VERSION, "" + splashConfig.version);
                userSettings.saveSettings(null);
            }
            openProjectsTab();
        }
    });
    holder.add(ok);
    holder.add(noshow);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.gerrit.client.account.MyWatchesTable.java

License:Apache License

protected void addNotifyButton(final AccountProjectWatch.NotifyType type, final AccountProjectWatchInfo info,
        final int row, final int col) {
    final CheckBox cbox = new CheckBox();

    cbox.addClickHandler(new ClickHandler() {
        @Override/*from w w w  .j  a  v  a 2 s  .c o  m*/
        public void onClick(final ClickEvent event) {
            final boolean oldVal = info.getWatch().isNotify(type);
            info.getWatch().setNotify(type, cbox.getValue());
            cbox.setEnabled(false);
            Util.ACCOUNT_SVC.updateProjectWatch(info.getWatch(), new GerritCallback<VoidResult>() {
                public void onSuccess(final VoidResult result) {
                    cbox.setEnabled(true);
                }

                @Override
                public void onFailure(final Throwable caught) {
                    cbox.setEnabled(true);
                    info.getWatch().setNotify(type, oldVal);
                    cbox.setValue(oldVal);
                    super.onFailure(caught);
                }
            });
        }
    });

    cbox.setValue(info.getWatch().isNotify(type));
    table.setWidget(row, col, cbox);
}

From source file:com.google.gwt.gen2.demo.picker.client.PickerDemoPanel.java

License:Apache License

public PickerDemoPanel() {
    FlexTable table = new FlexTable();

    // A TimePicker using AM/PM 12h format
    final TimePicker timePicker = new TimePicker(false);
    table.setHTML(3, 0, "Time picker:");
    table.setWidget(3, 1, timePicker);//w w w . jav a  2s  .c o m
    final CheckBox enableTimePicker = new CheckBox("Enable/disable");
    enableTimePicker.setValue(timePicker.isEnabled());
    enableTimePicker.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent source) {
            timePicker.setEnabled(enableTimePicker.getValue());
        }
    });
    table.setWidget(3, 2, enableTimePicker);

    // Creating a date time picker with AM/PM 12h TimePicker
    final DateTimePicker dateTimePicker = new DateTimePicker(false);
    dateTimePicker.setWidth("200px");
    // Create a label to display the selected date
    final Label dateLabel = new Label();
    Button getDate = new Button("Show date");
    getDate.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent source) {
            // Display the selected date/time using DateTimeFormat
            dateLabel.setText(DateTimeFormat.getMediumDateTimeFormat().format(dateTimePicker.getDate()));
        }
    });
    dateLabel.setStyleName("sandbox-Date");
    table.setHTML(4, 0, "Date time picker:");

    table.setWidget(4, 1, dateTimePicker);
    table.setWidget(5, 0, getDate);
    table.setWidget(5, 1, dateLabel);
    final CheckBox enableDateTimePicker = new CheckBox("Enable/disable");
    enableDateTimePicker.setValue(dateTimePicker.isEnabled());
    enableDateTimePicker.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dateTimePicker.setEnabled(enableDateTimePicker.getValue());
        }
    });
    table.setWidget(4, 2, enableDateTimePicker);

    final TimePicker customTimePicker = new TimePicker(new Date(), null, DateTimeFormat.getFormat("HH"),
            DateTimeFormat.getFormat("mm"), null);
    table.setHTML(8, 0, "Another time picker (24h):");
    table.setWidget(8, 1, customTimePicker);
    final CheckBox enable = new CheckBox("Enable/disable");
    enable.setValue(customTimePicker.isEnabled());
    enable.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent sender) {
            customTimePicker.setEnabled(enable.getValue());
        }

    });
    table.setWidget(8, 2, enable);

    initWidget(table);
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.ScrollTableDemo.java

License:Apache License

/**
 * @return the new header table/*w w  w  . ja  v  a2s  . c  o  m*/
 */
private FixedWidthFlexTable createHeaderTable() {
    FixedWidthFlexTable headerTable = new FixedWidthFlexTable();

    // Level 1 headers
    FlexCellFormatter headerFormatter = headerTable.getFlexCellFormatter();
    headerTable.setHTML(0, 0, "User Information");
    headerFormatter.setColSpan(0, 0, 13);

    // Create the select all checkbox
    final CheckBox selectAll = new CheckBox();
    selectAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (selectAll.getValue()) {
                getDataTable().selectAllRows();
            } else {
                getDataTable().deselectAllRows();
            }
        }
    });

    // Level 2 headers
    headerTable.setWidget(1, 0, selectAll);
    headerFormatter.setRowSpan(1, 0, 2);
    headerFormatter.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    headerTable.setHTML(1, 1, "First and Last Name");
    headerFormatter.setColSpan(1, 1, 2);
    headerFormatter.setRowSpan(1, 1, 2);
    headerTable.setHTML(1, 2, "General Info");
    headerFormatter.setColSpan(1, 2, 3);
    headerTable.setHTML(1, 3, "Favorite Color");
    headerFormatter.setColSpan(1, 3, 1);
    headerFormatter.setRowSpan(1, 3, 2);
    headerTable.setHTML(1, 4, "Preferred Sport");
    headerFormatter.setColSpan(1, 4, 1);
    headerFormatter.setRowSpan(1, 4, 2);
    headerTable.setHTML(1, 5, "School Info");
    headerFormatter.setColSpan(1, 5, 3);
    headerTable.setHTML(1, 6, "Login Info");
    headerFormatter.setColSpan(1, 6, 2);

    // Level 3 headers
    headerTable.setHTML(2, 0, "Age");
    headerTable.setHTML(2, 1, "Gender");
    headerTable.setHTML(2, 2, "Race");
    headerTable.setHTML(2, 3, "College");
    headerTable.setHTML(2, 4, "Year");
    headerTable.setHTML(2, 5, "GPA");
    headerTable.setHTML(2, 6, "ID");
    headerTable.setHTML(2, 7, "Pin");

    return headerTable;
}

From source file:com.google.gwt.maps.testing.client.maps.CustomControlsMapWidget.java

License:Apache License

private void drawControls() {
    Button button = new Button("B1");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 1 Clicked");
        }/*from  w ww  . j av a 2 s  .c om*/
    });

    Button button2 = new Button("B2");
    button2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 2 Clicked ");
        }
    });

    final CheckBox cb = new CheckBox();
    cb.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            GWT.log("Button 2 Clicked");
            Window.alert("CheckBox is " + cb.getValue());
        }
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    widget.add(new HTML("Custom Controls"));
    widget.add(button);
    widget.add(button2);
    widget.add(cb);
    widget.addStyleName("TestControls");

    // TODO I'm not able to get the stylesheet to work, but this works below
    DOM.setStyleAttribute(widget.getElement(), "background", "white");
    DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    DOM.setStyleAttribute(widget.getElement(), "border", "3px solid #FF0000");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);
}

From source file:com.google.gwt.maps.testing.client.maps.MultipleKmlMapWidget.java

License:Apache License

private void addRoutes() {
    final CheckBox check1 = new CheckBox();
    final CheckBox check2 = new CheckBox();
    final CheckBox check3 = new CheckBox();
    final CheckBox check4 = new CheckBox();
    final CheckBox check5 = new CheckBox();
    final CheckBox check6 = new CheckBox();
    final CheckBox check7 = new CheckBox();

    // Introduction
    HorizontalPanel pTitle = new HorizontalPanel();
    Label lTitle = new Label("Enable Disable Routes");
    pTitle.add(lTitle);/* w w  w.ja  va2  s.c  o m*/

    HorizontalPanel pDevider = new HorizontalPanel();
    Label lDevider = new Label("--------------------------");
    pDevider.add(lDevider);

    // stage 1
    HorizontalPanel stage1 = new HorizontalPanel();
    check1.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check1.getValue() == true) {
                kmlLoad(route1);

            } else {
                kmlUnload(route1);

            }
        }
    });
    Label stage1Label = new Label("Route 1");
    stage1.add(check1);
    stage1.add(stage1Label);

    // stage 2
    HorizontalPanel stage2 = new HorizontalPanel();
    check2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check2.getValue() == true) {
                kmlLoad(route2);

            } else {
                kmlUnload(route2);

            }
        }
    });
    Label stage2Label = new Label("Route 2");
    stage2.add(check2);
    stage2.add(stage2Label);

    // stage 3
    HorizontalPanel stage3 = new HorizontalPanel();
    check3.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check3.getValue() == true) {
                kmlLoad(route3);

            } else {
                kmlUnload(route3);

            }
        }
    });
    Label stage3Label = new Label("Route 3");
    stage3.add(check3);
    stage3.add(stage3Label);

    // stage 4
    HorizontalPanel stage4 = new HorizontalPanel();
    check4.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check4.getValue() == true) {
                kmlLoad(route4);

            } else {
                kmlUnload(route4);

            }
        }
    });
    Label stage4Label = new Label("Route 4");
    stage4.add(check4);
    stage4.add(stage4Label);

    // stage 5
    HorizontalPanel stage5 = new HorizontalPanel();
    check5.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check5.getValue() == true) {
                kmlLoad(route5);

            } else {
                kmlUnload(route5);

            }
        }
    });
    Label stage5Label = new Label("Route 5");
    stage5.add(check5);
    stage5.add(stage5Label);

    // stage 6
    HorizontalPanel stage6 = new HorizontalPanel();
    check6.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check6.getValue() == true) {
                kmlLoad(route6);

            } else {
                kmlUnload(route6);

            }
        }
    });
    Label stage19Label = new Label("Route 6");
    stage6.add(check6);
    stage6.add(stage19Label);

    // stage 7
    HorizontalPanel stage7 = new HorizontalPanel();
    check7.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (check7.getValue() == true) {
                kmlLoad(route7);

            } else {
                kmlUnload(route7);

            }
        }
    });
    Label stage7Label = new Label("Route 7");
    stage7.add(check7);
    stage7.add(stage7Label);

    // Adding all horizontal panels to the vertical panel pRoutes
    pRoutes.add(pTitle);
    pRoutes.add(pDevider);
    pRoutes.add(stage1);
    pRoutes.add(stage2);
    pRoutes.add(stage3);
    pRoutes.add(stage4);
    pRoutes.add(stage5);
    pRoutes.add(stage6);
    pRoutes.add(stage7);

}

From source file:com.google.gwt.sample.stockwatcher.client.OntologyBasedContentManagement.java

@SuppressWarnings("deprecation")
@Override/*  ww w.j  a  v  a 2 s.  com*/
public void onModuleLoad() {
    /*
     * Create file interface
     */
    // Create a FormPanel and point it at a service.
    form = new FormPanel();
    form.setAction(GWT.getModuleBaseURL() + "greet");
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    form.setWidget(secondPanel);
    // secondPanel.add(statusLabel);
    // fileUpload.setName(form.getTitle());
    fileUpload.setName("UploadFile");

    secondPanel.add(fileUpload);
    uploadedOntologies.add(loadFile);
    ClickHandler load_handler = new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            form.submit();
        }
    };
    loadFile.addClickHandler(load_handler);

    ontologies = new ListBox();
    ontologies.setSize("152px", "18px");

    uploadedOntologies.add(ontologies);
    uploadedOntologies.setSpacing(5);
    // secondPanel.add(uploadedOntologies);

    /*
     * end file creation
     */
    logger.log(Level.SEVERE, "Log!");
    Ont_Table.setText(1, 0, "Class"); // 3 columns
    Ont_Table.setText(1, 2, "Object Property");
    Ont_Table.setText(1, 4, "Data Property");
    double wi = Window.getClientWidth() / 3.5;
    String tablewidth = Double.toString(wi);
    tripleTable.getColumnFormatter().setWidth(0, tablewidth);
    tripleTable.getColumnFormatter().setWidth(1, tablewidth);
    tripleTable.getColumnFormatter().setWidth(2, tablewidth);
    tripleTable.setStyleName("Prompt-User");
    tripleTable.setText(0, 0, "Subject");
    tripleTable.setText(0, 1, "Predicate");
    tripleTable.setText(0, 2, "Object");
    tripleTable.getRowFormatter().addStyleName(0, "Prompt-User");
    tripleTable.getColumnFormatter().addStyleName(0, "columnOne");
    tripleTable.getColumnFormatter().addStyleName(1, "columnTwo");
    tripleTable.getColumnFormatter().addStyleName(2, "columnThree");
    tripleTable.addStyleName("tripleTable");
    row = tripleTable.getRowCount();

    webBox.setText(url);
    webBox.setWidth("340px");
    frameWidth = String.valueOf(Window.getClientWidth() / 3.3) + "px";
    queryBox.setText("\n\n\n\n\n\t\t\t\t\tEnter Query");
    queryBox.setSize("369px", "332px");

    queryBox.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            queryBox.selectAll();
        }

    });
    ontology_from_disk.setText("/Users/markhender/ontologies/pizzas/pizza.rdf");
    ontology_from_disk.setWidth("340px");
    frame = new Frame();
    frame.setUrl(url);
    frameWidth = String.valueOf(Window.getClientWidth() / 1.5) + "px"; // works
    // cross
    // browsers
    frameHeight = String.valueOf(String.valueOf(Window.getClientHeight() / 1.3) + "px");
    frame.setWidth(frameWidth);
    frame.setHeight(frameHeight);
    frame.setVisible(true);

    /*
     * Popup Panel
     */
    popupHolder.add(closePopup);

    popup.setWidget(popupContents);
    closePopup.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            int end_of_list = ft.getRowCount();
            int count = 1;

            while (count < end_of_list) {
                logger.log(Level.SEVERE, "line");
                CheckBox box = (CheckBox) ft.getWidget(count, 3);
                if (box.getValue()) {
                    // tripleTable.setText(tripleTable.getRowCount(), 0,
                    // ft.getText(count, 0));
                    printSuggestedSubject(ft.getText(count, 0));
                    addPredicate(ft.getText(count, 1));
                    if (ft.getText(count, 1).endsWith("*"))
                        addLitObject(ft.getText(count, 2));
                    else
                        addObject(ft.getText(count, 2));
                }
                count++;
            }
            logger.log(Level.SEVERE, "BINGO");
            ft.removeAllRows();

            popup.hide();
            popupContents.clear();
            popupContents.add(popupHolder);
        }
    });
    content.setText("Search for content in webpage");
    content.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            content.setFocus(true);
            if (content.getText().equals("Search for content in webpage"))
                content.setText("");
            else
                content.selectAll();
        }
    });
    addPanel.add(webBox);

    searchPanel.add(content); // content search box
    searchPanel.add(search); // trigger content search button
    search.setHeight("37px");
    dBox.setText("Triple Report");
    close.setText("Close");
    close.addClickListener(new ClickListener() {

        @Override
        public void onClick(Widget sender) {
            dialogBoxContents.clear();
            dBox.hide();
        }
    });
    dialogBoxholder.add(close);

    loadOntologyInternet.add(ontology_from_internet);
    loadOntologyInternet.add(load_ontology_web_button);
    radioButtonPanel.add(radioA);
    radioButtonPanel.add(radioB);
    searchPanel.add(radioButtonPanel);
    bottomOfScreen.add(searchPanel);
    bottomOfScreen.add(tripleTable);
    tripleTable.setSize("981px", "67px");
    // bottomOfScreen.setSpacing(10);
    search.setText("Enter");
    content.setSize("282px", "29px");
    ListBox listbox = new ListBox();
    ontology_Classes = new ListBox(); // Ontology class listbox
    property_Resources = new ListBox(); // " property listbox
    property_Literals = new ListBox(); // " individual listbox
    ontology_Classes.setWidth("100px");
    property_Resources.setWidth("100px");
    property_Literals.setWidth("100px");

    listbox.setWidth("100px");
    listbox.setHeight("400px");
    save.setText("Save");
    listbox.setVisible(false);
    /*
     * before new page
     */
    final PopupPanel contextpanel = new PopupPanel();

    final Button ok = new Button("OK");
    final HorizontalPanel hori = new HorizontalPanel();
    contextpanel.setWidget(hori);
    entercontext.setText("context");
    hori.add(ok);
    final ClickHandler download_handler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            greetingService.downloadRepository(entercontext.getText(), new downloadRepository());
            if (repository_downloaded)
                loadPageTwo(export_fp);
            repository_downloaded = true;
            logger.log(Level.SEVERE, "download_handler called");
        }
    };
    ClickHandler newpage_handler = new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            contextpanel.center();
            ok.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (repository_downloaded)
                        loadPageTwo(export_fp);
                    else {
                        download_handler.onClick(event);

                    }
                    contextpanel.hide();

                }

            });
            logger.log(Level.SEVERE, "export path: " + filepathofexport);

        }

    };
    new_page.addClickHandler(newpage_handler);
    download_repository.addClickHandler(download_handler);
    /* Return to homepage */
    home_page.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            loadHomePage();
        }
    });
    /* home page */

    //mainPanel.add(frame); // browser
    mainPanel.add(uploadedOntologies);
    mainPanel.add(addPanel); // url for browser
    addPanel.add(webSend);
    webSend.setHeight("32px");

    webSend.setText("GO");

    // Listen for mouse events on webSend Button
    // to get new website
    webSend.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            frame.setUrl(webBox.getText()); // take url from textbox
            logger.log(Level.SEVERE, frame.getUrl());
            content.setFocus(true);
            content.selectAll();
        }
    });
    mainPanel.add(loadOntologyInternet);
    mainPanel.add(Ont_Table); // listboxes
    mainPanel.add(queryBox);
    mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(queryButton);
    mainPanel.add(new_page);
    mainPanel.add(download_repository);

    RootPanel.get("stockList").add(frame, RootPanel.get("stockList").getAbsoluteLeft(),
            RootPanel.get("stockList").getAbsoluteTop());
    RootPanel.get("stockList").add(bottomOfScreen, 0, 725);
    bottomOfScreen.setSize("984px", "128px");
    RootPanel.get("stockList").add(form, frame.getOffsetWidth() + 10, frame.getAbsoluteTop());
    RootPanel.get("stockList").add(mainPanel, frame.getOffsetWidth() + 10,
            form.getOffsetHeight() + frame.getAbsoluteTop());
    // listen for keyboard events in the textbox
    webBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                frame.setUrl(webBox.getText());
                content.setFocus(true);
                content.selectAll();
            }
        }
    });
    frame.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {

        }

    });
    final AsyncCallback<ArrayList<String>> ontology_class = new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            classes = result;
            ontology.get(ontology.size() - 1).setClasses(result);
            if (ontology.size() == 1)
                populate_ClassBox(0);
        }
    };
    final AsyncCallback<ArrayList<String>> property_resource = new AsyncCallback<ArrayList<String>>() {
        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            properties = result;
            ontology.get(ontology.size() - 1).setProperties(result);
            if (ontology.size() == 1)
                populate_PropertyBox(0);
        }
    };
    final AsyncCallback<ArrayList<String>> property_literal = new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            literals = result;
            ontology.get(ontology.size() - 1).setLiterals(result);
            if (ontology.size() == 1)
                populate_LiteralBox(0);
        }
    };

    load_ontology_web_button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // TODO load ontologies from a web address
        }

    });
    final AsyncCallback<Integer[]> subjectIndexOfContent = new AsyncCallback<Integer[]>() {

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onSuccess(Integer[] result) {
            if (result[0] != -99 && result[1] != -99) {
                // word found
                printSubject();
            } else
                Window.alert("Word not found");
        }

    };

    final AsyncCallback<String> getOntName = new AsyncCallback<String>() {
        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(String result) {
            ontName = result;
            ontology.get(ontology.size() - 1).setName(result);
            logger.log(Level.SEVERE, ("OntologyName = " + ontName));
        }

    };

    final AsyncCallback<String> geturi = new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(String result) {
            baseURI = result;
            ontology.get(ontology.size() - 1).setBaseURI(result);
            logger.log(Level.SEVERE, "The baseURI is " + baseURI);
        }

    };
    final AsyncCallback<ArrayList<String[]>> suggestedTriples = new AsyncCallback<ArrayList<String[]>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String[]> result) {
            logger.log(Level.SEVERE, "First");
            populateSuggestedTriples(result);
            Window.alert("Pass");
        }

    };
    tripleTable.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            com.google.gwt.user.client.ui.HTMLTable.Cell cell = tripleTable.getCellForEvent(event);
            int cellIndex = cell.getCellIndex();
            int rowIndex = cell.getRowIndex();
            if (cellIndex == 4 || cellIndex == 0) {
                logger.log(Level.SEVERE, "Sending: " + tripleTable.getText(rowIndex, 0));
                greetingService.suggestedTriples(tripleTable.getHTML(rowIndex, 0), suggestedTriples);

            }

        }
    });

    search.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String blah = content.getText();
            if (radioA.isChecked() || !radioB.isChecked())
                greetingService.wordExists(blah, webBox.getText(), subjectIndexOfContent);
            else {
                printSubject();
            }
            content.setFocus(true);
            content.selectAll();
        }
    });

    content.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {

            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (radioA.isChecked() || !radioB.isChecked())
                    greetingService.wordExists(content.getText(), webBox.getText(), subjectIndexOfContent);
                else
                    printSubject();
                content.setFocus(true);
                content.selectAll();
            }
        }
    });
    save.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String[] temp = new String[3];
            temp = getTriples();
            repository_downloaded = false;
        }
    });

    Ont_Table.setWidget(0, 2, menuBar);
    menuBar.setSize("100%", "100%");

    Classes = new MenuItem("Classes", false, menuBar_3);
    Ontology_Contents_Holder.addItem(Classes);
    menuBar_2.addItem(mntmObject);
    menuBar_2.addItem(mntmData);
    Ontology_Contents_Holder.addItem(Properties);
    menuBar.addItem(Ontology_Name);

    Ont_Table.setWidget(2, 2, property_Resources);
    Ont_Table.setWidget(2, 4, property_Literals);

    /*
     * Adding Change listener to listboxes
     */
    ontologies.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            int listIndex = ontologies.getSelectedIndex();

            populate_ClassBox(listIndex);
            populate_PropertyBox(listIndex);
            populate_LiteralBox(listIndex);
        }
    });
    ontology_Classes.addChangeListener(new ChangeListener() {

        @Override
        public void onChange(Widget sender) {
            int listIndex = ontology_Classes.getSelectedIndex();
            String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
            String item = uri + ontology_Classes.getItemText(listIndex);
            addObject(item);
        }

    });
    property_Resources.addChangeListener(new ChangeListener() {

        @Override
        public void onChange(Widget sender) {
            // TODO Auto-generated method stub
            int listIndex = property_Resources.getSelectedIndex();
            logger.log(Level.SEVERE, property_Resources.getItemText(listIndex));
            if (!(property_Resources.getItemText(listIndex).equals("RDF.type"))) {
                logger.log(Level.SEVERE, "not rdf.type");
                String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
                String item = uri + property_Resources.getItemText(listIndex);
                addPredicate(item);
            } else {
                logger.log(Level.SEVERE, "rdf.type");
                String item = property_Resources.getItemText(listIndex);
                addPredicate(item);
            }

        }

    });

    property_Literals.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            if (property_Literals.getItemCount() == 0)
                Window.alert("This list is empty!");
            else {
                int listIndex = property_Literals.getSelectedIndex();
                String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
                String item = uri + property_Literals.getItemText(listIndex);
                addPredicate(item);
            }
        }
    });

    /*
     * File submit handling
     */
    form.addFormHandler(new FormHandler() {

        @Override
        public void onSubmit(FormSubmitEvent event) {
            // logger.log(Level.SEVERE, "form title: "+
            // fileUpload.getFilename().substring(fileUpload.getFilename().lastIndexOf('\\')
            // + 1));
            ontName = fileUpload.getFilename().substring(fileUpload.getFilename().lastIndexOf('\\') + 1);

        }

        @Override
        public void onSubmitComplete(FormSubmitCompleteEvent event) {
            // TODO Auto-generated method stub

        }

    });
    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            logger.log(Level.SEVERE, "form title: " + form.getTitle());
            form.reset();
            AsyncCallback<String> pathfile = new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub
                    Window.alert("Fail");
                }

                @Override
                public void onSuccess(String result) {
                    // TODO Auto-generated method stub
                    path_of_uploaded_file = result;
                    ontology.get(ontology.size() - 1).setFilePath(result);
                    Window.alert("Pass");
                    greetingService.greetServer(list, path_of_uploaded_file, 1, ontology_class);
                    greetingService.greetServer(list, path_of_uploaded_file, 2, property_resource);
                    greetingService.greetServer(list, path_of_uploaded_file, 3, property_literal);

                    ontologies.addItem(ontology.get(ontology.size() - 1).getName());

                    // logger.log(Level.SEVERE, baseURI);
                }

            };
            greetingService.filePath(pathfile);
            greetingService.getBaseURI(geturi);
            // greetingService.getOntName(getOntName);
            ontology.add(new Ontology(ontName, path_of_uploaded_file, baseURI, classes, properties, literals));
            // greetingService.getOntName(getOntName);
            if (ontology.size() == 1) {
                // populate_listBoxes();
            }
            logger.log(Level.SEVERE, "baseuri = " + baseURI);
        }

    });

}

From source file:com.google.mobile.trippy.web.client.view.AddItemPopUpView.java

License:Apache License

/**
 * Sets the content of Pop up Panel.// w  w  w.jav  a2s.com
 * 
 */
@Override
public void createPopUp(final int daysCount) {
    if (daysPanel == null) {
        daysPanel = new ArrayList<CheckBox>();
    } else {
        daysPanel.clear();
    }
    content.clear();

    selectDaysLabel.setText("Select Day(s)");
    selectDaysLabel.addStyleName(dayStyle.style.titleBaseModified());

    daysMenu.clear();
    daysMenu.setStyleName(dayStyle.style.daysMenu());
    addSelectOptions(daysMenu);

    for (int i = 0; i <= daysCount; i++) {
        final CheckBox dayPanel = new CheckBox(" Day " + i);
        dayPanel.setStyleName(dayStyle.style.dayPanel());
        if (i == 0) {
            final Message messages = GWT.create(Message.class);
            dayPanel.setText(" " + messages.unscheduled());
            dayPanel.setValue(true);
        } else {
            // if any day is selected, make sure we uncheck "unscheduled"
            dayPanel.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    boolean checked = ((CheckBox) event.getSource()).getValue();
                    if (checked) {
                        ((CheckBox) (daysMenu.getWidget(0))).setValue(false);
                    } else {
                        ((CheckBox) (daysMenu.getWidget(0))).setValue(true);
                        for (int i = 1; i < daysMenu.getWidgetCount(); i++) {
                            CheckBox cb = (CheckBox) daysMenu.getWidget(i);
                            if (cb.getValue()) {
                                ((CheckBox) (daysMenu.getWidget(0))).setValue(false);
                            }
                        }
                    }
                }
            });
        }
        daysMenu.add(dayPanel);
        daysPanel.add(dayPanel);
    }
    content.add(daysMenu);
    dayPopUp.hide();
}

From source file:com.google.sampling.experiential.client.EsmPanel.java

License:Open Source License

public EsmPanel(final SignalScheduleDAO schedule) {
    MyConstants myConstants = GWT.create(MyConstants.class);
    this.schedule = schedule;
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(2);//from   w  w w . j  av  a 2s . c o  m
    initWidget(verticalPanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(2);
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellVerticalAlignment(horizontalPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setWidth("");

    Label lblFrequency = new Label(myConstants.frequency() + ":");
    lblFrequency.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblFrequency);
    ValueSpinnerFixed frequencySpinner = new ValueSpinnerFixed(schedule.getEsmFrequency(), 0, 100);
    frequencySpinner.getTextBox().setWidth("18px");
    frequencySpinner.setWidth("35px");
    horizontalPanel.add(frequencySpinner);
    frequencySpinner.getSpinner().addSpinnerListener(new SpinnerListener() {
        public void onSpinning(long value) {
            schedule.setEsmFrequency((int) value);
        }
    });

    Label lblPeriod = new Label(myConstants.period() + ": ");
    lblPeriod.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblPeriod);

    final ListBox listBox = new ListBox();
    for (int i = 0; i < SignalScheduleDAO.ESM_PERIODS.length; i++) {
        listBox.addItem(SignalScheduleDAO.ESM_PERIODS_NAMES[i]);
    }
    horizontalPanel.add(listBox);
    listBox.setVisibleItemCount(1);
    Integer period = schedule.getEsmPeriodInDays();
    if (period == null) {
        period = SignalScheduleDAO.DEFAULT_ESM_PERIOD;
        schedule.setEsmPeriodInDays(SignalScheduleDAO.DEFAULT_ESM_PERIOD);
    }
    listBox.setSelectedIndex(period);
    listBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            schedule.setEsmPeriodInDays(listBox.getSelectedIndex());
        }
    });
    verticalPanel.add(horizontalPanel);

    HorizontalPanel weekendsPanel = new HorizontalPanel();
    weekendsPanel.setSpacing(2);
    weekendsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(weekendsPanel);
    weekendsPanel.setWidth("");
    Label lblWeekends = new Label(myConstants.includeWeekends() + ": ");
    lblWeekends.setStyleName("gwt-Label-Header");
    weekendsPanel.add(lblWeekends);

    final CheckBox weekendsBox = new CheckBox("");
    weekendsPanel.add(weekendsBox);
    weekendsBox.setValue(schedule.getEsmWeekends());
    weekendsBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            schedule.setEsmWeekends(weekendsBox.getValue());
        }

    });

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setSpacing(2);
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_1);
    horizontalPanel_1.setWidth("");

    Label lblStartHour = new Label(myConstants.startTime() + ":");
    lblStartHour.setStyleName("gwt-Label-Header");
    horizontalPanel_1.add(lblStartHour);
    lblStartHour.setWidth("83px");

    Date setTime = null;
    if (schedule.getEsmStartHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmStartHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
        setTime.setSeconds(0);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed startTimeBox = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_1.add(startTimeBox);

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setSpacing(2);
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_2);
    horizontalPanel_2.setWidth("");
    startTimeBox.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = startTimeBox.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmStartHour(offset);
        }
    });

    Label lblEndTime = new Label(myConstants.endTime() + ":  ");
    lblEndTime.setStyleName("gwt-Label-Header");
    horizontalPanel_2.add(lblEndTime);
    lblEndTime.setWidth("83px");

    setTime = null;
    if (schedule.getEsmEndHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmEndHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed endTimePicker = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_2.add(endTimePicker);
    endTimePicker.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = endTimePicker.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmEndHour(offset);
        }
    });

    TimeoutPanel timeoutPanel = new TimeoutPanel(schedule);
    verticalPanel.add(timeoutPanel);
    timeoutPanel.setWidth("286px");

    MinimumBufferPanel minimumBufferPanel = new MinimumBufferPanel(schedule);
    verticalPanel.add(minimumBufferPanel);
    minimumBufferPanel.setWidth("286px");

    SnoozePanel snoozePanel = new SnoozePanel(schedule);
    verticalPanel.add(snoozePanel);
    snoozePanel.setWidth("286px");

}