use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class AddToIndexPresenter method onAddClicked.
/** {@inheritDoc} */
@Override
public void onAddClicked() {
DevMachine devMachine = appContext.getDevMachine();
Resource[] resources = appContext.getResources();
Path projectLocation = appContext.getRootProject().getLocation();
Path[] paths = new Path[resources.length];
for (int i = 0; i < resources.length; i++) {
Path path = resources[i].getLocation().removeFirstSegments(projectLocation.segmentCount());
paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
}
final GitOutputConsole console = gitOutputConsoleFactory.create(constant.addToIndexCommandName());
consolesPanelPresenter.addCommandOutput(devMachine.getId(), console);
service.add(devMachine, projectLocation, view.isUpdated(), paths).then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
console.print(constant.addSuccess());
notificationManager.notify(constant.addSuccess());
view.close();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
console.printError(constant.addFailed());
notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
view.close();
}
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class RemoveFromIndexPresenter method showDialog.
public void showDialog(Project project) {
Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length > 0);
this.project = project;
if (resources.length == 1) {
Resource resource = appContext.getResource();
String selectedItemName = resource.getName();
if (resource instanceof Container) {
view.setMessage(constant.removeFromIndexFolder(selectedItemName));
} else {
view.setMessage(constant.removeFromIndexFile(selectedItemName));
}
} else {
view.setMessage(constant.removeFromIndexAll());
}
view.setRemoved(false);
view.showDialog();
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class HistoryPresenterTest method disarm.
@Override
public void disarm() {
super.disarm();
Resource resource = mock(Resource.class);
when(resource.getLocation()).thenReturn(EMPTY);
when(appContext.getResource()).thenReturn(resource);
when(appContext.getRootProject()).thenReturn(project);
when(service.log(any(DevMachine.class), any(Path.class), any(Path[].class), anyInt(), anyInt(), anyBoolean())).thenReturn(logPromise);
when(service.diff(any(DevMachine.class), any(Path.class), anyList(), any(DiffType.class), anyBoolean(), anyInt(), anyString(), anyString())).thenReturn(stringPromise);
when(service.showFileContent(any(DevMachine.class), any(Path.class), any(Path.class), anyString())).thenReturn(showPromise);
when(stringPromise.then(any(Operation.class))).thenReturn(stringPromise);
when(stringPromise.catchError(any(Operation.class))).thenReturn(stringPromise);
when(logPromise.then(any(Operation.class))).thenReturn(logPromise);
when(logPromise.catchError(any(Operation.class))).thenReturn(logPromise);
when(constant.historyTitle()).thenReturn("title");
when(constant.historyNothingToDisplay()).thenReturn("error message");
when(constant.compareReadOnlyTitle()).thenReturn("(Read only)");
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class AddToIndexAction method addToIndex.
private void addToIndex(final GitOutputConsole console) {
Resource[] resources = appContext.getResources();
Path[] paths = new Path[resources.length];
for (int i = 0; i < resources.length; i++) {
Path path = resources[i].getLocation().removeFirstSegments(1);
paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
}
service.add(appContext.getDevMachine(), appContext.getRootProject().getLocation(), false, paths).then(voidArg -> {
console.print(constant.addSuccess());
notificationManager.notify(constant.addSuccess());
}).catchError(error -> {
console.printError(constant.addFailed());
notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class CompareWithRevisionAction method updateInPerspective.
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
super.updateInPerspective(event);
final Resource resource = appContext.getResource();
event.getPresentation().setEnabled(resource != null && resource.getResourceType() == FILE);
}
Aggregations