Example #1
0
 public void createDeepLink() {
   if (tabContent instanceof IFrameTabPanel) {
     PromptDialogBox dialogBox =
         new PromptDialogBox(
             Messages.getString("deepLink"),
             Messages.getString("ok"),
             Messages.getString("cancel"),
             false, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             true);
     String url =
         Window.Location.getProtocol()
             + "//"
             + Window.Location.getHostName()
             + ":"
             + Window.Location.getPort()
             + Window.Location.getPath() // $NON-NLS-1$ //$NON-NLS-2$
             + "?name="
             + textLabel.getText()
             + "&startup-url="; //$NON-NLS-1$ //$NON-NLS-2$
     String startup = ((IFrameTabPanel) tabContent).getUrl();
     TextBox urlbox = new TextBox();
     urlbox.setText(url + URL.encodeComponent(startup));
     urlbox.setVisibleLength(80);
     dialogBox.setContent(urlbox);
     dialogBox.center();
   }
 }
Example #2
0
 public void refreshWebDAVPassword() {
   Configuration conf = (Configuration) GWT.create(Configuration.class);
   String domain = Window.Location.getHostName();
   String path = Window.Location.getPath();
   String cookie = conf.webdavCookie();
   webDAVPassword = Cookies.getCookie(cookie);
   Cookies.setCookie(cookie, "", null, domain, path, false);
 }
Example #3
0
 public static String formHrefWithWindowLocationPath(String strToAppend) {
   String noUrlParams = Window.Location.getPath();
   // Append '/' if necessary.
   if (!strToAppend.isEmpty() && !StringUtil.match(noUrlParams, "\\/$")) {
     noUrlParams += "/";
   }
   return noUrlParams + strToAppend;
 }
Example #4
0
 /** Clear the cookie and redirect the user to the logout page. */
 void logout() {
   Configuration conf = (Configuration) GWT.create(Configuration.class);
   String cookie = conf.authCookie();
   String domain = Window.Location.getHostName();
   String path = Window.Location.getPath();
   Cookies.setCookie(cookie, "", null, domain, path, false);
   String baseUrl = GWT.getModuleBaseURL();
   String homeUrl = baseUrl.substring(0, baseUrl.indexOf(path));
   Window.Location.assign(homeUrl + conf.logoutUrl());
 }
 private String getPath() {
   String mypath = Window.Location.getPath();
   if (!mypath.endsWith("/")) { // $NON-NLS-1$
     mypath = mypath.substring(0, mypath.lastIndexOf("/") + 1); // $NON-NLS-1$
   }
   mypath = mypath.replaceAll("/mantle/", "/"); // $NON-NLS-1$ //$NON-NLS-2$
   if (!mypath.endsWith("/")) { // $NON-NLS-1$
     mypath = "/" + mypath; // $NON-NLS-1$
   }
   return mypath;
 }
Example #6
0
  /**
   * Creates the main view of Guvnor. The path used to invoke guvnor is used to identify the view to
   * show: If the path contains "StandaloneEditor.html" then the StandaloneGuidedEditorManager is
   * used to render the view. If not, the default view is shown.
   */
  private void createMain() {
    EventBus eventBus = new SimpleEventBus();
    SuggestionCompletionCache.getInstance().setEventBus(eventBus);
    ClientFactory clientFactory = new ClientFactoryImpl(eventBus);
    appController = new AppController(clientFactory, eventBus);

    if (Window.Location.getPath().contains("StandaloneEditor.html")) {
      RootLayoutPanel.get()
          .add(new StandaloneEditorManager(clientFactory, eventBus).getBaseLayout());
    } else {

      RootLayoutPanel.get().add(appController.getMainPanel());
    }
  }
Example #7
0
  @Override
  public void onValueChange(ValueChangeEvent<String> event) {
    String hash = event.getValue();

    recordAnalyticsHit(Window.Location.getPath() + Window.Location.getHash());

    String[] parts = hash.split(",");

    if (parts.length == 12) {
      String code = parts[0];
      Integer year = Integer.decode(parts[1]);
      try {
        Integer timeLineDataType = Integer.decode(parts[2]);
        Integer timeLineChartSelect0 = Integer.decode(parts[3]);
        Integer timeLineChartSelect1 = Integer.decode(parts[4]);
        Integer timeLineChartSelect2 = Integer.decode(parts[5]);
        Integer timeLineChartSelect3 = Integer.decode(parts[6]);
        Integer timeLineChartSelect4 = Integer.decode(parts[7]);
        Integer timeLineChartSelect5 = Integer.decode(parts[8]);
        Integer pieChartDataType = Integer.decode(parts[9]);
        Integer pieChartNet = Integer.decode(parts[10]);
        Integer resultsGridNet = Integer.decode(parts[11]);
        selectBudgetCode(code, year);
        mTimeLineCharter.setState(
            timeLineDataType,
            timeLineChartSelect0,
            timeLineChartSelect1,
            timeLineChartSelect2,
            timeLineChartSelect3,
            timeLineChartSelect4,
            timeLineChartSelect5);
        mPieCharter.setState(pieChartDataType, pieChartNet);
        mResultsGrid.setState(resultsGridNet);
      } catch (Exception e) {
        Log.error("Application::onValueChange: Error while parsing url", e);
        newCodeAndYear("00", 2012);
      }
    } else {
      Log.error("Application::onValueChange: Error while parsing url");
      newCodeAndYear("00", 2012);
    }
  }
Example #8
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }
        @SuppressWarnings("deprecation")
        public void okPressed() {
          String path = Window.Location.getPath();
          if (!path.endsWith("/")) { // $NON-NLS-1$
            path = path.substring(0, path.lastIndexOf("/") + 1); // $NON-NLS-1$
          }
          RequestBuilder builder =
              new RequestBuilder(
                  RequestBuilder.POST, path + "j_spring_security_check"); // $NON-NLS-1$
          builder.setHeader(
              "Content-Type", "application/x-www-form-urlencoded"); // $NON-NLS-1$ //$NON-NLS-2$
          builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
          RequestCallback callback =
              new RequestCallback() {

                public void onError(Request request, Throwable exception) {
                  outerCallback.onFailure(exception);
                }

                public void onResponseReceived(Request request, Response response) {

                  try {
                    final String url =
                        GWT.getHostPageBaseURL() + "api/mantle/isAuthenticated"; // $NON-NLS-1$
                    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
                    requestBuilder.setHeader("accept", "text/plain");
                    requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    requestBuilder.sendRequest(
                        null,
                        new RequestCallback() {

                          public void onError(Request request, final Throwable caught) {
                            MessageDialogBox errBox =
                                new MessageDialogBox(
                                    Messages.getString("loginError"),
                                    Messages.getString("authFailed"),
                                    false,
                                    false,
                                    true); //$NON-NLS-1$ //$NON-NLS-2$
                            errBox.setCallback(
                                new IDialogCallback() {
                                  public void cancelPressed() {}

                                  public void okPressed() {
                                    outerCallback.onFailure(caught);
                                  }
                                });
                            errBox.show();
                          }

                          public void onResponseReceived(Request request, Response response) {
                            if ("true".equalsIgnoreCase(response.getText())) {
                              long year = 1000 * 60 * 60 * 24 * 365;
                              // one year into the future
                              Date expirationDate = new Date(System.currentTimeMillis() + year);
                              Cookies.setCookie(
                                  "loginNewWindowChecked",
                                  "" + newWindowChk.getValue(),
                                  expirationDate); //$NON-NLS-1$ //$NON-NLS-2$
                              outerCallback.onSuccess(
                                  newWindowChk != null && newWindowChk.getValue());
                            } else {
                              outerCallback.onFailure(
                                  new Throwable(Messages.getString("authFailed"))); // $NON-NLS-1$
                            }
                          }
                        });
                  } catch (final RequestException e) {
                    MessageDialogBox errBox =
                        new MessageDialogBox(
                            Messages.getString("loginError"),
                            Messages.getString("authFailed"),
                            false,
                            false,
                            true); //$NON-NLS-1$ //$NON-NLS-2$
                    errBox.setCallback(
                        new IDialogCallback() {
                          public void cancelPressed() {}

                          public void okPressed() {
                            outerCallback.onFailure(e);
                          }
                        });
                    errBox.show();
                  }
                }
              };
          try {
            String username = userTextBox.getText();
            String password = passwordTextBox.getText();
            builder.sendRequest(
                "j_username="******"&j_password="
                    + URL.encodeComponent(password),
                callback); //$NON-NLS-1$ //$NON-NLS-2$
          } catch (RequestException e) {
            e.printStackTrace();
          }
        }