use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class MergePresenter method merge.
/**
* Prepares to merging and opens Merge dialog.
*/
public void merge() {
view.enableMergeButton(false);
view.sourceCheckBox().setValue(false);
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length == 1);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
mergeTarget = response.getItems().get(0);
view.targetTextBox().setValue(mergeTarget.getRelativeURL());
String repositoryRoot = mergeTarget.getRepositoryRoot();
service.info(project.getLocation(), repositoryRoot, "HEAD", true).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (!response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
sourceURL = response.getItems().get(0).getURL();
SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0));
List<Node> children = new ArrayList<>();
if (response.getItems().size() > 1) {
for (int i = 1; i < response.getItems().size(); i++) {
SubversionItem item = response.getItems().get(i);
if (!"file".equals(item.getNodeKind())) {
children.add(new SubversionItemNode(item));
}
}
}
subversionTreeNode.setChildren(children);
view.setRootNode(subversionTreeNode);
view.show();
validateSourceURL();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class MovePresenter method onMoveClicked.
/** {@inheritDoc} */
@Override
public void onMoveClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Path source = getSource();
final String comment = view.isURLSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(locale.moveNotificationStarted(source.toString()));
return service.move(project.getLocation(), source, getTarget(), comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
notification.setTitle(locale.moveNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notification.setTitle(locale.moveNotificationFailed());
notification.setStatus(FAIL);
}
});
view.onClose();
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class MovePresenter method showMove.
public void showMove() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
source = resources[0];
this.project = project;
view.onShow(true);
view.setProject(project);
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class PropertyEditorPresenter method onOkClicked.
/**
* {@inheritDoc}
*/
@Override
public void onOkClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
view.onClose();
if (view.isEditPropertySelected()) {
editProperty(project);
} else if (view.isDeletePropertySelected()) {
deleteProperty(project);
}
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class PropertyEditorPresenter method obtainExistingPropertiesForPath.
@Override
public void obtainExistingPropertiesForPath() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
service.propertyList(project.getLocation(), toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
List<String> properties = new ArrayList<String>();
for (String property : response.getOutput()) {
properties.add(property.trim());
}
view.setExistingPropertiesForPath(properties);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE));
}
});
}
Aggregations