/**
   * Page widgets.
   *
   * @param cellTree the cell tree
   */
  public void createPageView(CellTree cellTree) {
    this.cellTree = cellTree;
    mainPanel.setStyleName("div-wrapper"); // main div

    SimplePanel leftPanel = new SimplePanel();
    leftPanel.getElement().setId("leftPanel_SimplePanel");
    leftPanel.setStyleName("div-first bottomPadding10px"); // left side div which will  have tree

    SimplePanel rightPanel = new SimplePanel();
    rightPanel.getElement().setId("rightPanel_SimplePanel");
    rightPanel.setStyleName("div-second"); // right div having tree creation inputs.

    VerticalPanel treePanel = new VerticalPanel();
    treePanel.getElement().setId("treePanel_VerticalPanel");
    HorizontalPanel expandCollapse = new HorizontalPanel();
    expandCollapse.getElement().setId("expandCollapse_HorizontalPanel");
    expandCollapse.setStyleName("leftAndTopPadding");
    expandCollapse.setSize("100px", "20px");
    buttonExpand.setStylePrimaryName("expandAllButton");
    buttonCollapse.setStylePrimaryName("collapseAllButton");
    buttonExpand.setTitle("Expand All (Shift +)");
    buttonCollapse.setTitle("Collapse All (Shift -)");
    expandCollapse.add(buttonExpand);
    expandCollapse.add(buttonCollapse);
    buttonExpand.setFocus(true);
    buttonCollapse.setVisible(true);

    treePanel.add(expandCollapse);
    treePanel.add(cellTree);
    leftPanel.add(treePanel);

    SimplePanel bottomSavePanel = new SimplePanel();
    bottomSavePanel.getElement().setId("bottomSavePanel_SimplePanel");
    bottomSavePanel.setStyleName("div-first buttonPadding");
    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel savePanel = new HorizontalPanel();
    savePanel.getElement().setId("savePanel_VerticalPanel");
    savePanel.add(new SpacerWidget());
    //		savePanel.add(errorMessageDisplay);
    vp.add(successMessageDisplay);
    //		saveBtn.setTitle("Ctrl+Alt+s");
    savePanel.add(saveBtn);
    validateBtn.setTitle("Validate");
    savePanel.add(validateBtn);
    vp.add(warningMessageDisplay);
    vp.add(savePanel);
    bottomSavePanel.add(vp);

    SimplePanel errPanel = new SimplePanel();
    errPanel.getElement().setId("errPanel_SimplePanel");
    errPanel.add(errorMessageDisplay);
    mainPanel.add(errPanel);
    mainPanel.add(leftPanel);
    mainPanel.add(rightPanel);
    mainPanel.add(bottomSavePanel);
    focusPanel.addKeyDownHandler(this);
    focusPanel.addFocusHandler(this);
    cellTreeHandlers();
  }
示例#2
0
  //  Welcome Page is main app page
  public void viewWelcomePage() {
    RootPanel rootPanel = RootPanel.get();
    rootPanel.clear();
    makeMenuBar(rootPanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    rootPanel.add(horizontalPanel, 10, 79);
    horizontalPanel.setSize("412px", "211px");

    makeSideBar(horizontalPanel);
  }
  public ConfigurationDialog(OkCancelDialogCallback callback) {
    setText("Configuration");
    setModal(true);
    this.okCancelDialogCallback = callback;

    setHTML("New dialog");

    VerticalPanel verticalPanel = new VerticalPanel();
    setWidget(verticalPanel);
    verticalPanel.setSize("100%", "100%");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);
    verticalPanel.setCellHeight(horizontalPanel, "100%");
    verticalPanel.setCellWidth(horizontalPanel, "100%");
    horizontalPanel.setSize("324px", "29px");

    Label lblBrokerUrl = new Label("Broker url: ");
    horizontalPanel.add(lblBrokerUrl);

    final TextBox txtBrokerUrl = new TextBox();
    horizontalPanel.add(txtBrokerUrl);

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    verticalPanel.add(horizontalPanel_1);
    verticalPanel.setCellWidth(horizontalPanel_1, "100%");
    verticalPanel.setCellHorizontalAlignment(
        horizontalPanel_1, HasHorizontalAlignment.ALIGN_CENTER);

    Button btnAcept = new Button("Acept");
    btnAcept.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            okCancelDialogCallback.okButtonClick(txtBrokerUrl.getText());
            hide();
          }
        });
    horizontalPanel_1.add(btnAcept);
    horizontalPanel_1.setCellVerticalAlignment(btnAcept, HasVerticalAlignment.ALIGN_MIDDLE);

    Button btnCancel = new Button("Cancel");
    btnCancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            okCancelDialogCallback.cancelButtonClick();
            hide();
          }
        });
    horizontalPanel_1.add(btnCancel);
    horizontalPanel_1.setCellVerticalAlignment(btnCancel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT);
  }
    BarcodeDialogBox(String projectName, String appInstallUrl) {
      super(false, true);
      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.barcodeTitle(projectName));

      ClickHandler buttonHandler =
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              hide();
            }
          };

      Button cancelButton = new Button(MESSAGES.cancelButton());
      cancelButton.addClickHandler(buttonHandler);
      Button okButton = new Button(MESSAGES.okButton());
      okButton.addClickHandler(buttonHandler);
      Image barcodeImage = new Image(appInstallUrl);
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
      HTML warningLabel =
          new HTML(
              MESSAGES.barcodeWarning(
                  Ode.getInstance().getUser().getUserEmail(),
                  "<a href=\""
                      + Ode.APP_INVENTOR_DOCS_URL
                      + "/learn/userfaq.html\" target=\"_blank\">",
                  "</a>"));
      warningLabel.setWordWrap(true);
      warningLabel.setWidth("200px"); // set width to get the text to wrap
      HorizontalPanel warningPanel = new HorizontalPanel();
      warningPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
      warningPanel.add(warningLabel);

      // The cancel button is removed from the panel since it has no meaning in this
      // context.  But the logic is still here in case we want to restore it, and as
      // an example of how to code this stuff in GWT.
      // buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      VerticalPanel contentPanel = new VerticalPanel();
      contentPanel.add(barcodeImage);
      contentPanel.add(buttonPanel);
      contentPanel.add(warningPanel);
      //      contentPanel.setSize("320px", "100%");
      add(contentPanel);
    }
  @Override
  public void buildPanel() {

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16);

    // create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);

    contentPanel.add(new HTML("<p>This example shows the use of the click handler.</p>"));
    contentPanel.add(
        new InfoPanel(
            "<p>Don't forget to add the following line to your HTML if you want to use Google V3. :</p>"
                + "<p><b>&lt;script src=\"http://maps.google.com/maps/api/js?v=3&amp;sensor=false\"&gt;&lt;/script&gt;</b></p>"));

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSize("800px", "500px");
    outputPanel.setSize("300px", "475px");
    horizontalPanel.add(mapWidget);

    VerticalPanel eventConsole = new VerticalPanel();

    listBox.setSize("300px", "25px");

    eventConsole.add(listBox);
    eventConsole.add(this.outputPanel);

    horizontalPanel.add(eventConsole);

    contentPanel.add(horizontalPanel);

    // create some Google Layers
    GoogleV3Options gNormalOptions = new GoogleV3Options();
    gNormalOptions.setIsBaseLayer(true);
    gNormalOptions.setType(GoogleV3MapType.G_NORMAL_MAP);
    GoogleV3 gNormal = new GoogleV3("Google Normal", gNormalOptions);

    // and add them to the map
    final Map map = mapWidget.getMap();
    map.addLayer(gNormal);

    // lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); // Display the scaleline

    final String singleKey = "single";
    ClickControl singleClickControl =
        new ClickControl(this.createClickHandlerOptions(true, false, false, false, 0, singleKey));
    map.addControl(singleClickControl);
    this.clickControls.put(singleKey, singleClickControl);
    listBox.addItem("single only", singleKey);

    final String doubleKey = "double";
    ClickControl doubleClickControl =
        new ClickControl(this.createClickHandlerOptions(false, true, false, false, 0, doubleKey));
    map.addControl(doubleClickControl);
    this.clickControls.put(doubleKey, doubleClickControl);
    this.listBox.addItem("double only", doubleKey);

    final String bothKey = "both";
    ClickControl bothClickControl =
        new ClickControl(this.createClickHandlerOptions(true, true, false, false, 0, bothKey));
    map.addControl(bothClickControl);
    this.clickControls.put(bothKey, bothClickControl);
    this.listBox.addItem("both", bothKey);

    final int tolerance = 200;
    final String dragKey = "drag";
    ClickControl dragClickControl =
        new ClickControl(
            this.createClickHandlerOptions(true, false, false, false, tolerance, dragKey));
    map.addControl(dragClickControl);
    this.clickControls.put(dragKey, dragClickControl);
    this.listBox.addItem("drag ( tolerance: " + tolerance + " )", dragKey);

    final String singleStopKey = "singlestop";
    ClickControl singleStopClickControl =
        new ClickControl(
            this.createClickHandlerOptions(true, false, true, false, 0, singleStopKey));
    map.addControl(singleStopClickControl);
    this.clickControls.put(singleStopKey, singleStopClickControl);
    listBox.addItem("single with stop", singleStopKey);

    final String doubleStopKey = "doublestop";
    ClickControl doubleStopClickControl =
        new ClickControl(
            this.createClickHandlerOptions(false, true, false, true, 0, doubleStopKey));
    map.addControl(doubleStopClickControl);
    this.clickControls.put(doubleStopKey, doubleStopClickControl);
    this.listBox.addItem("double with stop", doubleStopKey);

    final String bothStopKey = "bothstop";
    ClickControl bothStopClickControl =
        new ClickControl(this.createClickHandlerOptions(true, true, true, true, 0, bothStopKey));
    map.addControl(bothStopClickControl);
    this.clickControls.put(bothStopKey, bothStopClickControl);
    this.listBox.addItem("both with stop", bothStopKey);

    // center and zoom to a location
    LonLat lonLat = new LonLat(13.4, 52.51);
    lonLat.transform(
        DEFAULT_PROJECTION.getProjectionCode(),
        map.getProjection()); // transform lonlat to OSM coordinate system
    map.setCenter(lonLat, 12);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups

    this.listBox.addChangeHandler(
        new ChangeHandler() {

          @Override
          public void onChange(ChangeEvent event) {
            activateControl();
          }
        });

    this.activateControl();
  }
    NewFormDialog(final YoungAndroidProjectNode projectRootNode) {
      super(false, true);

      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.newFormTitle());
      VerticalPanel contentPanel = new VerticalPanel();

      final String prefix = "Screen";
      final int prefixLength = prefix.length();
      int highIndex = 0;
      // Collect the existing form names so we can prevent duplicate form names.
      otherFormNames = new HashSet<String>();

      for (ProjectNode source : projectRootNode.getAllSourceNodes()) {
        if (source instanceof YoungAndroidFormNode) {
          String formName = ((YoungAndroidFormNode) source).getFormName();
          otherFormNames.add(formName);

          if (formName.startsWith(prefix)) {
            try {
              highIndex = Math.max(highIndex, Integer.parseInt(formName.substring(prefixLength)));
            } catch (NumberFormatException e) {
              continue;
            }
          }
        }
      }

      String defaultFormName = prefix + (highIndex + 1);

      newNameTextBox = new LabeledTextBox(MESSAGES.formNameLabel());
      newNameTextBox.setText(defaultFormName);
      newNameTextBox
          .getTextBox()
          .addKeyUpHandler(
              new KeyUpHandler() {
                @Override
                public void onKeyUp(KeyUpEvent event) {
                  int keyCode = event.getNativeKeyCode();
                  if (keyCode == KeyCodes.KEY_ENTER) {
                    handleOkClick(projectRootNode);
                  } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                    hide();
                    executionFailedOrCanceled();
                  }
                }
              });
      contentPanel.add(newNameTextBox);

      String cancelText = MESSAGES.cancelButton();
      String okText = MESSAGES.okButton();

      // Keeps track of the total number of screens.
      int formCount = otherFormNames.size() + 1;
      if (formCount > MAX_FORM_COUNT) {
        HorizontalPanel errorPanel = new HorizontalPanel();
        HTML tooManyScreensLabel = new HTML(MESSAGES.formCountErrorLabel());
        errorPanel.add(tooManyScreensLabel);
        errorPanel.setSize("100%", "24px");
        contentPanel.add(errorPanel);

        okText = MESSAGES.addScreenButton();
        cancelText = MESSAGES.cancelScreenButton();

        // okText = "Add";
        // cancelText = "Don't Add";
      }

      Button cancelButton = new Button(cancelText);
      cancelButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              hide();
              executionFailedOrCanceled();
            }
          });
      Button okButton = new Button(okText);
      okButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              handleOkClick(projectRootNode);
            }
          });
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      contentPanel.add(buttonPanel);
      contentPanel.setSize("320px", "100%");

      add(contentPanel);
    }
示例#7
0
  private void initLayout() {

    table = new FlexTable();
    table.setWidth("100%");

    HTML conceptLab = new HTML(constants.exportConcept());
    HTML exportLab = new HTML(constants.exportFormat());
    HTML schemeLab = new HTML(constants.exportScheme());
    HTML dateLab = new HTML(constants.exportDate());
    HTML termCodeLab = new HTML(constants.exportTermCode());

    conceptLab.setWordWrap(false);
    exportLab.setWordWrap(false);
    schemeLab.setWordWrap(false);
    dateLab.setWordWrap(false);
    termCodeLab.setWordWrap(false);

    table.setWidget(0, 0, schemeLab);
    table.setWidget(0, 1, getScheme());
    table.setWidget(1, 0, conceptLab);
    table.setWidget(1, 1, getConcept());
    table.setWidget(2, 0, exportLab);
    table.setWidget(2, 1, getExportFormat());
    // table.setWidget(3, 0, termCodeLab);
    // table.setWidget(3, 1, getTermCode());
    // table.setWidget(4, 0, dateLab);
    // table.setWidget(4, 1, getDatePanel());

    table.getColumnFormatter().setWidth(0, "15%");
    table.getColumnFormatter().setWidth(1, "75%");

    final VerticalPanel exportOption = new VerticalPanel();
    exportOption.setSize("100%", "100%");
    exportOption.add(GridStyle.setTableRowStyle(table, "#F4F4F4", "#E8E8E8", 3));

    final Button export = new Button(constants.exportButton());
    final CheckBox chkZip = new CheckBox(constants.exportUseZip());

    HorizontalPanel bottombar = new HorizontalPanel();
    bottombar.setSpacing(5);
    bottombar.add(chkZip);
    bottombar.add(export);
    bottombar.setSize("100%", "100%");
    bottombar.setStyleName("bottombar");
    bottombar.setCellHorizontalAlignment(chkZip, HasHorizontalAlignment.ALIGN_LEFT);
    bottombar.setCellHorizontalAlignment(export, HasHorizontalAlignment.ALIGN_RIGHT);
    bottombar.setCellVerticalAlignment(export, HasVerticalAlignment.ALIGN_MIDDLE);

    // ButtonbarWidget bottomBarPanel = new ButtonbarWidget(null, bottombar);

    /*ld.setSize("100%", "100%");
    spacer.setSize("100%", "100%");
    spacer.setCellHorizontalAlignment(ld, HasHorizontalAlignment.ALIGN_CENTER);
    spacer.setCellVerticalAlignment(ld, HasVerticalAlignment.ALIGN_MIDDLE);

     Window.addResizeHandler(new ResizeHandler()
        {
        	public void onResize(ResizeEvent event) {
        		spacer.setSize("100%", "100%");
    		}
    	});*/

    VerticalPanel optionPanel = new VerticalPanel();
    optionPanel.setSize("100%", "100%");
    optionPanel.setStyleName("borderbar");
    optionPanel.add(exportOption);
    // optionPanel.add(spacer);
    optionPanel.add(bottombar);
    // optionPanel.setCellHeight(spacer, "100%");
    optionPanel.setCellVerticalAlignment(exportOption, HasVerticalAlignment.ALIGN_TOP);
    optionPanel.setCellVerticalAlignment(bottombar, HasVerticalAlignment.ALIGN_BOTTOM);

    HorizontalPanel langPanel = new HorizontalPanel();
    /*Image img = new Image("images/map-grey.gif");
    final Label lang = new Label(constants.exportSelectLang());
    lang.setSize("150", "100%");
    lang.setStyleName("displayexportLang");
    lang.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    lang.addClickHandler(new ClickHandler() {
    	public void onClick(ClickEvent event) {
    		if(selectLanguage == null || !selectLanguage.isLoaded)
    			selectLanguage = new SelectLanguage();
    		selectLanguage.show();
    	}
    });

    langPanel.setSize("10%", "100%");
    langPanel.add(img);
    langPanel.add(new HTML("&nbsp;"));
    langPanel.add(lang);
    langPanel.add(new HTML("&nbsp;"));
    langPanel.add(new HTML("&nbsp;"));
    langPanel.setCellWidth(lang, "100%");
    langPanel.setCellHeight(lang, "100%");
    langPanel.setCellVerticalAlignment(img, HasVerticalAlignment.ALIGN_MIDDLE);
    langPanel.setCellVerticalAlignment(lang, HasVerticalAlignment.ALIGN_MIDDLE);
    langPanel.setCellHorizontalAlignment(lang, HasHorizontalAlignment.ALIGN_RIGHT);
    langPanel.setSpacing(1);*/

    VerticalPanel tempmainPanel = new VerticalPanel();
    tempmainPanel.setSpacing(10);
    tempmainPanel.add(optionPanel);

    BodyPanel mainPanel = new BodyPanel(constants.exportTitle(), tempmainPanel, langPanel);

    mainBodypanel.setSize("100%", "100%");
    mainBodypanel.add(mainPanel);
    mainBodypanel.setCellHorizontalAlignment(mainPanel, HasHorizontalAlignment.ALIGN_CENTER);
    mainBodypanel.setCellVerticalAlignment(mainPanel, HasVerticalAlignment.ALIGN_TOP);
    mainBodypanel.setCellWidth(mainPanel, "100%");
    mainBodypanel.setCellHeight(mainPanel, "100%");

    panel.clear();
    panel.setSize("100%", "100%");
    panel.add(mainBodypanel);
    panel.add(loadingDialog);
    panel.setCellHorizontalAlignment(mainPanel, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(mainPanel, HasVerticalAlignment.ALIGN_TOP);
    showLoading(false);

    // =================

    export.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (!format.getValue((format.getSelectedIndex())).equals("")
                && !format.getValue(format.getSelectedIndex()).equals("--None--")) {
              exp.setFormat(format.getValue(format.getSelectedIndex()));
            } else {
              exp.setFormat(null);
            }
            String expformat = exp.getFormat();
            if (expformat == null || expformat.equals("")) {
              Window.alert(constants.exportSelectFormat());
            } else if (exp.getStartDate() != null || exp.getEndDate() != null) {
              if (exp.getStartDate() == null || exp.getEndDate() == null) {
                Window.alert(constants.exportSelectDateRange());
              }
            } else {
              showLoading(true);
              exp.setExpLanguage(userSelectedLanguage);
              exp.setTermCode(termCodeBox.getValue().equals("") ? null : termCodeBox.getValue());

              AsyncCallback<String> callback =
                  new AsyncCallback<String>() {
                    public void onSuccess(String key) {
                      String formattype = format.getValue(format.getSelectedIndex());

                      String filename =
                          "export_"
                              + formattype.toLowerCase()
                              + "_"
                              + DateTimeFormat.getFormat("ddMMyyyyhhmmss").format(new Date());

                      if (formattype.equals(ExportFormat.SKOS)
                          || formattype.equals(ExportFormat.SKOSXL)) filename += ".rdf";
                      else if (formattype.equals(ExportFormat.TBX)) filename += ".tbx";
                      else if (formattype.equals(ExportFormat.OWL_SIMPLE_FORMAT))
                        filename += ".owl";
                      else if (formattype.equals(ExportFormat.OWL_COMPLETE_FORMAT))
                        filename += ".owl";
                      else if (formattype.equals(ExportFormat.RDBMS_SQL_FORMAT)) filename += ".sql";

                      Window.open(
                          GWT.getHostPageBaseURL()
                              + "downloadExportData?filename="
                              + filename
                              + "&key="
                              + key
                              + "&size="
                              + ConfigConstants.ZIPSIZE
                              + "&forcezip="
                              + chkZip.getValue(),
                          "_download",
                          "");
                      showLoading(false);
                    }

                    public void onFailure(Throwable caught) {
                      showLoading(false);
                      ExceptionManager.showException(caught, constants.exportDataFail());
                    }
                  };
              Service.exportService.export(exp, MainApp.userId, 74, MainApp.userOntology, callback);
            }
          }
        });
  }
示例#8
0
  // Method response to user click of "Address" button in a post row
  // Causes popup panel to appear
  protected void doMapPopup(PostData post) {
    VerticalPanel content = new VerticalPanel();
    content.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final String address = post.getAddress();

    // Create a Panel to hold the map
    HorizontalPanel mapPanel = new HorizontalPanel();
    mapPanel.setSize("400px", "400px");

    // Create the Google Map object, with set options
    MapOptions myOptions = MapOptions.create();
    myOptions.setZoom(8.0);
    myOptions.setCenter(LatLng.create(-34.397, 150.644));
    myOptions.setMapTypeId(MapTypeId.ROADMAP);
    final GoogleMap map = GoogleMap.create(mapPanel.getElement(), myOptions);

    // GeoCoder is Google Maps API for taking an address and finding
    //  latitude-longitude.
    Geocoder geocoder = Geocoder.create();
    GeocoderRequest request = GeocoderRequest.create();
    request.setAddress(address);

    geocoder.geocode(
        request,
        new Callback() {
          public void handle(JsArray<GeocoderResult> results, GeocoderStatus status) {
            if (status == GeocoderStatus.OK) {
              GeocoderResult location = results.get(0);
              // Bug Fix - Needed to make sure that map is re-sized to parent panel
              map.triggerResize();
              map.setCenter(location.getGeometry().getLocation());
              // Create Marker (red) to show location
              MarkerOptions markerOpts = MarkerOptions.create();
              markerOpts.setMap(map);
              // Title of Marker will be address
              markerOpts.setTitle(address);
              // Place Marker at address location
              markerOpts.setPosition(location.getGeometry().getLocation());
              Marker.create(markerOpts);
            } else {
              Window.alert("Geocode was not successful for the following reason: " + status);
            }
          }
        });

    HorizontalPanel btnRow = new HorizontalPanel();
    btnRow.setStyleName("search-button-row");
    Button cancelBtn = new Button("Cancel");
    cancelBtn.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            searchPopup.hide();
          }
        });
    btnRow.add(cancelBtn);

    content.add(mapPanel);
    content.add(btnRow);
    searchPopup.setWidget(content);
    searchPopup.center();
  }
示例#9
0
  public void onModuleLoad() {
    RootPanel RootTXOriginal = RootPanel.get();
    RootPanel RootMenu = RootPanel.get("Menu");
    RootTXOriginal.setSize("100%", "100%");
    RootMenu.setStyleName("Root");
    RootTXOriginal.setStyleName("Root");

    YO = this;
    MenuBar menuBar = new MenuBar(false);
    RootMenu.add(menuBar);
    menuBar.setWidth("100%");

    MenuItem menuItem = new MenuItem("GroupAdministration", false, (Command) null);
    menuItem.setHTML("Users Administrator");
    menuItem.setEnabled(false);
    menuBar.addItem(menuItem);

    MenuItemSeparator separator = new MenuItemSeparator();
    menuBar.addSeparator(separator);

    MenuItem mntmBack =
        new MenuItem(
            "Back",
            false,
            new Command() {
              public void execute() {
                Controlador.change2Administrator();
              }
            });
    menuBar.addItem(mntmBack);

    MenuItem AddLots =
        new MenuItem(
            "Masive add",
            false,
            new Command() {
              public void execute() {
                PanelAddMasibo PAM = new PanelAddMasibo(YO);
                PAM.setVisible(true);
                PAM.center();
              }
            });
    AddLots.setHTML("Masive add");
    menuBar.addItem(AddLots);

    HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    RootTXOriginal.add(horizontalSplitPanel, 0, 25);
    horizontalSplitPanel.setSize("100%", "100%");

    VerticalPanel verticalPanel = new VerticalPanel();
    horizontalSplitPanel.setLeftWidget(verticalPanel);
    verticalPanel.setSize("100%", "");

    SimplePanel simplePanel = new SimplePanel();
    verticalPanel.add(simplePanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    simplePanel.setWidget(horizontalPanel);
    horizontalPanel.setSize("100%", "100%");

    textBox = new TextBox();
    textBox.setVisibleLength(50);
    horizontalPanel.add(textBox);
    textBox.setWidth("90%");

    Button btnNewButton = new Button("New button");
    btnNewButton.setText("+");
    btnNewButton.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });

    btnNewButton.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {

            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });

    btnNewButton.setStyleName("gwt-ButtonCenter");
    btnNewButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String S = ClearText(textBox.getText());
            if (isValidEmail(S)) addText(S);
            else Window.alert(ErrorConstants.ERROR_NO_EMAIL_VALIDO + S);
            textBox.setText("");
          }

          private native boolean isValidEmail(String email) /*-{
	        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	        	return !reg1.test(email) && reg2.test(email);
			}-*/;
        });

    horizontalPanel.add(btnNewButton);
    btnNewButton.setWidth("66px");
    btnNewButton.setHTML("+");

    verticalPanel_1 = new VerticalPanel();
    verticalPanel.add(verticalPanel_1);
    verticalPanel_1.setWidth("100%");

    SaveNewUsers = new Button("Save New Users");
    SaveNewUsers.setVisible(false);
    SaveNewUsers.addClickHandler(
        new ClickHandler() {
          private AsyncCallback<Boolean> callback;

          public void onClick(ClickEvent event) {
            Pilallamada = new Stack<UserApp>();
            int Elementos_a_salvar = verticalPanel_1.getWidgetCount();
            for (int i = 0; i < Elementos_a_salvar; i++) {
              Widget Uno = verticalPanel_1.getWidget(i);
              Button Dos = (Button) Uno;
              String Nombre = Dos.getText();
              Pilallamada.add(new UserApp(Nombre, Constants.STUDENT));
            }
            if (!Pilallamada.isEmpty()) {
              callback =
                  new AsyncCallback<Boolean>() {

                    public void onFailure(Throwable caught) {
                      Window.alert("The user could not be saved at this moment");
                      LoadingPanel.getInstance().hide();
                    }

                    public void onSuccess(Boolean result) {
                      LoadingPanel.getInstance().hide();
                      if (!result)
                        Window.alert(
                            "The user "
                                + Pilallamada.peek().getEmail()
                                + " already exists (if you do not see him/her it's because he may be administrator)");
                      Pilallamada.pop();
                      if (!Pilallamada.isEmpty()) {
                        LoadingPanel.getInstance().center();
                        LoadingPanel.getInstance().setLabelTexto("Saving...");
                        bookReaderServiceHolder.saveUser(Pilallamada.peek(), callback);

                      } else {
                        refreshPanel();
                      }
                    }
                  };
              LoadingPanel.getInstance().center();
              LoadingPanel.getInstance().setLabelTexto("Saving...");
              bookReaderServiceHolder.saveUser(Pilallamada.peek(), callback);
            }
            verticalPanel_1.clear();
            SaveNewUsers.setVisible(false);
          }
        });
    SaveNewUsers.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSavePush");
          }
        });
    SaveNewUsers.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSave");
          }
        });
    SaveNewUsers.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSaveOver");
          }
        });
    SaveNewUsers.setStyleName("gwt-ButtonBottonSave");
    //	SaveNewUsers.setStyleName("gwt-MenuItemMio");
    verticalPanel.add(SaveNewUsers);
    SaveNewUsers.setSize("100%", "100%");

    ScrollPanel scrollPanel = new ScrollPanel();
    horizontalSplitPanel.setRightWidget(scrollPanel);
    scrollPanel.setSize("100%", "100%");

    stackPanel_1 = new StackPanelMio();
    scrollPanel.setWidget(stackPanel_1);
    // simplePanel.add(stackPanel_1);

    stackPanel_1.setBotonTipo(new BotonesStackPanelUsersMio("prototipo", new VerticalPanel()));
    stackPanel_1.setBotonClick(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            Long Nombre = ((BotonesStackPanelUsersMio) event.getSource()).getEntidad().getID();
            LoadingPanel.getInstance().center();
            LoadingPanel.getInstance().setLabelTexto("Loading...");
            bookReaderServiceHolder.loadUserById(
                Nombre,
                new AsyncCallback<UserApp>() {

                  public void onFailure(Throwable caught) {
                    LoadingPanel.getInstance().hide();
                  }

                  public void onSuccess(UserApp result) {
                    LoadingPanel.getInstance().hide();
                    if (result.getGroupIds() == null) result.setGroupIds(new ArrayList<Long>());
                    if (!result.getGroupIds().isEmpty())
                      if (Window.confirm(
                          InformationConstants.ARE_YOU_SURE_DELETE_USER
                              + result.getGroupIds().size()
                              + InformationConstants.ARE_YOU_SURE_DELETE_USER2))
                        remove(result.getId());
                      else {
                      }
                    else {
                      if (Window.confirm(
                          "Are you sure you want to delete this user?, he is not a member of any group"))
                        remove(result.getId());
                    }
                  }
                });
          }

          private void remove(Long userId) {

            LoadingPanel.getInstance().center();
            LoadingPanel.getInstance().setLabelTexto("Deleting...");
            bookReaderServiceHolder.deleteUserApp(
                userId,
                new AsyncCallback<Integer>() {

                  public void onFailure(Throwable caught) {
                    LoadingPanel.getInstance().hide();
                    Window.alert("Sorry but the user could not be removed, try again later");
                  }

                  public void onSuccess(Integer result) {
                    LoadingPanel.getInstance().hide();
                    refreshPanel();
                  }
                });
          }
        });

    LoadingPanel.getInstance().center();
    LoadingPanel.getInstance().setLabelTexto("Loading...");
    bookReaderServiceHolder.getUsersApp(
        new AsyncCallback<ArrayList<UserApp>>() {

          public void onFailure(Throwable caught) {
            LoadingPanel.getInstance().hide();
          }

          public void onSuccess(ArrayList<UserApp> result) {
            LoadingPanel.getInstance().hide();
            if (result.size() < 10) {
              for (UserApp User1 : result) {
                String Bienvenida;
                if ((User1.getName() != null) && (!User1.getName().isEmpty()))
                  Bienvenida = User1.getName();
                else Bienvenida = User1.getEmail();
                EntidadUser E = new EntidadUser(Bienvenida, User1.getId());
                stackPanel_1.addBotonLessTen(E);
              }

            } else {
              for (UserApp User1 : result) {
                String Bienvenida;
                if ((User1.getName() != null) && (!User1.getName().isEmpty()))
                  Bienvenida = User1.getName();
                else Bienvenida = User1.getEmail();
                EntidadUser E = new EntidadUser(Bienvenida, User1.getId());
                stackPanel_1.addBoton(E);
              }
            }
            stackPanel_1.setSize("100%", "100%");
            stackPanel_1.ClearEmpty();
          }
        });

    stackPanel_1.setSize("100%", "100%");
  }