Search in sources :

Example 1 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.

the class DeleteFolderCommand method performOperation.

protected void performOperation() {
    if (this.getSolutionPath() != null) {
        SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
        sbp.getFile(this.getSolutionPath(), new SolutionFileHandler() {

            @Override
            public void handle(RepositoryFile repositoryFile) {
                DeleteFolderCommand.this.repositoryFile = repositoryFile;
                performOperation(true);
            }
        });
    } else {
        performOperation(true);
    }
}
Also used : SolutionFileHandler(org.pentaho.mantle.client.events.SolutionFileHandler) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)

Example 2 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method editFile.

public void editFile() {
    if (filesListPanel.getSelectedFileItems() == null || filesListPanel.getSelectedFileItems().size() != 1) {
        return;
    }
    RepositoryFile file = filesListPanel.getSelectedFileItems().get(0).getRepositoryFile();
    if (file.getName().endsWith(".analysisview.xaction")) {
        // $NON-NLS-1$
        openFile(file, COMMAND.RUN);
    } else {
        // check to see if a plugin supports editing
        ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName());
        if (plugin != null && plugin.hasCommand(COMMAND.EDIT)) {
            // load the editor for this plugin
            String editUrl = getPath() + "api/repos/" + pathToId(file.getPath()) + "/" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            (plugin != null && (plugin.getCommandPerspective(COMMAND.EDIT) != null) ? plugin.getCommandPerspective(COMMAND.EDIT) : "editor");
            // See if it's already loaded
            for (int i = 0; i < contentTabPanel.getTabCount(); i++) {
                Widget w = contentTabPanel.getTab(i).getContent();
                if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(editUrl)) {
                    // Already up, select and exit
                    contentTabPanel.selectTab(i);
                    return;
                }
            }
            contentTabPanel.showNewURLTab(Messages.getString("editingColon") + file.getTitle(), Messages.getString("editingColon") + file.getTitle(), editUrl, // $NON-NLS-1$ //$NON-NLS-2$
            true);
        } else {
            MessageDialogBox dialogBox = new // $NON-NLS-1$
            MessageDialogBox(// $NON-NLS-1$
            Messages.getString("error"), // $NON-NLS-1$
            Messages.getString("cannotEditFileType"), true, false, true);
            dialogBox.center();
        }
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Widget(com.google.gwt.user.client.ui.Widget) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 3 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method getFile.

public void getFile(final String solutionPath, final SolutionFileHandler handler) {
    final String moduleBaseURL = GWT.getModuleBaseURL();
    final String moduleName = GWT.getModuleName();
    final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    // Expecting some encoding here
    final String path = solutionPath;
    // $NON-NLS-1$
    final String url = contextURL + "api/repo/files/" + pathToId(path) + "/properties";
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("repositoryFileDto", (JSONObject) JSONParser.parseLenient(response.getText()));
                    RepositoryFile repositoryFile = new RepositoryFile(jsonObject);
                    handler.handle(repositoryFile);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) RequestCallback(com.google.gwt.http.client.RequestCallback) JSONObject(com.google.gwt.json.client.JSONObject) Request(com.google.gwt.http.client.Request) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) JsArrayString(com.google.gwt.core.client.JsArrayString) RequestException(com.google.gwt.http.client.RequestException)

Example 4 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method openFile.

public void openFile(final String fileNameWithPath, final FileCommand.COMMAND mode) {
    final String moduleBaseURL = GWT.getModuleBaseURL();
    final String moduleName = GWT.getModuleName();
    final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    // Expecting some encoding here
    final String path = fileNameWithPath;
    // $NON-NLS-1$
    final String url = contextURL + "api/repo/files/" + pathToId(path) + "/properties";
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("repositoryFileDto", (JSONObject) JSONParser.parseLenient(response.getText()));
                    RepositoryFile repositoryFile = new RepositoryFile(jsonObject);
                    openFile(repositoryFile, mode);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) RequestCallback(com.google.gwt.http.client.RequestCallback) JSONObject(com.google.gwt.json.client.JSONObject) Request(com.google.gwt.http.client.Request) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) JsArrayString(com.google.gwt.core.client.JsArrayString) RequestException(com.google.gwt.http.client.RequestException)

Example 5 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.

the class FilesListPanel method selectNextItem.

public void selectNextItem(List<FileItem> currentItems) {
    if (currentItems == null || currentItems.size() < 1) {
        return;
    }
    FileItem currentItem = currentItems.get(currentItems.size() - 1);
    RepositoryFile currentRepositoryFile = currentItem.getRepositoryFile();
    int myIndex = -1;
    for (int i = 0; i < getFileCount(); i++) {
        FileItem fileItem = getFileItem(i);
        if (fileItem == currentItem) {
            myIndex = i;
        }
    }
    if (myIndex >= 0 && myIndex < getFileCount() - 1) {
        if (currentRepositoryFile.isHidden()) {
            // $NON-NLS-1$
            currentItem.setStyleName("hiddenFileLabel");
        } else {
            // $NON-NLS-1$
            currentItem.setStyleName("fileLabel");
        }
        FileItem nextItem = getFileItem(myIndex + 1);
        RepositoryFile nextRepositoryFile = nextItem.getRepositoryFile();
        if (nextRepositoryFile.isHidden()) {
            // $NON-NLS-1$
            nextItem.setStyleName("hiddenFileLabelSelected");
        } else {
            // $NON-NLS-1$
            nextItem.setStyleName("fileLabelSelected");
        }
        List<FileItem> fileItems = new ArrayList<FileItem>();
        fileItems.add(nextItem);
        setSelectedFileItems(fileItems);
        nextItem.fireFileSelectionEvent();
    }
}
Also used : ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)

Aggregations

RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)23 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)7 Request (com.google.gwt.http.client.Request)6 RequestBuilder (com.google.gwt.http.client.RequestBuilder)6 RequestCallback (com.google.gwt.http.client.RequestCallback)6 RequestException (com.google.gwt.http.client.RequestException)6 Response (com.google.gwt.http.client.Response)6 RepositoryFileTree (org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree)6 JsArrayString (com.google.gwt.core.client.JsArrayString)5 ArrayList (java.util.ArrayList)4 SolutionFileHandler (org.pentaho.mantle.client.events.SolutionFileHandler)4 FileChooserDialog (org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog)3 FileChooserListener (org.pentaho.gwt.widgets.client.filechooser.FileChooserListener)3 SolutionFileActionEvent (org.pentaho.mantle.client.events.SolutionFileActionEvent)3 JSONObject (com.google.gwt.json.client.JSONObject)2 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)2 TreeItemComparator (org.pentaho.gwt.widgets.client.filechooser.TreeItemComparator)2 PentahoTabPanel (org.pentaho.gwt.widgets.client.tabs.PentahoTabPanel)2 EmptyRequestCallback (org.pentaho.mantle.client.EmptyRequestCallback)2 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)2