public void openFile(final RepositoryFile repositoryFile, final FileCommand.COMMAND mode) {
   PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
   String fileNameWithPath = repositoryFile.getPath();
   if (mode == FileCommand.COMMAND.EDIT) {
     editFile();
   } else if (mode == FileCommand.COMMAND.SCHEDULE_NEW) {
     ScheduleHelper.createSchedule(repositoryFile);
   } else if (mode == FileCommand.COMMAND.SHARE) {
     (new ShareFileCommand()).execute();
   } else {
     String url = null;
     String extension = ""; // $NON-NLS-1$
     if (fileNameWithPath.lastIndexOf(".") > 0) { // $NON-NLS-1$
       extension =
           fileNameWithPath.substring(fileNameWithPath.lastIndexOf(".") + 1); // $NON-NLS-1$
     }
     if (!executableFileExtensions.contains(extension)) {
       url =
           getPath()
               + "api/repos/"
               + pathToId(fileNameWithPath)
               + "/content"; //$NON-NLS-1$ //$NON-NLS-2$
     } else {
       ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(fileNameWithPath);
       url =
           getPath()
               + "api/repos/"
               + pathToId(fileNameWithPath)
               + "/"
               + (plugin != null && (plugin.getCommandPerspective(mode) != null)
                   ? plugin.getCommandPerspective(mode)
                   : "generatedContent"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     if (mode == FileCommand.COMMAND.NEWWINDOW) {
       Window.open(
           url,
           "_blank",
           "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no"); //$NON-NLS-1$
       // //$NON-NLS-2$
     } else {
       contentTabPanel.showNewURLTab(
           repositoryFile.getTitle(), repositoryFile.getTitle(), url, true);
       addRecent(fileNameWithPath, repositoryFile.getTitle());
     }
   }
 }
  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);
    }
  }