Search in sources :

Example 1 with Container

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

the class FullTextSearchAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Resource[] resources = appContext.getResources();
    final Path searchPath;
    if (resources == null || resources.length == 0 || resources.length > 1) {
        searchPath = Path.ROOT;
    } else {
        if (resources[0] instanceof Container) {
            searchPath = resources[0].getLocation();
        } else {
            final Container parent = resources[0].getParent();
            searchPath = parent != null ? parent.getLocation() : Path.ROOT;
        }
    }
    presenter.showDialog(searchPath);
}
Also used : Path(org.eclipse.che.ide.resource.Path) Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 2 with Container

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

the class ProjectConfigurationAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && resources.length == 1);
    final Resource resource = resources[0];
    checkState(resource instanceof Container);
    if (resource.getResourceType() == PROJECT) {
        final MutableProjectConfig config = new MutableProjectConfig((Project) resource);
        projectWizard.show(config);
    }
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 3 with Container

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

the class RefreshPathAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final Resource[] resources = appContext.getResources();
    if (resources == null || resources.length != 1) {
        return;
    }
    final Resource resource = resources[0];
    if (resource instanceof Container) {
        ((Container) resource).synchronize();
    } else {
        final Container parent = resource.getParent();
        if (parent != null) {
            parent.synchronize();
        }
    }
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 4 with Container

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

the class ProjectExplorerPresenter method onResourceChanged.

@Override
@SuppressWarnings("unchecked")
public void onResourceChanged(ResourceChangedEvent event) {
    final Tree tree = view.getTree();
    final ResourceDelta delta = event.getDelta();
    final Resource resource = delta.getResource();
    final NodeSettings nodeSettings = settingsProvider.getSettings();
    // process root projects, they have only one segment in path
    if (resource.getLocation().segmentCount() == 1) {
        if (delta.getKind() == ADDED) {
            if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) != 0) {
                Node node = getNode(delta.getFromPath());
                if (node != null) {
                    boolean expanded = tree.isExpanded(node);
                    tree.getNodeStorage().remove(node);
                    node = nodeFactory.newContainerNode((Container) resource, nodeSettings);
                    tree.getNodeStorage().add(node);
                    if (expanded) {
                        tree.setExpanded(node, true);
                    }
                }
            } else if (getNode(resource.getLocation()) == null) {
                tree.getNodeStorage().add(nodeFactory.newContainerNode((Container) resource, nodeSettings));
            }
        } else if (delta.getKind() == REMOVED) {
            Node node = getNode(resource.getLocation());
            if (node != null) {
                tree.getNodeStorage().remove(node);
            }
        } else if (delta.getKind() == UPDATED) {
            for (Node node : tree.getNodeStorage().getAll()) {
                if (node instanceof ResourceNode && ((ResourceNode) node).getData().getLocation().equals(delta.getResource().getLocation())) {
                    final String oldId = tree.getNodeStorage().getKeyProvider().getKey(node);
                    ((ResourceNode) node).setData(delta.getResource());
                    tree.getNodeStorage().reIndexNode(oldId, node);
                    tree.refresh(node);
                    updateTask.submit(delta.getResource().getLocation());
                }
            }
        }
    } else {
        if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) != 0) {
            final Node node = getNode(delta.getFromPath());
            if (node != null && tree.isExpanded(node)) {
                expandQueue.add(delta.getToPath());
            }
        }
        updateTask.submit(resource.getLocation());
        if (delta.getFromPath() != null) {
            updateTask.submit(delta.getFromPath());
        }
    }
}
Also used : NodeSettings(org.eclipse.che.ide.api.data.tree.settings.NodeSettings) Container(org.eclipse.che.ide.api.resources.Container) ResourceDelta(org.eclipse.che.ide.api.resources.ResourceDelta) Node(org.eclipse.che.ide.api.data.tree.Node) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode) SyntheticNode(org.eclipse.che.ide.project.node.SyntheticNode) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) Resource(org.eclipse.che.ide.api.resources.Resource) Tree(org.eclipse.che.ide.ui.smartTree.Tree) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode)

Example 5 with Container

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

the class CurrentClassFQN_Macro method expand.

@Override
public Promise<String> expand() {
    final Resource[] resources = appContext.getResources();
    if (resources == null || resources.length > 1) {
        return Promises.resolve("");
    }
    final Resource resource = resources[0];
    final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
    if (resource.getResourceType() == FILE && isJavaFile(resource) && srcFolder.isPresent()) {
        return Promises.resolve(JavaUtil.resolveFQN((Container) srcFolder.get(), resource));
    } else {
        return Promises.resolve("");
    }
}
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