public AboutView() {
    super();

    mainPanel.setWidth("100%");
    mainPanel.add(new HTML("<h1>" + Messages.Util.INSTANCE.get().about() + "</h1>"));

    Panel panelV = new VerticalPanel();
    panelV.setWidth("100%");
    ((HasHorizontalAlignment) panelV).setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    Panel panel = new FlowPanel();
    panel.getElement().getStyle().setProperty("maxWidth", "400px");

    // might be judicious to use css instead...
    String pstyle = "style=\"text-align: justify; font-size: 125%;\"";

    StringBuilder htmlStr = new StringBuilder();

    htmlStr.append("<h2>General Information</h2>");

    htmlStr.append("<p ").append(pstyle).append(">");
    htmlStr.append("This simple web app provides a showcase for the ");
    htmlStr.append("<a href=\"https://developer.lufthansa.com/\">Lufthansa Open API</a>. ");
    htmlStr.append(
        "The API and data are used in conformance with the <a href=\"https://developer.lufthansa.com/General_Terms_and_Conditions\">license</a>.");
    htmlStr.append("</p>");

    htmlStr.append("<h2>Some Technical Aspects</h2>");

    htmlStr.append("<p ").append(pstyle).append(">");
    htmlStr.append("This app is developped using <a href=\"http://www.gwtproject.org/\">GWT</a>. ");
    htmlStr.append(
        "It reposes on the MVP architecture (Model-View-Presenter) as described in the article <a href=\"http://www.gwtproject.org/articles/mvp-architecture.html\">Building MVP apps</a>.");
    htmlStr.append("</p>");

    htmlStr.append("<h2>Source Code</h2>");

    htmlStr.append("<p ").append(pstyle).append(">");
    htmlStr.append(
        "The source code is available on <a href=\"https://github.com/roikku/lh-api-showcase\">GitHub</a>. ");
    htmlStr.append("</p>");

    htmlStr.append("<h2>Disclaimer</h2>");

    htmlStr.append("<p ").append(pstyle).append(">");
    htmlStr.append(
        "The owner of this website cannot be held liable for damages of any kind arising out of use, reference to, or reliance on any information found on this site. It must be borne in mind that no guarantee is given that the information provided in this website is correct, complete, and up-to-date.");
    htmlStr.append("</p>");

    panel.add(new HTML(htmlStr.toString()));
    panelV.add(panel);
    mainPanel.add(panelV);
    initWidget(mainPanel);
  }
  @Override
  public void init(P presenter) {
    super.setPresenter(presenter);
    super.setVisualization(container);

    container.add(titleHtml);
    container.add(filterPanel);
    container.add(displayerPanel);

    filterPanel.getElement().setAttribute("cellpadding", "2");
  }
Exemple #3
0
  /**
   * @see com.alkacon.acacia.client.I_EntityRenderer#renderForm(com.alkacon.vie.shared.I_Entity,
   *     com.google.gwt.user.client.ui.Panel)
   */
  public void renderForm(final I_Entity entity, Panel context) {

    context.addStyleName(ENTITY_CLASS);
    context.getElement().setAttribute("typeof", entity.getTypeName());
    context.getElement().setAttribute("about", entity.getId());
    I_Type entityType = m_vie.getType(entity.getTypeName());
    List<String> attributeNames = entityType.getAttributeNames();
    for (final String attributeName : attributeNames) {
      AttributeHandler handler =
          new AttributeHandler(m_vie, entity, attributeName, m_widgetService);
      I_Type attributeType = entityType.getAttributeType(attributeName);
      I_EntityRenderer renderer =
          m_widgetService.getRendererForAttribute(attributeName, attributeType);
      int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
      String label = m_widgetService.getAttributeLabel(attributeName);
      String help = m_widgetService.getAttributeHelp(attributeName);
      ValuePanel attributeElement = new ValuePanel();
      context.add(attributeElement);
      I_EntityAttribute attribute = entity.getAttribute(attributeName);
      if ((attribute == null) && (minOccurrence > 0)) {
        attribute = createEmptyAttribute(entity, attributeName, minOccurrence);
      }
      if (attribute != null) {
        for (int i = 0; i < attribute.getValueCount(); i++) {
          AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
          attributeElement.add(valueWidget);
          if (attribute.isSimpleValue()) {
            valueWidget.setValueWidget(
                m_widgetService.getAttributeWidget(attributeName),
                attribute.getSimpleValues().get(i));
          } else {
            valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
          }
        }
      } else {
        AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
        attributeElement.add(valueWidget);
      }
      handler.updateButtonVisisbility();
    }
  }
 /* (non-Javadoc)
  * @see com.google.gwt.user.client.ui.UIObject#getElement()
  */
 @Override
 public Element getElement() {
   return calendarDlg != null ? calendarDlg.getElement() : outer.getElement();
 }
  /**
   * Creates the calendar instance based in the configuration provided.
   *
   * <p>Options can be passed joining these using the or bit wise operator
   *
   * <ul>
   *   <li>CONFIG_DIALOG show as modal dialog
   *   <li>CONFIG_ROUNDED_BOX wrap with a rounded-corner box
   *   <li>CONFIG_NO_AUTOHIDE don't autohide dialog when the user click out of the picker
   *   <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden
   *   <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden
   *   <li>CONFIG_BACKGROUND show a semitransparent background covering all the document
   *   <li>CONFIG_FLAT_BUTTONS use native Buttons instead of GWTCButton also add the dependent class
   *       'flat'
   *   <li>CONFIG_STANDARD_BUTTONS use native browser Buttons instead of GWTCButton
   * </ul>
   */
  public void initialize(int config) {

    int buttonsType = config & CONFIG_FLAT_BUTTONS | config & CONFIG_STANDARD_BUTTONS;
    helpBtn = createButton(buttonsType, "?", this);
    closeBtn = createButton(buttonsType, "x", this);
    todayBtn = createButton(buttonsType, "-", this);
    prevMBtn = createButton(buttonsType, "\u003c", this);
    prevYBtn = createButton(buttonsType, "\u00AB", this);
    nextMBtn = createButton(buttonsType, "\u003e", this);
    nextYBtn = createButton(buttonsType, "\u00BB", this);

    if ((config & CONFIG_DIALOG) == CONFIG_DIALOG) {
      int opt = 0;
      if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) {
        opt |= GWTCModalBox.OPTION_ROUNDED_FLAT;
      }
      if ((config & CONFIG_BACKGROUND) != CONFIG_BACKGROUND) {
        opt |= GWTCModalBox.OPTION_DISABLE_BACKGROUND;
        if ((config & CONFIG_NO_AUTOHIDE) == CONFIG_NO_AUTOHIDE) {
          opt |= GWTCModalBox.OPTION_DISABLE_AUTOHIDE;
        }
      }
      calendarDlg = new GWTCModalBox(opt);
      calendarDlg.setAnimationEnabled((config & CONFIG_NO_ANIMATION) != CONFIG_NO_ANIMATION);

      outer = calendarDlg;
      initWidget(new DockPanel());

      setStyleName(styleName);
      addStyleDependentName(StyleDialog);
      setZIndex(999);
    } else {
      if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) {
        outer = new GWTCBox(GWTCBox.STYLE_FLAT);
      } else {
        outer = new VerticalPanel();
      }
      String s = outer.getStyleName();
      initWidget(outer);
      setStyleName(styleName);
      addStyleDependentName(StyleEmbeded);
      if (s != null && s.length() > 0) addStyleName(s);
    }

    helpDlg.addStyleName(StyleHelp);
    navButtonsTop.setStyleName(StyleCButtonsTop);
    navButtonsBottom.setStyleName(StyleCButtonsBottom);
    calendarGrid.setStyleName(StyleMonthGrid);
    navButtonsTop.setWidth("100%");
    calendarGrid.setWidth("100%");
    navButtonsBottom.setWidth("100%");

    if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) addStyleDependentName(StyleBox);
    else addStyleDependentName(StyleNoBox);

    if ((config & CONFIG_DIALOG) != CONFIG_DIALOG) closeBtn.setVisible(false);

    monthSelectorHeader.setAnimationEnabled(true);

    outer.add(navButtonsTop);
    outer.add(calendarGrid);
    outer.add(navButtonsBottom);

    drawDatePickerWidget();
    refresh();

    DOM.sinkEvents(outer.getElement(), Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONCLICK);
    DOM.setStyleAttribute(outer.getElement(), "cursor", "default");
    DOM.setElementAttribute(monthMenu.getElement(), "align", "center");
  }
 public void formatTimeline(float top, float height) {
   timelineFillPanel.setHeight(height + "%");
   DOM.setStyleAttribute(timelineFillPanel.getElement(), "top", top + "%");
 }
 public void setDescription(String description) {
   this.description = description;
   DOM.setInnerHTML(bodyPanel.getElement(), description);
 }
  @Override
  public SurveyStageInterface getInterface(
      final Callback1<MealOperation> onComplete,
      Callback1<Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>> updateIntermediateState) {
    final TemplateFood food = (TemplateFood) meal.foods.get(foodIndex);
    final ComponentDef component = food.data.template.get(componentIndex);

    final FlowPanel content = new FlowPanel();

    PromptUtil.addBackLink(content);

    component.headerConstructor.accept(
        new Option.SideEffectVisitor<Function0<Widget>>() {
          @Override
          public void visitSome(Function0<Widget> item) {
            Widget header = item.apply();
            ShepherdTour.makeShepherdTarget(header);
            content.add(header);
          }

          @Override
          public void visitNone() {}
        });

    SafeHtml promptText;

    if (isFirst) promptText = SafeHtmlUtils.fromSafeConstant(component.primaryInstancePrompt);
    else promptText = SafeHtmlUtils.fromSafeConstant(component.secondaryInstancePrompt);

    final Panel promptPanel =
        WidgetFactory.createPromptPanel(
            promptText,
            WidgetFactory.createHelpButton(
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent arg0) {
                    String promptType =
                        CompoundFoodPrompt.class.getSimpleName() + "." + food.data.template_id;
                    GoogleAnalytics.trackHelpButtonClicked(promptType);
                    ShepherdTour.startTour(
                        tour.plusAll(foodBrowser.getShepherdTourSteps()), promptType);
                  }
                }));

    content.add(promptPanel);
    ShepherdTour.makeShepherdTarget(promptPanel);
    promptPanel.getElement().setId("intake24-compound-food-prompt");

    String skipLabel;

    if (isFirst) skipLabel = component.primarySkipButtonLabel;
    else skipLabel = component.secondarySkipButtonLabel;

    Option<SkipFoodHandler> skipHandler =
        allowSkip
            ? Option.some(
                new SkipFoodHandler(
                    skipLabel,
                    new Callback() {
                      @Override
                      public void call() {
                        onComplete.call(
                            MealOperation.updateTemplateFood(
                                foodIndex,
                                new Function1<TemplateFood, TemplateFood>() {
                                  @Override
                                  public TemplateFood apply(TemplateFood argument) {
                                    return argument.markComponentComplete(componentIndex);
                                  }
                                }));
                      }
                    }))
            : Option.<SkipFoodHandler>none();

    foodBrowser =
        new FoodBrowser(
            locale,
            new Callback1<FoodData>() {
              @Override
              public void call(final FoodData result) {
                onComplete.call(
                    MealOperation.update(
                        new Function1<Meal, Meal>() {
                          @Override
                          public Meal apply(Meal argument) {
                            EncodedFood componentFood =
                                new EncodedFood(
                                    result,
                                    FoodLink.newLinked(food.link.id),
                                    "compound food template");
                            return argument
                                .plusFood(componentFood)
                                .updateFood(
                                    foodIndex,
                                    food.addComponent(componentIndex, componentFood.link.id));
                          }
                        }));
              }
            },
            new Callback1<String>() {
              @Override
              public void call(String code) {
                throw new RuntimeException(
                    "Special foods are not allowed as compound food ingredients");
              }
            },
            new Callback() {
              @Override
              public void call() {
                onComplete.call(
                    MealOperation.update(
                        new Function1<Meal, Meal>() {
                          @Override
                          public Meal apply(Meal argument) {
                            MissingFood missingFood =
                                new MissingFood(
                                        FoodLink.newLinked(food.link.id), component.name, false)
                                    .withFlag(MissingFood.NOT_HOME_RECIPE_FLAG);

                            return argument
                                .plusFood(missingFood)
                                .updateFood(
                                    foodIndex,
                                    food.addComponent(componentIndex, missingFood.link.id));
                          }
                        }));
              }
            },
            skipHandler,
            false,
            Option.<Pair<String, String>>none());

    foodBrowser.browse(
        component.categoryCode,
        component.dataSetLabel,
        component.foodsLabel,
        component.categoriesLabel);

    content.add(foodBrowser);

    return new SurveyStageInterface.Aligned(
        content,
        HasHorizontalAlignment.ALIGN_LEFT,
        HasVerticalAlignment.ALIGN_TOP,
        SurveyStageInterface.DEFAULT_OPTIONS);
  }
 @Override
 public Style getBodyStyle() {
   return displayerPanel.getElement().getStyle();
 }
 @Override
 public Style getHeaderStyle() {
   return headerPanel.getElement().getStyle();
 }
Exemple #11
0
  public GWTGraphics(final Panel panel, final LGame game, final GWTSetting cfg) {
    super(game, new GWTGL20(), new Scale(cfg.scaleFactor));

    this.config = cfg;
    Document doc = Document.get();
    this.dummyCanvas = doc.createCanvasElement();
    this.dummyCtx = dummyCanvas.getContext2d();

    Element root = panel.getElement();

    this.rootElement = root;

    measureElement = doc.createDivElement();
    measureElement.getStyle().setVisibility(Style.Visibility.HIDDEN);
    measureElement.getStyle().setPosition(Style.Position.ABSOLUTE);
    measureElement.getStyle().setTop(-500, Unit.PX);
    measureElement.getStyle().setOverflow(Style.Overflow.VISIBLE);
    measureElement.getStyle().setWhiteSpace(Style.WhiteSpace.NOWRAP);
    root.appendChild(measureElement);

    mouseScale = config.scaleFactor / Loon.devicePixelRatio();

    canvas = Document.get().createCanvasElement();
    root.appendChild(canvas);
    if (config.scaling()) {
      setSize(
          config.width_zoom > 0 ? config.width_zoom : root.getOffsetWidth(),
          config.height_zoom > 0 ? config.height_zoom : root.getOffsetHeight());
    } else {
      setSize(
          config.width > 0 ? config.width : root.getOffsetWidth(),
          config.height > 0 ? config.height : root.getOffsetHeight());
    }
    WebGLContextAttributes attrs = WebGLContextAttributes.create();
    attrs.setAntialias(config.antiAliasing);
    attrs.setStencil(config.stencil);
    attrs.setAlpha(config.transparentCanvas);
    attrs.setPremultipliedAlpha(config.premultipliedAlpha);
    attrs.setPreserveDrawingBuffer(config.preserveDrawingBuffer);

    WebGLRenderingContext glc = WebGLRenderingContext.getContext(canvas, attrs);
    if (glc == null) {
      throw new RuntimeException("Unable to create GL context");
    }

    ((GWTGL20) gl).init(glc);

    if (config.scaling()) {
      glc.viewport(0, 0, config.width_zoom, config.height_zoom);
    } else {
      glc.viewport(0, 0, config.width, config.height);
    }

    if (config.fullscreen) {
      Window.addResizeHandler(
          new ResizeHandler() {
            @Override
            public void onResize(ResizeEvent event) {
              if (getScreenWidthJSNI() == event.getWidth()
                  && getScreenHeightJSNI() == event.getHeight()) {
                float width = LSystem.viewSize.width(), height = LSystem.viewSize.height();
                experimentalScale =
                    Math.min(getScreenWidthJSNI() / width, getScreenHeightJSNI() / height);

                int yOfs = (int) ((getScreenHeightJSNI() - height * experimentalScale) / 3.f);
                int xOfs = (int) ((getScreenWidthJSNI() - width * experimentalScale) / 2.f);
                rootElement.setAttribute(
                    "style",
                    "width:"
                        + experimentalScale * width
                        + "px; "
                        + "height:"
                        + experimentalScale * height
                        + "px; "
                        + "position:absolute; left:"
                        + xOfs
                        + "px; top:"
                        + yOfs);
                Document.get().getBody().addClassName("fullscreen");
              } else {
                experimentalScale = 1;
                rootElement.removeAttribute("style");
                Document.get().getBody().removeClassName("fullscreen");
              }
            }
          });
    }

    Loon.self.addHandler(
        new OrientationChangedHandler() {
          @Override
          public void onChanged(Orientation newOrientation) {
            int width = Loon.self.getContainerWidth();
            int height = Loon.self.getContainerHeight();
            game.log().info("update screen size width :" + width + " height :" + height);
            setSize(width, height);
          }
        });
  }