Search in sources :

Example 66 with Resource

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();
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 67 with Resource

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();
}
Also used : Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 68 with Resource

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)");
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) DiffType(org.eclipse.che.api.git.shared.DiffType)

Example 69 with Resource

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);
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Inject(com.google.inject.Inject) GitServiceClient(org.eclipse.che.ide.api.git.GitServiceClient) FAIL(org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL) Resource(org.eclipse.che.ide.api.resources.Resource) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) AddToIndexPresenter(org.eclipse.che.ide.ext.git.client.add.AddToIndexPresenter) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) FontAwesome(org.eclipse.che.ide.FontAwesome) FLOAT_MODE(org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE) AppContext(org.eclipse.che.ide.api.app.AppContext) GitLocalizationConstant(org.eclipse.che.ide.ext.git.client.GitLocalizationConstant) GitOutputConsoleFactory(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsoleFactory) NotificationManager(org.eclipse.che.ide.api.notification.NotificationManager) Singleton(com.google.inject.Singleton) ProcessesPanelPresenter(org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter) Path(org.eclipse.che.ide.resource.Path) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 70 with Resource

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);
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource)

Aggregations

Resource (org.eclipse.che.ide.api.resources.Resource)146 Project (org.eclipse.che.ide.api.resources.Project)73 OperationException (org.eclipse.che.api.promises.client.OperationException)48 Operation (org.eclipse.che.api.promises.client.Operation)46 PromiseError (org.eclipse.che.api.promises.client.PromiseError)40 Container (org.eclipse.che.ide.api.resources.Container)32 Path (org.eclipse.che.ide.resource.Path)30 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)22 Optional (com.google.common.base.Optional)15 File (org.eclipse.che.ide.api.resources.File)14 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)14 List (java.util.List)13 Promise (org.eclipse.che.api.promises.client.Promise)13 FunctionException (org.eclipse.che.api.promises.client.FunctionException)12 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 ArrayList (java.util.ArrayList)11 Function (org.eclipse.che.api.promises.client.Function)9 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)9 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)9 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)8