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