use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class RemoveFromIndexPresenter method onRemoveClicked.
/** {@inheritDoc} */
@Override
public void onRemoveClicked() {
final GitOutputConsole console = gitOutputConsoleFactory.create(REMOVE_FROM_INDEX_COMMAND_NAME);
final Resource[] resources = appContext.getResources();
checkState(!isNullOrEmpty(resources));
service.remove(appContext.getDevMachine(), project.getLocation(), toRelativePaths(resources), view.isRemoved()).then(new Operation<Void>() {
@Override
public void apply(Void ignored) throws OperationException {
console.print(constant.removeFilesSuccessfull());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.removeFilesSuccessfull());
project.synchronize();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), console);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
}
});
view.close();
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class AddToIndexAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource[] resources = appContext.getResources();
checkState(resources != null);
final DevMachine devMachine = appContext.getDevMachine();
final GitOutputConsole console = gitOutputConsoleFactory.create(constant.addToIndexCommandName());
consolesPanelPresenter.addCommandOutput(devMachine.getId(), console);
service.getStatus(devMachine, appContext.getRootProject().getLocation()).then(status -> {
if (containsInSelected(status.getUntracked())) {
presenter.showDialog();
} else if (containsInSelected(status.getModified()) || containsInSelected(status.getMissing())) {
addToIndex(console);
} else {
String message = resources.length > 1 ? constant.nothingAddToIndexMultiSelect() : constant.nothingAddToIndex();
console.print(message);
notificationManager.notify(message);
}
}).catchError(error -> {
console.printError(constant.statusFailed());
notificationManager.notify(constant.statusFailed(), FAIL, FLOAT_MODE);
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class CompareWithBranchAction 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");
presenter.showBranches(project, resource);
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class CompareWithLatestAction 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(project.getLocation().isPrefixOf(resource.getLocation()), "Given selected item is not descendant of given project");
final String selectedItemPath = resource.getLocation().removeFirstSegments(project.getLocation().segmentCount()).removeTrailingSeparator().toString();
service.diff(appContext.getDevMachine(), project.getLocation(), selectedItemPath.isEmpty() ? null : singletonList(selectedItemPath), NAME_STATUS, false, 0, REVISION, false).then(new Operation<String>() {
@Override
public void apply(String diff) throws OperationException {
if (diff.isEmpty()) {
dialogFactory.createMessageDialog(locale.compareMessageIdenticalContentTitle(), locale.compareMessageIdenticalContentText(), null).show();
} else {
final String[] changedFiles = diff.split("\n");
if (changedFiles.length == 1) {
project.getFile(changedFiles[0].substring(2)).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
comparePresenter.showCompareWithLatest(file.get(), defineStatus(changedFiles[0].substring(0, 1)), REVISION);
}
}
});
} else {
Map<String, Status> items = new HashMap<>();
for (String item : changedFiles) {
items.put(item.substring(2, item.length()), defineStatus(item.substring(0, 1)));
}
changedListPresenter.show(items, REVISION, null, project);
}
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(locale.diffFailed(), FAIL, NOT_EMERGE_MODE);
}
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class EditorContentSynchronizerImplTest method shouldUpdatePathForGroupWhenFileLocationIsChanged.
@Test
public void shouldUpdatePathForGroupWhenFileLocationIsChanged() {
Resource resource = mock(Resource.class);
ResourceDelta delta = mock(ResourceDelta.class);
ResourceChangedEvent resourceChangedEvent = new ResourceChangedEvent(delta);
Path fromPath = new Path(FILE_PATH);
Path toPath = new Path("testProject/src/main/java/org/eclipse/che/examples/changedFile");
EditorPartPresenter openedEditor1 = mock(EditorPartPresenter.class);
when(openedEditor1.getEditorInput()).thenReturn(editorInput);
when(delta.getKind()).thenReturn(ResourceDelta.ADDED);
when(delta.getFlags()).thenReturn(5632);
when(delta.getFromPath()).thenReturn(fromPath);
when(delta.getToPath()).thenReturn(toPath);
when(delta.getResource()).thenReturn(resource);
when(resource.isFile()).thenReturn(true);
editorContentSynchronizer.trackEditor(openedEditor1);
editorContentSynchronizer.onResourceChanged(resourceChangedEvent);
final EditorGroupSynchronization oldGroup = editorContentSynchronizer.editorGroups.get(fromPath);
final EditorGroupSynchronization newGroup = editorContentSynchronizer.editorGroups.get(toPath);
assertNull(oldGroup);
assertNotNull(newGroup);
}
Aggregations