Exemple #1
0
  private SimplePlot createPlot(
      final String id, Markings markings, String xAxisLabel, double yMinimum, boolean isMetric) {
    PlotOptions plotOptions = new PlotOptions();
    plotOptions.setZoomOptions(new ZoomOptions().setAmount(1.02));
    plotOptions.setGlobalSeriesOptions(
        new GlobalSeriesOptions()
            .setLineSeriesOptions(
                new LineSeriesOptions().setLineWidth(1).setShow(true).setFill(0.1))
            .setPointsOptions(new PointsSeriesOptions().setRadius(1).setShow(true))
            .setShadowSize(0d));

    plotOptions.setPanOptions(new PanOptions().setInteractive(true));

    if (isMetric) {
      plotOptions.addXAxisOptions(
          new AxisOptions()
              .setZoomRange(true)
              .setTickDecimals(0)
              .setTickFormatter(
                  new TickFormatter() {
                    @Override
                    public String formatTickValue(double tickValue, Axis axis) {
                      if (tickValue >= 0 && tickValue < chosenSessions.size())
                        return chosenSessions.get((int) tickValue);
                      else return "";
                    }
                  }));
    } else {
      plotOptions.addXAxisOptions(new AxisOptions().setZoomRange(true).setMinimum(0));
    }

    plotOptions.addYAxisOptions(new AxisOptions().setZoomRange(false).setMinimum(yMinimum));

    plotOptions.setLegendOptions(new LegendOptions().setNumOfColumns(2));

    if (markings == null) {
      // Make the grid hoverable
      plotOptions.setGridOptions(new GridOptions().setHoverable(true));
    } else {
      // Make the grid hoverable and add  markings
      plotOptions.setGridOptions(
          new GridOptions().setHoverable(true).setMarkings(markings).setClickable(true));
    }

    // create the plot
    SimplePlot plot = new SimplePlot(plotOptions);
    plot.setHeight(200);
    plot.setWidth("100%");

    final PopupPanel popup = new PopupPanel();
    popup.addStyleName(getResources().css().infoPanel());
    final HTML popupPanelContent = new HTML();
    popup.add(popupPanelContent);

    // add hover listener
    if (isMetric) {
      plot.addHoverListener(
          new ShowCurrentValueHoverListener(popup, popupPanelContent, xAxisLabel, chosenSessions),
          false);
    } else {
      plot.addHoverListener(
          new ShowCurrentValueHoverListener(popup, popupPanelContent, xAxisLabel, null), false);
    }

    if (!isMetric && markings != null && !markingsMap.isEmpty()) {
      final PopupPanel taskInfoPanel = new PopupPanel();
      taskInfoPanel.setWidth("200px");
      taskInfoPanel.addStyleName(getResources().css().infoPanel());
      final HTML taskInfoPanelContent = new HTML();
      taskInfoPanel.add(taskInfoPanelContent);
      taskInfoPanel.setAutoHideEnabled(true);

      plot.addClickListener(
          new ShowTaskDetailsListener(id, markingsMap, taskInfoPanel, 200, taskInfoPanelContent),
          false);
    }

    return plot;
  }
  private void loadModule() {

    // basic settings
    session.setUiElements(new UiElements(null));

    // Get web page's BODY
    RootLayoutPanel body = RootLayoutPanel.get();

    // check RPC url
    if (session.getRpcUrl().isEmpty()) {
      VerticalPanel bodyContents = new VerticalPanel();
      bodyContents.setSize("100%", "300px");
      bodyContents.add(
          new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>RPC SERVER NOT FOUND!</h2>"));
      bodyContents.setCellHorizontalAlignment(
          bodyContents.getWidget(0), HasHorizontalAlignment.ALIGN_CENTER);
      bodyContents.setCellVerticalAlignment(
          bodyContents.getWidget(0), HasVerticalAlignment.ALIGN_BOTTOM);
      body.add(bodyContents);
      return;
    }

    // WEB PAGE SPLITTER
    bodySplitter.getElement().setId("appFormGUI");
    body.add(bodySplitter);

    // left menu
    leftMenu = new ApplicationFormLeftMenu();

    // show loading box
    loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();

    // switch menu event
    JsonCallbackEvents events =
        new JsonCallbackEvents() {
          @Override
          public void onFinished(JavaScriptObject jso) {

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            ArrayList<Application> apps = JsonUtils.jsoAsList(jso);
            if (apps != null && !apps.isEmpty()) {
              // show menu
              bodySplitter.addWest(leftMenu, 280);
            }
            // else don't show menu
            // MAIN CONTENT
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // WE DON'T WANT TO CONFUSE USER WITH STATUS MESSAGES
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }

          @Override
          public void onError(PerunError error) {
            // MAIN CONTENT

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            contentPanel.clear();
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }
        };

    // load VO to check if exists
    loadVo(events);
  }