use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class CompareWithRevisionAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Project project = appContext.getRootProject();
final Resource resource = appContext.getResource();
checkState(project != null, "Null project occurred");
checkState(resource instanceof File, "Invalid file occurred");
presenter.showRevisions(project, (File) resource);
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class OrionEditorPresenter method onResourceCreated.
private void onResourceCreated(ResourceDelta delta) {
if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) {
return;
}
final Resource resource = delta.getResource();
final Path movedFrom = delta.getFromPath();
//file moved directly
if (document.getFile().getLocation().equals(movedFrom)) {
deletedFilesController.add(movedFrom.toString());
document.setFile((File) resource);
input.setFile((File) resource);
updateContent();
} else if (movedFrom.isPrefixOf(document.getFile().getLocation())) {
//directory where file moved
final Path relPath = document.getFile().getLocation().removeFirstSegments(movedFrom.segmentCount());
final Path newPath = delta.getToPath().append(relPath);
appContext.getWorkspaceRoot().getFile(newPath).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
final Path location = document.getFile().getLocation();
deletedFilesController.add(location.toString());
generalEventBus.fireEvent(newFileTrackingStartEvent(file.get().getLocation().toString()));
document.setFile(file.get());
input.setFile(file.get());
updateTabReference(file.get(), location);
updateContent();
}
}
});
}
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class PlainJavaPagePresenterTest method selectedNodeShouldBeWithRelativePath.
@Test
public void selectedNodeShouldBeWithRelativePath() throws Exception {
when(view.getLibraryFolder()).thenReturn("lib1, lib2");
when(view.getSourceFolder()).thenReturn("src1, src2");
List<Node> selectedNodes = new ArrayList<>();
ResourceNode selectedNode1 = mock(ResourceNode.class);
ResourceNode selectedNode2 = mock(ResourceNode.class);
Resource resource1 = mock(Resource.class);
Resource resource2 = mock(Resource.class);
selectedNodes.add(selectedNode1);
selectedNodes.add(selectedNode2);
when(selectedNode1.getData()).thenReturn(resource1);
when(resource1.getLocation()).thenReturn(Path.valueOf("projectName/folder1/folder2"));
when(selectedNode2.getData()).thenReturn(resource2);
when(resource2.getLocation()).thenReturn(Path.valueOf("projectName/folder"));
when(dataObject.getName()).thenReturn("projectName");
page.setUpdateDelegate(updateDelegate);
page.init(dataObject);
page.onNodeSelected(selectedNodes);
verify(view).setLibraryFolder(eq("folder1/folder2, folder"));
}
use of org.eclipse.che.ide.api.resources.Resource 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.Resource in project che by eclipse.
the class EmptyEditorsPanel method onResourceChanged.
@Override
public void onResourceChanged(ResourceChangedEvent event) {
final ResourceDelta delta = event.getDelta();
final Resource resource = delta.getResource();
if (!(resource.getResourceType() == PROJECT && resource.getLocation().segmentCount() == 1)) {
return;
}
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
updateOnProjectsChange();
}
});
}
Aggregations