Search in sources :

Example 36 with Container

use of org.eclipse.che.ide.api.resources.Container in project che by eclipse.

the class RefreshPathAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    event.getPresentation().setText("Refresh");
    event.getPresentation().setVisible(true);
    final Resource[] resources = appContext.getResources();
    if (resources == null || resources.length != 1) {
        event.getPresentation().setEnabled(false);
        return;
    }
    final Resource resource = resources[0];
    if (resource instanceof Container) {
        event.getPresentation().setText("Refresh '" + resource.getName() + "'");
    } else {
        final Container parent = resource.getParent();
        if (parent != null) {
            event.getPresentation().setText("Refresh '" + parent.getName() + "'");
        } else {
            event.getPresentation().setEnabled(false);
            return;
        }
    }
    event.getPresentation().setEnabled(true);
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 37 with Container

use of org.eclipse.che.ide.api.resources.Container in project che by eclipse.

the class NewFolderAction method createFolder.

final void createFolder(String name) {
    Resource resource = appContext.getResource();
    if (!(resource instanceof Container)) {
        final Container parent = resource.getParent();
        checkState(parent != null, "Parent should be a container");
        resource = parent;
    }
    ((Container) resource).newFolder(name).then(new Operation<Folder>() {

        @Override
        public void apply(Folder folder) throws OperationException {
            eventBus.fireEvent(new RevealResourceEvent(folder));
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            dialogFactory.createMessageDialog("Error", error.getMessage(), null).show();
        }
    });
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Folder(org.eclipse.che.ide.api.resources.Folder) RevealResourceEvent(org.eclipse.che.ide.resources.reveal.RevealResourceEvent) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 38 with Container

use of org.eclipse.che.ide.api.resources.Container in project che by eclipse.

the class NewXFilePresenter method createSourceFile.

private void createSourceFile(final String nameWithoutExtension, final String content) {
    Resource resource = appContext.getResource();
    if (!(resource instanceof Container)) {
        final Container parent = resource.getParent();
        checkState(parent != null, "Parent should be a container");
        resource = parent;
    }
    createFile(resource.getLocation().toString(), nameWithoutExtension, content);
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Aggregations

Container (org.eclipse.che.ide.api.resources.Container)38 Resource (org.eclipse.che.ide.api.resources.Resource)32 Project (org.eclipse.che.ide.api.resources.Project)13 Operation (org.eclipse.che.api.promises.client.Operation)7 OperationException (org.eclipse.che.api.promises.client.OperationException)7 Optional (com.google.common.base.Optional)5 PromiseError (org.eclipse.che.api.promises.client.PromiseError)5 File (org.eclipse.che.ide.api.resources.File)5 Path (org.eclipse.che.ide.resource.Path)5 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)4 SVGResource (org.vectomatic.dom.svg.ui.SVGResource)4 List (java.util.List)3 FunctionException (org.eclipse.che.api.promises.client.FunctionException)3 Folder (org.eclipse.che.ide.api.resources.Folder)3 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)3 RevealResourceEvent (org.eclipse.che.ide.resources.reveal.RevealResourceEvent)3 ArrayList (java.util.ArrayList)2 Collections.singletonList (java.util.Collections.singletonList)2 Promise (org.eclipse.che.api.promises.client.Promise)2 Node (org.eclipse.che.ide.api.data.tree.Node)2