Search in sources :

Example 1 with FLOAT_MODE

use of org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE 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 2 with FLOAT_MODE

use of org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE 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);
    });
}
Also used : 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) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Resource(org.eclipse.che.ide.api.resources.Resource)

Aggregations

Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 Inject (com.google.inject.Inject)2 Singleton (com.google.inject.Singleton)2 List (java.util.List)2 FontAwesome (org.eclipse.che.ide.FontAwesome)2 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)2 AppContext (org.eclipse.che.ide.api.app.AppContext)2 GitServiceClient (org.eclipse.che.ide.api.git.GitServiceClient)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 NotificationManager (org.eclipse.che.ide.api.notification.NotificationManager)2 FLOAT_MODE (org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE)2 FAIL (org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL)2 Resource (org.eclipse.che.ide.api.resources.Resource)2 GitLocalizationConstant (org.eclipse.che.ide.ext.git.client.GitLocalizationConstant)2 AddToIndexPresenter (org.eclipse.che.ide.ext.git.client.add.AddToIndexPresenter)2 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)2 GitOutputConsoleFactory (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsoleFactory)2 ProcessesPanelPresenter (org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter)2 Path (org.eclipse.che.ide.resource.Path)2