use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ResetFilesPresenter method onResetClicked.
/** {@inheritDoc} */
@Override
public void onResetClicked() {
Path[] paths = new Path[0];
for (IndexFile file : indexedFiles) {
if (!file.isIndexed()) {
paths = add(paths, Path.valueOf(file.getPath()));
}
}
final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
if (paths.length == 0) {
view.close();
console.print(constant.nothingToReset());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.nothingToReset());
return;
}
view.close();
service.reset(appContext.getDevMachine(), project.getLocation(), "HEAD", ResetType.MIXED, paths).then(new Operation<Void>() {
@Override
public void apply(Void ignored) throws OperationException {
console.print(constant.resetFilesSuccessfully());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.resetFilesSuccessfully());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
String errorMassage = error.getMessage() != null ? error.getMessage() : constant.resetFilesFailed();
console.printError(errorMassage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(errorMassage);
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class NewJavaSourceFilePresenter method getPackageQualifier.
private String getPackageQualifier(String packageFragment) {
final Optional<Resource> srcFolder = parent.getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent() && isNullOrEmpty(packageFragment)) {
return "\n";
}
final Path path = parent.getLocation().removeFirstSegments(srcFolder.get().getLocation().segmentCount());
String packageFQN = path.toString().replace('/', '.');
if (!packageFragment.isEmpty()) {
packageFQN = packageFQN.isEmpty() ? packageFragment : packageFQN + '.' + packageFragment;
}
if (!packageFQN.isEmpty()) {
return "package " + packageFQN + ";\n\n";
} else {
return "\n";
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class JavaCommandPagePresenter method setMainClass.
public void setMainClass(Resource resource, String fqn) {
if (editedCommandModel.getMainClass().equals(resource.getLocation().toString())) {
return;
}
final Optional<Project> project = resource.getRelatedProject();
if (!project.isPresent()) {
return;
}
final Path relPath = resource.getLocation().removeFirstSegments(project.get().getLocation().segmentCount());
view.setMainClass(relPath.toString());
String commandLine = editedCommandModel.getCommandLine();
commandLine = commandLine.replace(editedCommandModel.getMainClass(), relPath.toString());
commandLine = commandLine.replace(' ' + editedCommandModel.getMainClassFQN(), ' ' + fqn);
editedCommandModel.setMainClass(view.getMainClass());
editedCommandModel.setCommandLine(commandLine);
editedCommand.setCommandLine(editedCommandModel.toCommandLine());
listener.onDirtyStateChanged();
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class BreakpointManagerImpl method registerEventHandlers.
/**
* Registers events handlers.
*/
private void registerEventHandlers(EventBus eventBus) {
eventBus.addHandler(WorkspaceReadyEvent.getType(), new WorkspaceReadyEvent.WorkspaceReadyHandler() {
@Override
public void onWorkspaceReady(WorkspaceReadyEvent event) {
restoreBreakpoints();
}
});
eventBus.addHandler(EditorOpenedEvent.TYPE, new EditorOpenedEventHandler() {
@Override
public void onEditorOpened(EditorOpenedEvent event) {
onOpenEditor(event.getFile().getLocation().toString(), event.getEditor());
}
});
eventBus.addHandler(DeleteProjectEvent.TYPE, new DeleteProjectHandler() {
@Override
public void onProjectDeleted(DeleteProjectEvent event) {
if (breakpoints.isEmpty()) {
return;
}
ProjectConfigDto config = event.getProjectConfig();
String path = config.getPath() + "/";
deleteBreakpoints(getBreakpointPaths(path));
}
});
eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {
@Override
public void onResourceChanged(ResourceChangedEvent event) {
if (event.getDelta().getKind() == ResourceDelta.REMOVED) {
if (breakpoints.isEmpty()) {
return;
}
final Resource resource = event.getDelta().getResource();
Path path = resource.getLocation();
if (resource.isFolder()) {
path.addTrailingSeparator();
deleteBreakpoints(getBreakpointPaths(path.toString()));
} else if (resource.isFile()) {
deleteBreakpoints(Collections.singleton(path.toString()));
}
}
}
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorContentSynchronizerImpl method unTrackEditor.
/**
* Stops to track given editor.
*
* @param editor
* editor to stop tracking
*/
@Override
public void unTrackEditor(EditorPartPresenter editor) {
Path path = editor.getEditorInput().getFile().getLocation();
EditorGroupSynchronization group = editorGroups.get(path);
if (group == null) {
return;
}
group.removeEditor(editor);
if (group.getSynchronizedEditors().isEmpty()) {
group.unInstall();
editorGroups.remove(path);
}
}
Aggregations