public void setWidget(Widget w, boolean delegateCaptionHandling) { if (w != null) { this.widgetType = VaadinWidgetUtils.getWidgetTypeByWidget(w); this.widgetElement = VaadinWidgetUtils.getElementByVaadinWidget(w, this.widgetType); if (this.widgetType.isAddStyle()) { this.widgetElement.addClassName(this.widgetType.getCssStyle()); } else { this.widgetElement.setClassName(this.widgetType.getCssStyle()); } if (delegateCaptionHandling) { getElement().appendChild(label = DOM.createLabel()); } else { getElement().appendChild(label = DOM.createDiv()); } getElement().appendChild(div); } super.setWidget(w); if (w != null) { getContainerElement().appendChild(small); getContainerElement().appendChild(feedback); } }
@Override public List<SelectionInterface> getSelection() { List<SelectionInterface> selection = new ArrayList<EventInterface.SelectionInterface>(); for (int i = 0; i < iTables.getWidgetCount(); i++) { Widget w = iTables.getWidget(i); if (w instanceof TimeGrid) for (SelectionInterface s: ((TimeGrid)w).getSelections()) { SelectionInterface x = new SelectionInterface(); x.setLength(s.getLength()); x.setStartSlot(s.getStartSlot()); for (ResourceInterface r: s.getLocations()) x.addLocation(r); for (Integer d: s.getDays()) x.addDay(iSelectedDates.get(d - iSelectedDates.get(0))); selection.add(x); } } return selection; }
protected Widget getCell(final AttributeInterface feature, final AttributesColumn column, final int idx) { switch (column) { case NAME: return new Label(feature.getName() == null ? "" : feature.getName(), false); case CODE: return new Label(feature.getCode() == null ? "" : feature.getCode(), false); case TYPE: if (feature.getType() == null) return null; else { Label type = new Label(feature.getType().getAbbreviation(), false); type.setTitle(feature.getType().getLabel()); return type; } case PARENT: return new Label(feature.getParentName() == null ? "" : feature.getParentName(), false); case INSTRUCTORS: if (feature.hasInstructors()) return new InstructorsCell(feature); else return null; default: return null; } }
private final Widget buildProcessInstancesGrid() { commonGridSettings(processInstancesGrid); processInstancesGrid.setSelectionType(SelectionStyle.SINGLE); ListGridField nameField = new ListGridField("piid", "Process Instance ID", 120); ListGridField stateField = new ListGridField("state", "Process Instance State"); ListGridField currentField = new ListGridField("current", "Current Steps", 100); ListGridField historyField = new ListGridField("history", "History Steps", 100); processInstancesGrid.setFields(new ListGridField[] { integerField(nameField), leftField(stateField), integerField(currentField), integerField(historyField) }); return processInstancesGrid; }
@Test public void shouldInitModule_withTemplate() { // given Element element = mock(Element.class); SlideshowBean slideshowBean = new SlideshowBean(); List<SlideBean> slides = Lists.newArrayList(); slideshowBean.setSlideBeans(slides); SlideshowPlayerBean slideshowPlayer = new SlideshowPlayerBean(); slideshowPlayer.setSlideshowBean(slideshowBean); when(moduleStructure.getBean()).thenReturn(slideshowPlayer); when(templateInterpreter.isPagerTemplateActivate(slideshowPlayer)).thenReturn(true); // when testObj.initModule(element, moduleSocket, eventsBus); // then verify(presenter).init(slideshowBean, inlineBodyGeneratorSocket); verify(controller).init(slideshowBean.getSlideBeans(), inlineBodyGeneratorSocket); verify(controller).initPager(slides.size()); verify(presenter).setPager(any(Widget.class)); }
private boolean focus(int row, int col) { if (!getRowFormatter().isVisible(row) || col >= getCellCount(row)) return false; Widget w = super.getWidget(row, col); if (w == null || !w.isVisible()) return false; if (w instanceof SmartTableCell) { return ((SmartTableCell)w).focus(); } else if (w instanceof HasFocus) { return ((HasFocus)w).focus(); } else if (w instanceof Focusable) { ((Focusable)w).setFocus(true); if (w instanceof TextBoxBase) ((TextBoxBase)w).selectAll(); return true; } return false; }
/** * Sets the components widget representation and initializes its properties. * * <p>To be called from implementing constructor. * * @param widget components visual representation in designer */ void initComponent(Widget widget) { // Widget needs to be initialized before the component itself so that the component properties // can be reflected by the widget initWidget(widget); // Capture mouse and click events in onBrowserEvent(Event) sinkEvents(Event.MOUSEEVENTS | Event.ONCLICK); // Add the special name property and set the tooltip String name = componentName(); setTitle(name); addProperty(PROPERTY_NAME_NAME, name, null, new TextPropertyEditor()); // TODO(user): Ensure this value is unique within the project using a list of // already used UUIDs // Set the component's UUID // The default value here can be anything except 0, because YoungAndroidProjectServce // creates forms with an initial Uuid of 0, and Properties.java doesn't encode // default values when it generates JSON for a component. addProperty(PROPERTY_NAME_UUID, "-1", null, new TextPropertyEditor()); changeProperty(PROPERTY_NAME_UUID, "" + Random.nextInt()); editor.getComponentPalettePanel().configureComponent(this); }
private MediaExecutor<Widget> createSwfExecutor(BaseMediaConfiguration bmc) { if (bmc.isFeedback()) { return simpleSwfExecutorProvider.get(); } else { return createLocalSwfMediaExecutor(); } }
/** * buduke widok na starych zasadach * * @param element */ protected void createOldView(Element element) { ImgContent content; imageSource = element.getAttribute("src"); if (element.getElementsByTagName("label").getLength() > 0) { content = labelledImgContentProvider.get(); } else { Map<String, String> styles = styleSocket.getStyles(element); if (styles.containsKey(EMPIRIA_IMG_MODE) && styles.get(EMPIRIA_IMG_MODE).equalsIgnoreCase("explorable")) { content = explorableImgContentProvider.get(); } else { content = picturePlayerModuleProvider.get(); } } content.init(element, getModuleSocket()); view.setContent(content); NodeList titleNodes = element.getElementsByTagName("title"); if (titleNodes.getLength() > 0) { Widget titleWidget = getModuleSocket().getInlineBodyGeneratorSocket().generateInlineBody(titleNodes.item(0)); if (titleWidget != null) { view.setTitle(titleWidget); } } NodeList descriptionNodes = element.getElementsByTagName("description"); if (descriptionNodes.getLength() > 0) { Widget descriptionWidget = getModuleSocket().getInlineBodyGeneratorSocket().generateInlineBody(descriptionNodes.item(0)); if (descriptionWidget != null) { view.setDescription(descriptionWidget); } } }
private CallbackReceiver<MediaWrapper<Widget>> createCallbackReceiver(final String audioName, final ExternalSoundInstanceCallback callback, final Optional<OnEndCallback> onEndCallback, final Optional<OnPauseCallback> onPauseCallback) { return new CallbackReceiver<MediaWrapper<Widget>>() { @Override public void setCallbackReturnObject(MediaWrapper<Widget> audioWrapper) { ExternalSoundInstance soundInstance = moduleFactory.getExternalSoundInstance(audioWrapper, onEndCallback, onPauseCallback); callback.onSoundCreated(soundInstance, audioName); } }; }
@Test public void shouldReturnViewAsWidget() { // given Widget widget = mock(Widget.class); when(view.asWidget()).thenReturn(widget); // when Widget result = testObj.getView(); // then assertThat(result).isEqualTo(widget); }
/** * Creates video on page! */ private static void createVideoDialog(String tutorialId) { // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(true, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText("Tutorial Video"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); VerticalPanel DialogBoxContents = new VerticalPanel(); // Adds Youtube Video HTML message = new HTML("<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/" + tutorialId + "?rel=0&autoplay=1\" frameborder=\"0\" allowfullscreen></iframe>"); message.setStyleName("DialogBox-message"); FlowPanel holder = new FlowPanel(); Button ok = new Button("Close"); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); ok.setStyleName("DialogBox-button"); holder.add(ok); DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.center(); dialogBox.show(); }
protected Widget createTitleWidget(String index, String text) { Panel titlePanel = new FlowPanel(); titlePanel.setStyleName(styleNames.QP_ITEM_TITLE()); Label indexLabel = new Label(index + ". "); indexLabel.setStyleName(styleNames.QP_ITEM_TITLE_INDEX()); Label textLabel = new Label(text); textLabel.setStyleName(styleNames.QP_ITEM_TITLE_TEXT()); titlePanel.add(indexLabel); titlePanel.add(textLabel); return titlePanel; }
private void mockDropEnabling() { @SuppressWarnings("unchecked") DroppableObject<FlowPanelWithDropZone> droppable = Mockito.mock(DroppableObject.class); when(dragGapView.enableDropCapabilities()).thenReturn(droppable); Widget droppableWidget = Mockito.mock(Widget.class); when(droppable.getDroppableWidget()).thenReturn(droppableWidget); dropZoneGuardian = Mockito.mock(DropZoneGuardian.class); when(dragGapModuleFactory.createDropZoneGuardian(droppable, droppableWidget)).thenReturn(dropZoneGuardian); }
public boolean focus() { Widget w = getWidget(); if (w instanceof UniTimeWidget<?>) w = ((UniTimeWidget<?>)w).getWidget(); if (w instanceof Focusable) { ((Focusable)w).setFocus(true); if (w instanceof TextBox) ((TextBox)w).selectAll(); return true; } return false; }
static void restoreSizeStyle(Widget w, String[] style) { Element element = w.getElement(); if (style[0] != null) { DOM.setStyleAttribute(element, "width", style[0]); } if (style[1] != null) { DOM.setStyleAttribute(element, "height", style[1]); } }
private void registerOnPauseCallback(MediaWrapper<Widget> audioWrapper, final Optional<OnPauseCallback> onPauseCallback) { if (onPauseCallback.isPresent()) { mediaWrapperController.addHandler(MediaEventTypes.ON_PAUSE, audioWrapper, new MediaEventHandler() { @Override public void onMediaEvent(MediaEvent event) { onPauseCallback.get().onPause(); } }); } }
private Widget prepareObjectModuleView(Element element, Element defaultTemplate) { AudioModuleView audioModuleView = new AudioModuleView(); addStyleName(element, audioModuleView); Map<String, String> src = getSource(element, "audio"); mediaWrapperCreator.createMediaWrapper(src, getCallbackRecevier(defaultTemplate, audioModuleView)); return audioModuleView; }
@Override public Widget getView() { if (pagePanel == null) { pagePanel = controller.getView(); pagePanel.setStyleName(styleNames.QP_PAGE_IN_PAGE()); } return pagePanel; }
void setFor(ComponentConnector forId) { Widget widget = forId.getWidget(); // VNativeSelect need binding of Caption on the ListBox to get :focus if (widget instanceof VNativeSelect) { AriaHelper.bindCaption(((VNativeSelect) widget).getListBox(), label); return; } AriaHelper.bindCaption(widget, label); }
/** * Possibly display the MIT App Inventor "Splash Screen" * * @param force Bypass the check to see if they have dimissed this version */ private void createWelcomeDialog(boolean force) { if (!shouldShowWelcomeDialog() && !force) { maybeShowNoProjectsDialog(); return; } // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText(MESSAGES.createWelcomeDialogText()); dialogBox.setHeight(splashConfig.height + "px"); dialogBox.setWidth(splashConfig.width + "px"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); VerticalPanel DialogBoxContents = new VerticalPanel(); HTML message = new HTML(splashConfig.content); message.setStyleName("DialogBox-message"); FlowPanel holder = new FlowPanel(); Button ok = new Button(MESSAGES.createWelcomeDialogButton()); final CheckBox noshow = new CheckBox(MESSAGES.doNotShow()); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); if (noshow.getValue()) { // User checked the box userSettings.getSettings(SettingsConstants.SPLASH_SETTINGS). changePropertyValue(SettingsConstants.SPLASH_SETTINGS_VERSION, "" + splashConfig.version); userSettings.saveSettings(null); } maybeShowNoProjectsDialog(); } }); holder.add(ok); holder.add(noshow); DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.show(); }
public void addBlankLine() { List<Widget> line = new ArrayList<Widget>(); HorizontalPanel hp = new HorizontalPanel(); line.add(hp); CurriculaCourseSelectionBox cx = new CurriculaCourseSelectionBox(); cx.setWidth("130px"); cx.addCourseSelectionHandler(iCourseChangedHandler); if (cx.getCourseFinder() instanceof HasOpenHandlers) ((HasOpenHandlers<PopupPanel>)cx.getCourseFinder()).addOpenHandler(new OpenHandler<PopupPanel>() { @Override public void onOpen(OpenEvent<PopupPanel> event) { iTable.clearHover(); } }); if (!iEditable) cx.setEnabled(false); line.add(cx); for (int col = 0; col < iClassifications.getClassifications().size(); col++) { ShareTextBox ex = new ShareTextBox(col, null, null); if (!iEditable) ex.setReadOnly(true); line.add(ex); EnrollmentLabel note = new EnrollmentLabel(col, null, null, null, null, null, null); line.add(note); } int row = iTable.addRow("", line); iTable.getRowFormatter().addStyleName(row, "unitime-NoPrint"); if (iVisibleCourses != null) iTable.getRowFormatter().setVisible(row, false); for (int col = 0; col < line.size(); col++) if (!iTable.getCellFormatter().isVisible(0, col)) iTable.getCellFormatter().setVisible(row, col, false); }
@Override public void onMediaEvent(MediaEvent event) { MediaWrapper<Widget> onEndEventSource = (MediaWrapper<Widget>) event.getMediaWrapper(); if (slideshowSounds.containsWrapper(onEndEventSource)) { slideEndHandler.onEnd(); } }
@Override protected List<Widget> getData() { Map<String, String> attrColorMap = createAttributeColorMap(); List<Widget> widgets = new ArrayList<Widget>(); for (Entry<String, String> attr : attrColorMap.entrySet()) { HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(2); hpanel.add(getColorPanel(attr.getValue())); hpanel.add(new Label(attr.getKey())); widgets.add(hpanel); } return widgets; }
private Widget createPanel() { VerticalLayoutContainer panel = new VerticalLayoutContainer(); initLayerCombo1(); FieldLabel layer1Label = new FieldLabel(layerCombo1, UIMessages.INSTANCE.layerLabelText("")); panel.add(layer1Label, new VerticalLayoutData(1, -1)); return panel; }
private Widget mockSurfaceWidget(ConnectionModuleViewImpl spyView) { ConnectionSurface surface = mock(ConnectionSurface.class); Widget widget = mock(Widget.class); when(surface.asWidget()).thenReturn(widget); doReturn(surface).when(spyView).getCurrentSurface(); return widget; }
public void refreshTable() { for (int r = 1; r < getRowCount(); r++) { for (int c = 0; c < getCellCount(r); c++) { Widget w = getWidget(r, c); if (w instanceof HasRefresh) ((HasRefresh)w).refresh(); } } }
@Override public void onMouseDown(MouseDownEvent event) { clickTargetWidget = (Widget) event.getSource(); event.stopPropagation(); }
private MediaController createModuleWrapper(String elementName) { MediaController moduleWrapper = null; Widget widget = generateInlineBody(elementName); if (widget == null) { moduleWrapper = createEmptyModuleWrapper(); } else { moduleWrapper = createModuleWrapperForWidget(widget); } return moduleWrapper; }
public Widget createPager(int slidesSize) { for (int i = 0; i < slidesSize; i++) { SlideshowPagerButtonPresenter pagerButton = createPagerButton(); pagerButtonsList.add(pagerButton); view.addPager(pagerButton.getView()); } return view.asWidget(); }
@Override public Widget getView() { if (switchWidget == null) { switchWidget = new PageSwitchListBox(); switchWidget.addChangeHandler(this); switchWidget.setItemsCount(dataSourceSupplier.getItemsCount()); ((Widget) switchWidget).setStyleName(getStyleName()); } return (Widget) switchWidget; }
private void fixHandlers(final FilterBox box, Widget w) { if (w instanceof HasBlurHandlers) ((HasBlurHandlers)w).addBlurHandler(box.iBlurHandler); if (w instanceof HasFocusHandlers) ((HasFocusHandlers)w).addFocusHandler(box.iFocusHandler); if (w instanceof HasKeyDownHandlers) ((HasKeyDownHandlers)w).addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) if (box.isFilterPopupShowing()) box.hideFilterPopup(); } }); }
public CheckBox getClassSelection(int row) { Widget w = getWidget(row, 0); if (w != null && w instanceof CheckBox) { return (CheckBox)w; } else { return null; } }
private Widget createPanel() { final VerticalLayoutContainer vPanel = new VerticalLayoutContainer(); vPanel.addStyleName(ThemeStyles.get().style().borderBottom()); final GitHubRepositoryAttributeBeanProperties props = GWT .create(GitHubRepositoryAttributeBeanProperties.class); repositoryStore = new ListStore<GitHubRepositoryAttributeBean>(props.key()); final ColumnConfig<GitHubRepositoryAttributeBean, Integer> idCol = new ColumnConfig<GitHubRepositoryAttributeBean, Integer>( props.attributeId(), 190, "Id"); final ColumnConfig<GitHubRepositoryAttributeBean, String> nameCol = new ColumnConfig<GitHubRepositoryAttributeBean, String>( props.attributeName(), 190, UIMessages.INSTANCE.gitHubColumNameRepo()); final ColumnConfig<GitHubRepositoryAttributeBean, String> descriptionCol = new ColumnConfig<GitHubRepositoryAttributeBean, String>( props.description(), 200, UIMessages.INSTANCE.gitHubColumDescriptionRepo()); final ColumnConfig<GitHubRepositoryAttributeBean, String> fullNameCol = new ColumnConfig<GitHubRepositoryAttributeBean, String>( props.attributeFullName(), 200, "Full Name"); final List<ColumnConfig<GitHubRepositoryAttributeBean, ?>> columns = new ArrayList<ColumnConfig<GitHubRepositoryAttributeBean, ?>>(); //columns.add(idCol); columns.add(nameCol); columns.add(descriptionCol); //columns.add(fullNameCol); final ColumnModel<GitHubRepositoryAttributeBean> columModel = new ColumnModel<GitHubRepositoryAttributeBean>( columns); grid = new Grid<GitHubRepositoryAttributeBean>( repositoryStore, columModel); //grid.setSelectionModel(new CellSelectionModel<GitHubRepositoryAttributeBean>()); grid.getColumnModel().getColumn(0).setHideable(false); grid.setAllowTextSelection(true); grid.getView().setStripeRows(true); grid.getView().setColumnLines(true); grid.setBorders(false); setGridDragable(grid); vPanel.add(grid, new VerticalLayoutData(1, 1, new Margins(5, 0, 0, 0))); return vPanel; }
private Widget getSaveToolGroup1Tools() { HorizontalPanel horizontalGroup = new HorizontalPanel(); horizontalGroup.getElement().getStyle() .setVerticalAlign(VerticalAlign.MIDDLE); horizontalGroup.setSpacing(5); horizontalGroup.add(saveLayerTool); horizontalGroup.add(exportLayerTool); //horizontalGroup.add(saveProjectTool); return horizontalGroup; }
protected Widget getCell(final GroupInterface group, final RoomGroupsColumn column, final int idx) { switch (column) { case NAME: return new Label(group.getLabel() == null ? "" : group.getLabel(), false); case ABBREVIATION: return new Label(group.getAbbreviation() == null ? "" : group.getAbbreviation(), false); case DEFAULT: if (group.isDefault()) return new Image(RESOURCES.on()); else return null; case DEPARTMENT: return new DepartmentCell(true, group.getDepartment()); case DESCRIPTION: if (group.hasDescription()) { HTML html = new HTML(group.getDescription()); html.setStyleName("description"); return html; } else return null; case ROOMS: if (group.hasRooms()) return new RoomsCell(group); else return null; default: return null; } }
public boolean removeChip(Chip chip, boolean fireEvents) { for (int i = 0; i < getWidgetCount(); i++) { Widget w = getWidget(i); if (w instanceof ChipPanel && ((ChipPanel)w).getChip().equals(chip)) { remove(i); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); if (fireEvents) ValueChangeEvent.fire(FilterBox.this, getValue()); return true; } } return false; }
public Widget getContentView() { return contentView; }
@Override public void parse(Node mainNode, Widget parent) { super.parse(mainNode, parent); }
@Override public void setMediaWrapper(MediaWrapper<Widget> descriptor) { }