Search in sources :

Example 16 with Action

use of org.eclipse.che.ide.api.action.Action in project che by eclipse.

the class TerminalPresenter method connectToTerminalWebSocket.

private void connectToTerminalWebSocket(@NotNull String wsUrl) {
    countRetry--;
    socket = WebSocket.create(wsUrl);
    socket.setOnMessageHandler(new MessageReceivedHandler() {

        @Override
        public void onMessageReceived(MessageReceivedEvent event) {
            terminal.write(event.getMessage());
        }
    });
    socket.setOnCloseHandler(new ConnectionClosedHandler() {

        @Override
        public void onClose(WebSocketClosedEvent event) {
            if (CLOSE_NORMAL == event.getCode()) {
                connected = false;
                terminalStateListener.onExit();
            }
        }
    });
    socket.setOnOpenHandler(new ConnectionOpenedHandler() {

        @Override
        public void onOpen() {
            JavaScriptObject terminalJso = moduleHolder.getModule("Xterm");
            // if terminal was created programmatically then we don't set focus on it
            TerminalOptionsJso terminalOptionsJso = TerminalOptionsJso.createDefault();
            if (source instanceof AddTerminalClickHandler || source instanceof Action) {
                terminalOptionsJso.withFocusOnOpen(true);
            }
            terminal = TerminalJso.create(terminalJso, terminalOptionsJso);
            connected = true;
            view.openTerminal(terminal);
            terminal.on(DATA_EVENT_NAME, new Operation<String>() {

                @Override
                public void apply(String arg) throws OperationException {
                    Jso jso = Jso.create();
                    jso.addField("type", "data");
                    jso.addField("data", arg);
                    socket.send(jso.serialize());
                }
            });
        }
    });
    socket.setOnErrorHandler(new ConnectionErrorHandler() {

        @Override
        public void onError() {
            connected = false;
            if (countRetry == 0) {
                view.showErrorMessage(locale.terminalErrorStart());
                notificationManager.notify(locale.connectionFailedWithTerminal(), locale.terminalErrorConnection(), FAIL, FLOAT_MODE);
            } else {
                reconnect();
            }
        }
    });
}
Also used : ConnectionOpenedHandler(org.eclipse.che.ide.websocket.events.ConnectionOpenedHandler) Action(org.eclipse.che.ide.api.action.Action) ConnectionErrorHandler(org.eclipse.che.ide.websocket.events.ConnectionErrorHandler) MessageReceivedHandler(org.eclipse.che.ide.websocket.events.MessageReceivedHandler) Jso(org.eclipse.che.ide.collections.Jso) Operation(org.eclipse.che.api.promises.client.Operation) MessageReceivedEvent(org.eclipse.che.ide.websocket.events.MessageReceivedEvent) WebSocketClosedEvent(org.eclipse.che.ide.websocket.events.WebSocketClosedEvent) AddTerminalClickHandler(org.eclipse.che.ide.extension.machine.client.processes.AddTerminalClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ConnectionClosedHandler(org.eclipse.che.ide.websocket.events.ConnectionClosedHandler)

Example 17 with Action

use of org.eclipse.che.ide.api.action.Action in project che by eclipse.

the class StatusPanelGroupViewImpl method expandActionGroup.

private void expandActionGroup(List<Action> newVisibleActions, ActionManager actionManager, ActionGroup mainActionGroup) {
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent e = new ActionEvent(presentation, actionManager, perspectiveManager.get());
        action.update(e);
        if (presentation.isVisible()) {
            // add only visible items
            newVisibleActions.add(action);
        }
        if (action2barItem.containsKey(action)) {
            action2barItem.get(action).update();
        }
    }
}
Also used : CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 18 with Action

use of org.eclipse.che.ide.api.action.Action in project che by eclipse.

the class ActionManagerImpl method performAction.

@Override
public void performAction(String actionId, Map<String, String> parameters) {
    final Action action;
    if (actionId != null && (action = getAction(actionId)) != null) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent actionEvent = new ActionEvent(presentation, this, managerProvider.get(), parameters);
        action.update(actionEvent);
        if (presentation.isEnabled() && presentation.isVisible()) {
            action.actionPerformed(actionEvent);
        }
    }
}
Also used : PromisableAction(org.eclipse.che.ide.api.action.PromisableAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 19 with Action

use of org.eclipse.che.ide.api.action.Action in project che by eclipse.

the class EditorPartStackPresenterTest method onActionClickedTest.

@Test
public void onActionClickedTest() {
    Action action = mock(Action.class);
    when(editorPaneActionMenuItem.getData()).thenReturn(action);
    presenter.addPart(partPresenter1);
    presenter.setActivePart(partPresenter1);
    presenter.paneMenuActionItemHandler.onItemClicked(editorPaneActionMenuItem);
    verify(presentation).putClientProperty(eq(CURRENT_PANE_PROP), eq(presenter));
    verify(presentation).putClientProperty(eq(CURRENT_TAB_PROP), eq(editorTab1));
    verify(presentation).putClientProperty(eq(CURRENT_FILE_PROP), eq(file1));
}
Also used : CloseAllTabsPaneAction(org.eclipse.che.ide.part.editor.actions.CloseAllTabsPaneAction) ClosePaneAction(org.eclipse.che.ide.part.editor.actions.ClosePaneAction) SplitHorizontallyAction(org.eclipse.che.ide.part.editor.actions.SplitHorizontallyAction) SplitVerticallyAction(org.eclipse.che.ide.part.editor.actions.SplitVerticallyAction) Action(org.eclipse.che.ide.api.action.Action) Test(org.junit.Test)

Example 20 with Action

use of org.eclipse.che.ide.api.action.Action in project che by eclipse.

the class DropDownWidgetImpl method updateActions.

/**
     * Refresh the list of visible actions.
     */
private void updateActions() {
    actions.removeAll();
    ActionGroup mainActionGroup = (ActionGroup) actionManager.getAction(actionGroupId);
    if (mainActionGroup == null) {
        return;
    }
    Action[] children = mainActionGroup.getChildren(null);
    for (Action action : children) {
        Presentation presentation = presentationFactory.getPresentation(action);
        ActionEvent e = new ActionEvent(presentation, actionManager, managerProvider.get());
        action.update(e);
        if (presentation.isVisible()) {
            actions.add(action);
        }
    }
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Aggregations

Action (org.eclipse.che.ide.api.action.Action)32 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)10 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)10 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)10 Presentation (org.eclipse.che.ide.api.action.Presentation)10 Separator (org.eclipse.che.ide.api.action.Separator)5 ToggleAction (org.eclipse.che.ide.api.action.ToggleAction)5 ArrayList (java.util.ArrayList)4 CustomComponentAction (org.eclipse.che.ide.api.action.CustomComponentAction)4 CreateProjectAction (org.eclipse.che.ide.actions.CreateProjectAction)2 ImportProjectAction (org.eclipse.che.ide.actions.ImportProjectAction)2 PromisableAction (org.eclipse.che.ide.api.action.PromisableAction)2 SplitHorizontallyAction (org.eclipse.che.ide.part.editor.actions.SplitHorizontallyAction)2 SplitVerticallyAction (org.eclipse.che.ide.part.editor.actions.SplitVerticallyAction)2 Test (org.junit.Test)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 DivElement (com.google.gwt.dom.client.DivElement)1 Element (com.google.gwt.dom.client.Element)1 RegExp (com.google.gwt.regexp.shared.RegExp)1