private void handleCanCreate() {
   if (markedAsNoCreate) {
     markedAsNoCreate = false;
     setTooltip("Click to add card");
     CardSummaryListHeader.this.addStyleName("m-cursor-pointer");
     title.addStyleName("m-cursor-pointer");
     content.addStyleName("m-cursor-pointer");
   }
 }
    BuilderDrawer() {
      if (drawerResource != null) {
        Embedded drawerBkg = new Embedded(null, drawerResource);
        addComponent(drawerBkg, "top:0px;left:0px");
      }
      content = new TextArea();
      // only shows if no focus, and if we don't have focus, it's not normally showing
      // content.setInputPrompt("Type here to add to this card chain.");
      content.setWordwrap(true);
      content.setImmediate(true);
      content.setTextChangeEventMode(TextChangeEventMode.LAZY);
      content.setTextChangeTimeout(500);
      // cause exception w/ 2 windows?
      // content.setDebugId(CardTypeManager.getCardContentDebugId(ct));
      content.setId(
          CardDebug.getCardContentDebugId(ct)); // CardTypeManager.getCardContentDebugId(ct));

      content.addTextChangeListener(new characterTypedHandler());

      content.setWidth(CARDLISTHEADER_DRAWER_TEXT_W);
      content.setHeight(CARDLISTHEADER_DRAWER_TEXT_H);
      content.addStyleName("m-white-background");
      addComponent(content, CARDLISTHEADER_DRAWER_TEXT_POS);

      count = new Label("0/140");
      count.setWidth(CARDLISTHEADER_DRAWER_COUNT_W);
      count.setHeight(CARDLISTHEADER_DRAWER_COUNT_H);
      count.addStyleName("m-cardbuilder-count-text");
      addComponent(count, CARDLISTHEADER_DRAWER_COUNT_POS);

      cancelButt = new NativeButton("cancel");
      cancelButt.setWidth(CARDLISTHEADER_DRAWER_CANCEL_W);
      cancelButt.setHeight(CARDLISTHEADER_DRAWER_CANCEL_H);
      cancelButt.addStyleName("borderless");
      cancelButt.addStyleName("m-cardbuilder-button-text");
      cancelButt.addClickListener(new CancelHandler());
      addComponent(cancelButt, CARDLISTHEADER_DRAWER_CANCEL_POS);

      submitButt = new NativeButton("submit");
      // cause exception w/ 2 windows?
      // submitButt.setDebugId(CardTypeManager.getCardSubmitDebugId(ct));
      submitButt.setId(
          CardDebug.getCardSubmitDebugId(ct)); // CardTypeManager.getCardSubmitDebugId(ct));

      submitButt.setWidth(CARDLISTHEADER_DRAWER_OKBUTT_W);
      submitButt.setHeight(CARDLISTHEADER_DRAWER_OKBUTT_H);
      submitButt.addStyleName("borderless");
      submitButt.addStyleName("m-cardbuilder-button-text");
      submitButt.addClickListener(new CardPlayHandler());
      addComponent(submitButt, CARDLISTHEADER_DRAWER_OKBUTT_POS);

      setWidth(CARDLISTHEADER_DRAWER_W);
      setHeight(CARDLISTHEADER_DRAWER_H);
    }
Exemple #3
0
  private void renderPlots(
      HTMLPanel panel,
      List<PlotSeriesDto> plotSeriesDtoList,
      String id,
      double yMinimum,
      boolean isMetric) {
    panel.add(loadIndicator);

    SimplePlot redrawingPlot = null;

    VerticalPanel plotGroupPanel = new VerticalPanel();
    plotGroupPanel.setWidth("100%");
    plotGroupPanel.getElement().setId(id);

    for (PlotSeriesDto plotSeriesDto : plotSeriesDtoList) {
      Markings markings = null;
      if (plotSeriesDto.getMarkingSeries() != null) {
        markings = new Markings();
        for (MarkingDto plotDatasetDto : plotSeriesDto.getMarkingSeries()) {
          double x = plotDatasetDto.getValue();
          markings.addMarking(
              new Marking()
                  .setX(new Range(x, x))
                  .setLineWidth(1)
                  .setColor(plotDatasetDto.getColor()));
        }

        markingsMap.put(id, new TreeSet<MarkingDto>(plotSeriesDto.getMarkingSeries()));
      }

      final SimplePlot plot =
          createPlot(id, markings, plotSeriesDto.getXAxisLabel(), yMinimum, isMetric);
      redrawingPlot = plot;
      PlotModel plotModel = plot.getModel();

      for (PlotDatasetDto plotDatasetDto : plotSeriesDto.getPlotSeries()) {
        SeriesHandler handler =
            plotModel.addSeries(plotDatasetDto.getLegend(), plotDatasetDto.getColor());

        // Populate plot with data
        for (PointDto pointDto : plotDatasetDto.getPlotData()) {
          handler.add(new DataPoint(pointDto.getX(), pointDto.getY()));
        }
      }

      // Add X axis label
      Label xLabel = new Label(plotSeriesDto.getXAxisLabel());
      xLabel.addStyleName(getResources().css().xAxisLabel());

      Label plotHeader = new Label(plotSeriesDto.getPlotHeader());
      plotHeader.addStyleName(getResources().css().plotHeader());

      Label plotLegend = new Label("PLOT LEGEND");
      plotLegend.addStyleName(getResources().css().plotLegend());

      VerticalPanel vp = new VerticalPanel();
      vp.setWidth("100%");

      Label panLeftLabel = new Label();
      panLeftLabel.addStyleName(getResources().css().panLabel());
      panLeftLabel.getElement().appendChild(new Image(getResources().getArrowLeft()).getElement());
      panLeftLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.pan(new Pan().setLeft(-100));
            }
          });

      Label panRightLabel = new Label();
      panRightLabel.addStyleName(getResources().css().panLabel());
      panRightLabel
          .getElement()
          .appendChild(new Image(getResources().getArrowRight()).getElement());
      panRightLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.pan(new Pan().setLeft(100));
            }
          });

      Label zoomInLabel = new Label("Zoom In");
      zoomInLabel.addStyleName(getResources().css().zoomLabel());
      zoomInLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.zoom();
            }
          });

      Label zoomOutLabel = new Label("Zoom Out");
      zoomOutLabel.addStyleName(getResources().css().zoomLabel());
      zoomOutLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.zoomOut();
            }
          });

      FlowPanel zoomPanel = new FlowPanel();
      zoomPanel.addStyleName(getResources().css().zoomPanel());
      zoomPanel.add(panLeftLabel);
      zoomPanel.add(panRightLabel);
      zoomPanel.add(zoomInLabel);
      zoomPanel.add(zoomOutLabel);

      vp.add(plotHeader);
      vp.add(zoomPanel);
      vp.add(plot);
      vp.add(xLabel);
      // Will be added if there is need it
      // vp.add(plotLegend);

      plotGroupPanel.add(vp);
    }
    int loadingId = panel.getWidgetCount() - 1;
    panel.remove(loadingId);
    panel.add(plotGroupPanel);

    // Redraw plot
    if (redrawingPlot != null) {
      redrawingPlot.redraw();
    }
  }
  @SuppressWarnings("serial")
  @Override
  public void initGui() {
    addStyleName("m-cursor-pointer");
    if (bckgrndResource != null) {
      Embedded bkgnd = new Embedded(null, bckgrndResource);
      addComponent(bkgnd, "top:0px;left:0px");
    }
    final MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    ct = CardType.getTL(ctId);
    String textColorStyle = CardStyler.getCardTextColorOverBaseStyle(ct);

    // nested abslay for the click handler
    AbsoluteLayout topHalfLay = new AbsoluteLayout();
    topHalfLay.setWidth(CARDLISTHEADER_W);
    topHalfLay.setHeight(HEIGHT_NODRAWER);
    addComponent(topHalfLay, "top:0px;left:0px");

    title.setValue(ct.getTitle()); // .toUpperCase());
    title.setHeight(CARDLISTHEADER_TITLE_H);
    title.setWidth(CARDLISTHEADER_TITLE_W);
    title.addStyleName("m-cardsummarylist-header-title");
    title.addStyleName("m-cursor-pointer");
    title.addStyleName("m-vagabond-font");
    if (textColorStyle != null) title.addStyleName(textColorStyle);

    topHalfLay.addComponent(title, CARDLISTHEADER_TITLE_POS);

    content.setValue(ct.getPrompt());
    content.setHeight(CARDLISTHEADER_CONTENT_H);
    content.setWidth(CARDLISTHEADER_CONTENT_W);
    content.addStyleName("m-cardsummarylist-header-content");
    content.addStyleName("m-cursor-pointer");
    if (textColorStyle != null) content.addStyleName(textColorStyle);
    // cause exception w/ 2 windows?

    content.setId(CardDebug.getCardCreateClickDebugId(ct));
    topHalfLay.addComponent(content, CARDLISTHEADER_CONTENT_POS);

    boolean cantCreateBecauseHiddenParent = checkNoCreateBecauseHiddenTL(parent);
    boolean cantCreateBecauseParentMarkedNoChild =
        false; // todo enable with gameswitch checkNoCreateBecauseParentMarkedNoChild(parent);

    if (globs.canCreateCard(ct.isIdeaCard())) {
      markedAsNoCreate = false;
      if (!cantCreateBecauseHiddenParent && !cantCreateBecauseParentMarkedNoChild) {
        // Add the text at the bottom
        Label lab;
        topHalfLay.addComponent(lab = new Label("click to add new"), "top:130px;left:75px");
        lab.addStyleName("m-click-to-add-new");
        if (textColorStyle != null) lab.addStyleName(textColorStyle);
      }
    } else markedAsNoCreate = true;

    drawerComponent = new BuilderDrawer();
    addComponent(drawerComponent, CARDLISTHEADER_DRAWER_POS);
    drawerComponent.setVisible(false);

    setWidth(CARDLISTHEADER_W);
    setHeight(HEIGHT_NODRAWER);

    if (!mockupOnly)
      topHalfLay.addLayoutClickListener(
          new LayoutClickListener() {
            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void layoutClick(LayoutClickEvent event) {
              HSess.init();
              if (checkNoCreateBecauseHiddenTL(
                  parent)) { // todo enable with game switch ||
                             // checkNoCreateBecauseParentMarkedNoChild(parent)) {
                if (drawerComponent.isVisible()) closeDrawer();
                HSess.close();
                return;
              }

              if (drawerComponent.isVisible()) closeDrawer();
              else {
                CardPermission cp = globs.cardPermissionsCommon(ct.isIdeaCard());
                if (!cp.canCreate) {
                  if (!markedAsNoCreate) handleNoCreate();
                  Notification.show(cp.whyNot);
                } else {
                  showDrawer();
                  handleCanCreate(); // reset tt, etc.
                  if (newCardListener != null) newCardListener.drawerOpenedTL(ctId);
                }
              }
              HSess.close();
            }
          });
    if (cantCreateBecauseHiddenParent) handleNoCreate("Can't add card to hidden parent");
    else if (cantCreateBecauseParentMarkedNoChild)
      handleNoCreate("New child cards cannot be added to this card");
    else if (!globs.canCreateCard(ct.isIdeaCard())) handleNoCreate();
    else setTooltip("Click to add card");
  }