use of org.eclipse.che.ide.resources.tree.ResourceNode 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());
}
}
}
use of org.eclipse.che.ide.resources.tree.ResourceNode in project che by eclipse.
the class ExplorerCurrentProjectTypeMacro method expand.
/** {@inheritDoc} */
@Override
public Promise<String> expand() {
List<Node> selectedNodes = projectExplorer.getTree().getSelectionModel().getSelectedNodes();
if (selectedNodes.isEmpty() || selectedNodes.size() > 1) {
return promises.resolve("");
}
final Node node = selectedNodes.get(0);
if (node instanceof ResourceNode) {
final Optional<Project> project = ((ResourceNode) node).getData().getRelatedProject();
if (!project.isPresent()) {
return promises.resolve("");
}
return promises.resolve(project.get().getType());
}
return promises.resolve("");
}
use of org.eclipse.che.ide.resources.tree.ResourceNode in project che by eclipse.
the class SelectNodeViewImpl method acceptButtonClicked.
private void acceptButtonClicked() {
List<Node> nodes = tree.getSelectionModel().getSelectedNodes();
if (nodes.isEmpty()) {
return;
}
Node selectedNode = nodes.get(0);
if (selectedNode instanceof ResourceNode) {
final Resource resource = ((ResourceNode) selectedNode).getData();
delegate.setSelectedNode(resource, resolveFQN(resource));
}
hide();
}
use of org.eclipse.che.ide.resources.tree.ResourceNode in project che by eclipse.
the class FindResultPresenter method onResourceChanged.
@Override
@SuppressWarnings("unchecked")
public void onResourceChanged(ResourceChangedEvent event) {
final ResourceDelta delta = event.getDelta();
final Tree tree = view.getTree();
if (delta.getKind() == REMOVED) {
for (Node node : tree.getNodeStorage().getAll()) {
if (node instanceof ResourceNode && ((ResourceNode) node).getData().getLocation().equals(delta.getResource().getLocation())) {
tree.getNodeStorage().remove(node);
return;
}
}
}
}
use of org.eclipse.che.ide.resources.tree.ResourceNode in project che by eclipse.
the class SelectPathViewImpl method acceptButtonClicked.
private void acceptButtonClicked() {
List<Node> nodes = tree.getSelectionModel().getSelectedNodes();
if (nodes.isEmpty()) {
return;
}
Node selectedNode = nodes.get(0);
if (selectedNode instanceof ResourceNode) {
delegate.setSelectedPath(((ResourceNode) selectedNode).getData().getLocation().toString());
}
hide();
}
Aggregations