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);
}
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);
}
}
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();
}
}
}
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());
}
}
}
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("");
}
}
Aggregations