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());
}
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);
}
});
}
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);
}
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());
}
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);
}
}
}
}
Aggregations