Search in sources :

Example 11 with IsWidget

use of com.google.gwt.user.client.ui.IsWidget in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldAddCommand.

@Test
public void shouldAddCommand() throws Exception {
    ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    List<ProcessTreeNode> children = new ArrayList<>();
    children.add(machineNode);
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    verify(view, never()).hideProcessOutput(anyString());
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(view).addProcessNode(anyObject());
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).setProcessesData(anyObject());
    verify(view).getNodeById(anyString());
    verify(view).setStopButtonVisibility(anyString(), anyBoolean());
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ArrayList(java.util.ArrayList) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Test(org.junit.Test)

Example 12 with IsWidget

use of com.google.gwt.user.client.ui.IsWidget in project che by eclipse.

the class TargetsPresenter method onTargetSelected.

@Override
public void onTargetSelected(final Target target) {
    selectedTarget = target;
    if (target == null) {
        view.showHintPanel();
        return;
    }
    final CategoryPage page = categoryPageRegistry.getCategoryPage(target.getCategory());
    if (page == null) {
        view.showHintPanel();
        return;
    }
    page.go(new AcceptsOneWidget() {

        @Override
        public void setWidget(IsWidget widget) {
            view.setPropertiesPanel(widget.asWidget());
            page.setCurrentSelection(target);
        }
    });
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget)

Example 13 with IsWidget

use of com.google.gwt.user.client.ui.IsWidget in project che by eclipse.

the class ProcessesPanelPresenter method addOutputConsole.

private void addOutputConsole(final String id, final ProcessTreeNode processNode, final OutputConsole outputConsole, final boolean machineConsole) {
    consoles.put(id, outputConsole);
    consoleCommands.put(outputConsole, id);
    outputConsole.go(new AcceptsOneWidget() {

        @Override
        public void setWidget(final IsWidget widget) {
            view.addProcessNode(processNode);
            view.addWidget(id, outputConsole.getTitle(), outputConsole.getTitleIcon(), widget, machineConsole);
            if (!MACHINE_NODE.equals(processNode.getType())) {
                ProcessTreeNode node = view.getNodeById(id);
                view.selectNode(node);
                notifyTreeNodeSelected(node);
            }
        }
    });
    outputConsole.addActionDelegate(this);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget)

Example 14 with IsWidget

use of com.google.gwt.user.client.ui.IsWidget in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldReplaceCommandOutput.

@Test
public void shouldReplaceCommandOutput() throws Exception {
    MachineEntity machine = mock(MachineEntity.class);
    when(machine.getId()).thenReturn(MACHINE_ID);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    List<ProcessTreeNode> children = new ArrayList<>();
    ProcessTreeNode commandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
    children.add(commandNode);
    ProcessTreeNode machineNode = new ProcessTreeNode(MACHINE_NODE, null, machine, null, children);
    children.add(machineNode);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    String commandId = commandNode.getId();
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    presenter.consoles.put(commandId, outputConsole);
    when(outputConsole.isFinished()).thenReturn(true);
    when(outputConsole.getTitle()).thenReturn(PROCESS_NAME);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(view).hideProcessOutput(eq(commandId));
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).getNodeById(anyString());
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 15 with IsWidget

use of com.google.gwt.user.client.ui.IsWidget in project gwt-test-utils by gwt-test-utils.

the class UiBinderBeanUtils method populateObject.

/**
     * @param o
     * @param properties
     * @see BeanUtilsBean#populate(Object, Map)
     */
public static void populateObject(Object o, Map<String, Object> properties) {
    try {
        Map<String, Object> filteredProperties = new HashMap<String, Object>();
        for (String key : properties.keySet()) {
            if (PropertyUtils.isWriteable(o, key)) {
                filteredProperties.put(key, properties.get(key));
            }
        }
        UIBINDER_BEANUTILS.populate(o, filteredProperties);
    } catch (Exception e) {
        throw new ReflectionException("UiBinder error while setting properties for '" + o.getClass().getSimpleName() + "'", e);
    }
    // handle specifics
    String[] styles = (String[]) properties.get("addStyleNames");
    if (styles != null) {
        for (String style : styles) {
            if (o instanceof IsWidget) {
                ((IsWidget) o).asWidget().addStyleName(style);
            } else if (o instanceof UIObject) {
                ((UIObject) o).addStyleName(style);
            }
        }
    }
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ReflectionException(com.googlecode.gwt.test.exceptions.ReflectionException) UIObject(com.google.gwt.user.client.ui.UIObject) HashMap(java.util.HashMap) UIObject(com.google.gwt.user.client.ui.UIObject) ReflectionException(com.googlecode.gwt.test.exceptions.ReflectionException)

Aggregations

IsWidget (com.google.gwt.user.client.ui.IsWidget)15 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)4 AcceptsOneWidget (com.google.gwt.user.client.ui.AcceptsOneWidget)3 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)3 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)2 UIObject (com.google.gwt.user.client.ui.UIObject)1 ReflectionException (com.googlecode.gwt.test.exceptions.ReflectionException)1 HashMap (java.util.HashMap)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)1 OutputConsole (org.eclipse.che.ide.api.outputconsole.OutputConsole)1 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)1 Matchers.anyString (org.mockito.Matchers.anyString)1