public void execute() {
   SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
   List<RepositoryFile> selectedList = sbp.getFilesListPanel().getRepositoryFiles();
   if (selectedList != null && selectedList.size() == 1) {
     RepositoryFile item = selectedList.get(0);
     FilePropertiesDialog dialog =
         new FilePropertiesDialog(
             item, new MantleTabPanel(), null, FilePropertiesDialog.Tabs.PERMISSION);
     dialog.showTab(FilePropertiesDialog.Tabs.PERMISSION);
     dialog.center();
   }
 }
 private Frame getActiveBrowserPerspectiveFrame() {
   IFrameTabPanel panel =
       SolutionBrowserPanel.getInstance().getContentTabPanel().getCurrentFrame();
   if (panel == null) {
     return null;
   } else {
     return panel.getFrame();
   }
 }
Esempio n. 3
0
 @Override
 public void popupClosed(PopupPanel panel) {
   IFrameTabPanel iframeTab =
       SolutionBrowserPanel.getInstance().getContentTabPanel().getCurrentFrame();
   if (iframeTab == null || iframeTab.getFrame() == null) {
     return;
   }
   Frame currentFrame = iframeTab.getFrame();
   FrameUtils.setEmbedVisibility(currentFrame, true);
 }
  /* (non-Javadoc)
   * @see org.pentaho.mantle.client.commands.AbstractCommand#performOperation()
   */
  @Override
  protected void performOperation() {

    if (this.getSolutionPath() != null) {
      SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
      sbp.getFile(
          this.getSolutionPath(),
          new SolutionFileHandler() {
            @Override
            public void handle(RepositoryFile repositoryFile) {
              if (repositoryFiles == null) {
                repositoryFiles = new ArrayList<FileItem>();
              }
              repositoryFiles.add(new FileItem(repositoryFile, null, null, false, null));
              performOperation(false);
            }
          });
    } else {
      performOperation(false);
    }
  }
  private SolutionBrowserPanel() {
    RootPanel.get().getElement().getStyle().setProperty("position", "relative");
    dragController = new SolutionBrowserDragController(contentTabPanel);
    instance = this;

    ExecuteUrlInNewTabCommand.setupNativeHooks();
    SolutionBrowserPanel.setupNativeHooks(this);

    solutionTree.addTreeListener(treeListener);
    initializeExecutableFileTypes();
    buildUI();
  }
Esempio n. 6
0
 @Override
 public void popupOpened(PopupPanel panel) {
   IFrameTabPanel iframeTab =
       SolutionBrowserPanel.getInstance().getContentTabPanel().getCurrentFrame();
   if (iframeTab == null || iframeTab.getFrame() == null) {
     return;
   }
   Frame currentFrame = iframeTab.getFrame();
   if (ElementUtils.elementsOverlap(panel.getElement(), currentFrame.getElement())) {
     FrameUtils.setEmbedVisibility(currentFrame, false);
   }
 }
  private void performRestoreToHomeFolder(
      final String filesList,
      final int restoreResponseStatusCode,
      final String userHomeFolderPath,
      final SolutionFileActionEvent event) {

    final String encodedUserHomeFolderPath = SolutionBrowserPanel.pathToId(userHomeFolderPath);
    String fileListDescription = "files";
    // if there is one file
    if (filesList.split(",").length == 1) {
      fileListDescription = "file";
    }

    HTML messageTextBox = new HTML();
    String cannotRestoreToOrigFolder =
        Messages.getString("cannotRestoreToOriginFolder", fileListDescription);
    String restoreToHomeFolder = Messages.getString("restoreToHomeFolder", userHomeFolderPath);

    messageTextBox.setHTML(cannotRestoreToOrigFolder + "<br> <br>" + restoreToHomeFolder + "<br>");
    final PromptDialogBox restoreFileWarningDialogBox =
        new PromptDialogBox(
            Messages.getString("couldNotWriteToFolder"), "Restore File", "Cancel", true, true);
    restoreFileWarningDialogBox.setContent(messageTextBox);

    final IDialogCallback callback =
        new IDialogCallback() {

          public void cancelPressed() {
            restoreFileWarningDialogBox.hide();
          }

          public void okPressed() {
            // We can't write to origin file folder, and there are
            // files in homeFolder with same names
            if (restoreResponseStatusCode == Response.SC_CONFLICT) {
              final OverwritePromptDialog overwriteDialog = new OverwritePromptDialog();
              final IDialogCallback callback =
                  new IDialogCallback() {
                    public void cancelPressed() {
                      event.setMessage("Cancel");
                      overwriteDialog.hide();
                    }

                    public void okPressed() {
                      String restoreFilesUrl =
                          contextURL
                              + "api/repo/files/restore?overwriteMode="
                              + overwriteDialog.getOverwriteMode(); // $NON-NLS-1$
                      RequestBuilder builder =
                          new RequestBuilder(RequestBuilder.PUT, restoreFilesUrl);
                      try {
                        builder.sendRequest(
                            filesList,
                            new RequestCallback() {
                              @Override
                              public void onResponseReceived(Request request, Response response) {
                                if (response.getStatusCode() == Response.SC_OK) {
                                  new RefreshRepositoryCommand().execute(false);
                                  event.setMessage("Success");
                                  EventBusUtil.EVENT_BUS.fireEvent(event);
                                } else {
                                  showErrorDialogBox(event);
                                }
                              }

                              @Override
                              public void onError(Request request, Throwable exception) {
                                showErrorDialogBox(event);
                              }
                            });
                      } catch (RequestException e) {
                        showErrorDialogBox(event);
                      }
                    }
                  };
              overwriteDialog.setCallback(callback);
              overwriteDialog.center();
            } else if (restoreResponseStatusCode == Response.SC_TEMPORARY_REDIRECT) {
              String moveFilesURL =
                  contextURL + "api/repo/files/" + encodedUserHomeFolderPath + "/move";
              RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, moveFilesURL);
              try {
                builder.sendRequest(
                    filesList,
                    new RequestCallback() {
                      @Override
                      public void onResponseReceived(Request request, Response response) {
                        new RefreshRepositoryCommand().execute(false);
                        event.setMessage("Success");
                        EventBusUtil.EVENT_BUS.fireEvent(event);
                      }

                      @Override
                      public void onError(Request request, Throwable exception) {
                        showErrorDialogBox(event);
                      }
                    });
              } catch (RequestException e) {
                showErrorDialogBox(event);
              }
            }
          }
        };

    restoreFileWarningDialogBox.setCallback(callback);
    restoreFileWarningDialogBox.center();
  }
  public void onMantleSettingsLoaded(MantleSettingsLoadedEvent event) {
    final HashMap<String, String> settings = event.getSettings();
    final String startupPerspective = Window.Location.getParameter("startupPerspective");

    mantleRevisionOverride = settings.get("user-console-revision");
    RootPanel.get("pucMenuBar").add(MantleXul.getInstance().getMenubar());
    if (!StringUtils.isEmpty(startupPerspective)) {
      RootPanel.get("pucMenuBar").setVisible(false);
    }

    RootPanel.get("pucPerspectives").add(PerspectiveManager.getInstance());
    if (!StringUtils.isEmpty(startupPerspective)) {
      RootPanel.get("pucPerspectives").setVisible(false);
    }

    RootPanel.get("pucToolBar").add(MantleXul.getInstance().getToolbar());
    if (!StringUtils.isEmpty(startupPerspective)) {
      RootPanel.get("pucToolBar").setVisible(false);
    }

    // update supported file types
    PluginOptionsHelper.buildEnabledOptionsList(settings);

    // show stuff we've created/configured
    contentDeck.add(new Label());
    contentDeck.showWidget(0);
    contentDeck.add(SolutionBrowserPanel.getInstance());
    if (!StringUtils.isEmpty(startupPerspective)) {
      SolutionBrowserPanel.getInstance().setVisible(false);
    }

    contentDeck.getElement().setId("applicationShell");
    contentDeck.setStyleName("applicationShell");

    // menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=1200,height=800
    try {
      RootPanel.get("pucContent").add(contentDeck);
    } catch (Throwable t) {
      // onLoad of something is causing problems
    }

    RootPanel.get().add(WaitPopup.getInstance());

    // Add in the overlay panel
    overlayPanel.setVisible(false);
    overlayPanel.setHeight("100%");
    overlayPanel.setWidth("100%");
    overlayPanel.getElement().getStyle().setProperty("zIndex", "1000");
    overlayPanel.getElement().getStyle().setProperty("position", "absolute");
    RootPanel.get().add(overlayPanel, 0, 0);

    String showAdvancedFeaturesSetting = settings.get("show-advanced-features"); // $NON-NLS-1$
    showAdvancedFeatures =
        showAdvancedFeaturesSetting == null
            ? showAdvancedFeatures
            : Boolean.parseBoolean(showAdvancedFeaturesSetting);

    String submitOnEnterSetting = settings.get("submit-on-enter-key");
    submitOnEnter =
        submitOnEnterSetting == null ? submitOnEnter : Boolean.parseBoolean(submitOnEnterSetting);

    try {
      String restUrl = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister"; // $NON-NLS-1$
      RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, restUrl);
      requestBuilder.sendRequest(
          null,
          new RequestCallback() {

            @Override
            public void onError(Request arg0, Throwable arg1) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox(
                      Messages.getString("error"),
                      arg1.getLocalizedMessage(),
                      false,
                      false,
                      true); //$NON-NLS-1$
              dialogBox.center();
            }

            @SuppressWarnings("deprecation")
            @Override
            public void onResponseReceived(Request arg0, Response response) {
              Boolean isAdministrator = Boolean.parseBoolean(response.getText());
              SolutionBrowserPanel.getInstance().setAdministrator(isAdministrator);

              try {
                String restUrl2 =
                    GWT.getHostPageBaseURL() + "api/scheduler/canSchedule"; // $NON-NLS-1$
                RequestBuilder requestBuilder2 = new RequestBuilder(RequestBuilder.GET, restUrl2);
                requestBuilder2.sendRequest(
                    null,
                    new RequestCallback() {
                      @Override
                      public void onError(Request arg0, Throwable arg1) {
                        MessageDialogBox dialogBox =
                            new MessageDialogBox(
                                Messages.getString("error"),
                                arg1.getLocalizedMessage(),
                                false,
                                false,
                                true); //$NON-NLS-1$
                        dialogBox.center();
                      }

                      public void onResponseReceived(Request arg0, Response response) {
                        Boolean isScheduler = Boolean.parseBoolean(response.getText());
                        SolutionBrowserPanel.getInstance().setScheduler(isScheduler);

                        String numStartupURLsSetting = settings.get("num-startup-urls");
                        if (numStartupURLsSetting != null) {
                          int numStartupURLs =
                              Integer.parseInt(numStartupURLsSetting); // $NON-NLS-1$
                          for (int i = 0; i < numStartupURLs; i++) {
                            String url = settings.get("startup-url-" + (i + 1)); // $NON-NLS-1$
                            String name = settings.get("startup-name-" + (i + 1)); // $NON-NLS-1$
                            if (url != null && !"".equals(url)) { // $NON-NLS-1$
                              SolutionBrowserPanel.getInstance()
                                  .getContentTabPanel()
                                  .showNewURLTab(name != null ? name : url, url, url, false);
                            }
                          }
                        }
                        if (SolutionBrowserPanel.getInstance().getContentTabPanel().getWidgetCount()
                            > 0) {
                          SolutionBrowserPanel.getInstance().getContentTabPanel().selectTab(0);
                        }

                        // startup-url on the URL for the app, wins over settings
                        String startupURL =
                            Window.Location.getParameter("startup-url"); // $NON-NLS-1$
                        if (startupURL != null && !"".equals(startupURL)) { // $NON-NLS-1$
                          String title = Window.Location.getParameter("name"); // $NON-NLS-1$
                          startupURL = URL.decodeComponent(startupURL);
                          SolutionBrowserPanel.getInstance()
                              .getContentTabPanel()
                              .showNewURLTab(title, title, startupURL, false);
                        }
                      }
                    });
              } catch (RequestException e) {
                MessageDialogBox dialogBox =
                    new MessageDialogBox(
                        Messages.getString("error"),
                        e.getLocalizedMessage(),
                        false,
                        false,
                        true); //$NON-NLS-1$
                dialogBox.center();
              }
            }
          });
    } catch (RequestException e) {
      MessageDialogBox dialogBox =
          new MessageDialogBox(
              Messages.getString("error"),
              e.getLocalizedMessage(),
              false,
              false,
              true); //$NON-NLS-1$
      dialogBox.center();
    }

    if (!StringUtils.isEmpty(startupPerspective)) {
      ICallback<Void> callback =
          new ICallback<Void>() {
            public void onHandle(Void nothing) {
              PerspectiveManager.getInstance().setPerspective(startupPerspective);
            }
          };
      PerspectiveManager.getInstance().addPerspectivesLoadedCallback(callback);
    }
  }