Java Code Examples for com.google.gwt.user.client.ui.Panel

The following are top voted examples for showing how to use com.google.gwt.user.client.ui.Panel. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: sigmah   File: CreditsView.java   View source code 7 votes vote down vote up
private Panel buildPropertiesPanel() {

		// Team panel.
		final ScrollPanel scrollTeamPanel = new ScrollPanel();
		scrollTeamPanel.addStyleName(CSS_SCROLL);
		scrollTeamPanel.add(buildTeamPanel());

		// Main panel.
		final HorizontalPanel panel = new HorizontalPanel();
		panel.addStyleName(CSS_PROPS);

		panel.add(buildVersionPanel());
		panel.add(scrollTeamPanel);

		return panel;

	}
 
Example 2
Project: empiria.player   File: PageViewSocketImpl.java   View source code 6 votes vote down vote up
@Override
public void setPageViewCarrier(PageViewCarrier pageViewCarrier) {
    view.getTitlePanel().clear();
    view.getTitlePanel().add(pageViewCarrier.getPageTitle());
    if (pageViewCarrier.hasContent()) {
        Panel contentPanel = new FlowPanel();

        if (pageViewCarrier.pageType == PageType.ERROR) {
            contentPanel.setStyleName(styleNames.QP_PAGE_ERROR());
            Label errorLabel = new Label(pageViewCarrier.errorMessage);
            errorLabel.setStyleName(styleNames.QP_PAGE_ERROR_TEXT());
            contentPanel.add(errorLabel);
        }

        view.getItemsPanel().clear();
        view.getItemsPanel().add(contentPanel);
    }
}
 
Example 3
Project: empiria.player   File: VolumeMediaButton.java   View source code 6 votes vote down vote up
@Override
protected void onClick() {
    setActive(!isActive());
    if (!attached) {
        volumeScrollBar.getElement().getStyle().setPosition(Position.ABSOLUTE);
        ((Panel) getParent()).add(volumeScrollBar);
        attached = true;
    }
    changeStyleForClick();
    if (isActive()) {
        volumeScrollBar.setVisible(true);
        int width = volumeScrollBar.getElement().getAbsoluteRight() - volumeScrollBar.getElement().getAbsoluteLeft();
        width = getElement().getAbsoluteRight() - getElement().getAbsoluteLeft() - width;
        volumeScrollBar.getElement().getStyle().setLeft(getElement().getAbsoluteLeft() + width / 2, Unit.PX);
        int height = volumeScrollBar.getElement().getAbsoluteBottom() - volumeScrollBar.getElement().getAbsoluteTop();
        volumeScrollBar.getElement().getStyle().setTop(getElement().getAbsoluteTop() - height, Unit.PX);

    } else {
        volumeScrollBar.setVisible(false);
    }
}
 
Example 4
Project: appinventor-extensions   File: GalleryPage.java   View source code 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's title section
 * @param container   The container that title resides
 */
private void initAppTitle(Panel container) {
  if (newOrUpdateApp()) {
    // GUI for editable title container
    if (editStatus==NEWAPP) {
      // If it's new app, give a textual hint telling user this is title
      titleText.setText(app.getTitle());
    } else if (editStatus==UPDATEAPP) {
      // If it's not new, just set whatever's in the data field already
      titleText.setText(app.getTitle());
    }
    titleText.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setTitle(titleText.getText());
      }
    });
    titleText.addStyleName("app-desc-textarea");
    container.add(titleText);
    container.addStyleName("app-title-container");
  } else {
    Label title = new Label(app.getTitle());
    title.addStyleName("app-title");
    container.add(title);
  }
}
 
Example 5
Project: appinventor-extensions   File: GalleryPage.java   View source code 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's description
 * @param c1   The container that description resides (editable state)
 * @param c2   The container that description resides (public state)
 */
private void initAppDesc(Panel c1, Panel c2) {
  desc.getElement().setPropertyString("placeholder", MESSAGES.galleryDescriptionHint());
  if (newOrUpdateApp()) {
    desc.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setDescription(desc.getText());
      }
    });
    if(editStatus==UPDATEAPP){
      desc.setText(app.getDescription());
    }
    desc.addStyleName("app-desc-textarea");
    c1.add(desc);
  } else {
    Label description = new Label(app.getDescription());
    c2.add(description);
    c2.addStyleName("app-description");
  }
}
 
Example 6
Project: appinventor-extensions   File: GalleryPage.java   View source code 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the salvage section
 * @param container   The container that salvage label reside
 */
private void initSalvageSection(Panel container) { //TODO: Update the location of this button
  if (!canSalvage()) {                              // Permitted to salvage?
    return;
  }

  final Label salvagePrompt = new Label("salvage");
  salvagePrompt.addStyleName("primary-link");
  container.add(salvagePrompt);

  salvagePrompt.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
      final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>(
          // failure message
          MESSAGES.galleryError()) {
            @Override
            public void onSuccess(Void bool) {
              salvagePrompt.setText("done");
            }
        };
      Ode.getInstance().getGalleryService().salvageGalleryApp(app.getGalleryAppId(), callback);
    }
  });
}
 
Example 7
Project: walkaround   File: Walkaround.java   View source code 6 votes vote down vote up
/** Reveals the log div, and executes a task when done. */
// The async API for this method is intended to support two things: a cool
// spew animation, and also the potential to runAsync the whole LogPanel code.
private static void attachLogPanel() {
  Logs.get().addHandler(domLogger);
  final Panel logHolder = RootPanel.get("logHolder");
  logHolder.setVisible(true);

  // Need one layout and paint cycle after revealing it to start animation.
  // Use high priority to avoid potential starvation by other tasks if a
  // problem is occurring.
  SchedulerInstance.getHighPriorityTimer().scheduleDelayed(new Task() {
    @Override
    public void execute() {
      logHolder.add(domLogger);
      Style waveStyle = Document.get().getElementById(WAVEPANEL_PLACEHOLDER).getStyle();
      Style logStyle = logHolder.getElement().getStyle();
      logStyle.setHeight(250, Unit.PX);
      waveStyle.setBottom(250, Unit.PX);
    }
  }, 50);
}
 
Example 8
Project: Wiab.pro   File: KeyBindingRegistryIntegrationGwtTest.java   View source code 6 votes vote down vote up
/** Util to help construct an editor instance. */
private EditorImpl createEditor(KeyBindingRegistry keyBinding) {
  EditorStaticDeps.setPopupProvider(new PopupProvider() {
    @Override
    public UniversalPopup createPopup(Element reference, RelativePopupPositioner positioner,
        PopupChrome chrome, boolean autoHide) {
      return new Popup(reference, positioner);
    }
    @Override
    public void setRootPanel(Panel rootPanel) {
      // Not used as we use our own popup implementation.
    }
  });
  Editor editor = Editors.create();
  initEditor(editor, Editor.ROOT_REGISTRIES, keyBinding);
  return (EditorImpl) editor;
}
 
Example 9
Project: ontobrowser   File: SearchOptionsView.java   View source code 6 votes vote down vote up
private Panel createPanel() {
	Label label = new Label("Search Options");
	label.addStyleName("search-header");
	label.getElement().getStyle().setDisplay(Display.BLOCK);
	
	Grid grid = new Grid(2,2);
	grid.setText(0, 0, "Ontology/Codelist:");
	grid.setWidget(0, 1, ontologiesDropBox);
	grid.setText(1, 0, "Include Synonyms:");
	grid.setWidget(1, 1, includeSynonyms);
	grid.addStyleName("search-options");
	
	CellFormatter cellFormatter = grid.getCellFormatter();
	for(int i = 0; i < grid.getRowCount(); i++) {
		cellFormatter.addStyleName(i, 0, "search-option");
	}
	
	Panel panel = new FlowPanel();
	panel.add(label);
	panel.add(grid);
    return panel;
}
 
Example 10
Project: firefly   File: MiniPlotWidget.java   View source code 6 votes vote down vote up
public Panel makeFixedSizeContainer(int width, int height, boolean decorated) {

        SimplePanel panel= new SimplePanel();
        panel.setWidget(this);
        panel.setPixelSize(width,height);

        Panel retval= panel;

        if (decorated) {
            DecoratorPanel dp= new DecoratorPanel();
            dp.setWidget(panel);
            retval= dp;
        }
        return retval;

    }
 
Example 11
Project: firefly   File: MiniPlotWidget.java   View source code 6 votes vote down vote up
public Panel makeFailureMessage(String message, int width, int height, boolean decorated) {
    VerticalPanel panel= new VerticalPanel();
    HTML header = new HTML(getTitle());
    Widget msg = GwtUtil.centerAlign(new HTML(message));
    header.addStyleName("preview-title");
    GwtUtil.setStyle(msg, "padding", "5px");
    panel.add(header);
    panel.add(msg);
    panel.setPixelSize(width, height);

    Panel retval= panel;

    if (decorated) {
        DecoratorPanel dp= new DecoratorPanel();
        dp.setWidget(panel);
        retval= dp;
    }
    return retval;
}
 
Example 12
Project: firefly   File: ImageSelectDialogTypes.java   View source code 6 votes vote down vote up
public void addTab(TabPane<Panel> tabs) {
    FlowPanel fp= new FlowPanel();
    fp.add(urlField);
    fp.add(multiAction);
    fp.add(ext);

    GwtUtil.setStyle(urlField, "padding", "20px 0 25px 30px");
    tabs.addTab(fp, _prop.getTitle("url"));


    GwtUtil.setHidden(ext,multiAction.getField().getValue().equals("loadAll"));

    multiAction.getField().addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            GwtUtil.setHidden(ext, multiAction.getField().getValue().equals("loadAll"));
        }
    });

}
 
Example 13
Project: fullmetalgalaxy   File: MAppPresences.java   View source code 6 votes vote down vote up
@Override
public void onChannelMessage(Object p_message)
{
  // redraw widget according to new presenceRoom
  PresenceRoom newPresenceRoom = (PresenceRoom)p_message;
  m_panel.clear();
  Set<String> pseudoList = new HashSet<String>();
  for( Presence presence : newPresenceRoom )
  {
    if( !pseudoList.contains( presence.getPseudo() ) )
    {
      pseudoList.add( presence.getPseudo() );
      Panel panel = new HorizontalPanel();
      Image image = new Image( presence.getAvatarUrl() );
      image.setPixelSize( 32, 32 );
      image.setAltText( presence.getPseudo() );
      image.setTitle( presence.getPseudo() );
      panel.add( image );
      panel.add( new Label(presence.getPseudo()) );
      m_panel.add( panel );
    }
  }
}
 
Example 14
Project: fullmetalgalaxy   File: MAppChat.java   View source code 6 votes vote down vote up
public MAppChat()
{
  m_panel.setSize( "100%", "100%" );

  scrollPanel.setHeight( "400px" );
  m_msgList.setStyleName( "msglist" );
  scrollPanel.add( m_msgList );
  m_panel.add( scrollPanel );

  Panel hpanel = new HorizontalPanel();
  hpanel.setSize( "100%", "100%" );
  hpanel.add( m_text );
  m_text.setWidth( "100%" );
  m_text.addKeyDownHandler( this );
  hpanel.add( m_btnOk );
  m_btnOk.addClickHandler( this );
  m_panel.add( hpanel );

  initWidget( m_panel );
}
 
Example 15
Project: blogwt   File: UiHelper.java   View source code 6 votes vote down vote up
/**
 * Swaps a TextBox with an element of the same type for remember password. The text box needs to be within an panel. The styles of the text box are also
 * copied
 * 
 * @param textBox
 * @param elementId
 * @return
 */
@SuppressWarnings("unchecked")
public static <T extends TextBox> T swap (T textBox, String elementId) {
	Panel parent = (Panel) textBox.getParent();
	T newTextBox = null;

	if (textBox instanceof PasswordTextBox) {
		newTextBox = (T) PasswordTextBox
				.wrap(DOM.getElementById(elementId));
	} else if (textBox instanceof TextBox) {
		newTextBox = (T) TextBox.wrap(DOM.getElementById(elementId));
	}

	newTextBox.getElement().setAttribute("class",
			textBox.getElement().getAttribute("class"));
	newTextBox.removeFromParent();
	parent.getElement().insertBefore(newTextBox.getElement(),
			textBox.getElement());

	textBox.removeFromParent();

	return newTextBox;
}
 
Example 16
Project: appformer   File: GridLienzoScrollBarsTest.java   View source code 6 votes vote down vote up
private Panel scrollPanel() {

        final Panel panel = mock(AbsolutePanel.class);
        final Element element = mock(Element.class);

        doReturn(SCROLL_LEFT).when(element).getScrollLeft();
        doReturn(SCROLL_TOP).when(element).getScrollTop();
        doReturn(SCROLL_WIDTH).when(element).getScrollWidth();
        doReturn(SCROLL_HEIGHT).when(element).getScrollHeight();
        doReturn(CLIENT_WIDTH).when(element).getClientWidth();
        doReturn(CLIENT_HEIGHT).when(element).getClientHeight();

        doReturn(element).when(panel).getElement();

        return panel;
    }
 
Example 17
Project: appformer   File: GridLienzoScrollBarsTest.java   View source code 6 votes vote down vote up
private Panel emptyPanel() {

        final Panel panel = mock(AbsolutePanel.class);
        final Element element = mock(Element.class);

        doReturn(0).when(element).getScrollLeft();
        doReturn(0).when(element).getScrollTop();
        doReturn(0).when(element).getScrollWidth();
        doReturn(0).when(element).getScrollHeight();
        doReturn(0).when(element).getClientWidth();
        doReturn(0).when(element).getClientHeight();

        doReturn(element).when(panel).getElement();

        return panel;
    }
 
Example 18
Project: google-apis-explorer   File: FullView.java   View source code 6 votes vote down vote up
/**
 * Generate breadcrumbs into the specified container using the format link > link > text where the
 * last breadcrumb is always plain text.
 */
private void generateBreadcrumbs(Panel container, List<Title> titles) {
  container.clear();

  // For all of the titles previous to the last, add a link and a separator.
  for (Title notLast : titles.subList(0, titles.size() - 1)) {
    container.add(new InlineHyperlink(notLast.getTitle(), notLast.getFragment()));
    container.add(new InlineLabel(" > "));
  }

  // Append only the text for the last title.
  Title lastTitle = Iterables.getLast(titles);
  container.add(new InlineLabel(lastTitle.getTitle()));
  if (lastTitle.getSubtitle() != null) {
    Label subtitle = new InlineLabel(" - " + lastTitle.getSubtitle());
    subtitle.addStyleName(style.methodSubtitle());
    container.add(subtitle);
  }
}
 
Example 19
Project: qafe-platform   File: RendererHelper.java   View source code 6 votes vote down vote up
public static void addMenu(ComponentGVO vo, UIObject ui, String uuid, String parent) {
	if (vo != null && ui != null) {
		if (vo.getMenu() != null) {
			MenuBar menu = new MenuBar();
			menu.setAutoOpen(true);
			menu.setWidth("100%");
			UIObject renderedComponent = new MenuItemRenderer().render(vo.getMenu(), uuid, parent, vo.getContext());
			if (renderedComponent instanceof MenuBar) {
				menu.addItem(vo.getMenu().getDisplayname(), (MenuBar) renderedComponent);
			} else if (renderedComponent instanceof MenuItem) {
				menu.addItem((MenuItem) renderedComponent);
			}
			if (ui instanceof DockPanel) {
				((DockPanel) ui).add(menu, DockPanel.NORTH);
			} else if (ui instanceof Grid || ui instanceof VerticalPanel || ui instanceof HorizontalPanel)
				((Panel) ui).add(menu);
		}
	}

}
 
Example 20
Project: qafe-platform   File: GWTUIGenerator.java   View source code 6 votes vote down vote up
public static final Panel createView(UIGVO ui) {
	Panel view = null;
	if (ui != null) {
		String uuid = ui.getUuid();

		WindowGVO[] windows = ui.getWindows();
		Widget[] widgets = new Widget[windows.length];

		/*
		 * for (int i = 0; i < windows.length; i++) {
		 *
		 * Widget w = (Widget) new
		 * WindowRenderer().render(windows[i],windows[i].getId() +"|"+uuid
		 * ); widgets[i] = w; }
		 */
		buildMenu(widgets, windows, uuid, ui);

	}

	return view;
}
 
Example 21
Project: qafe-platform   File: RendererHelper.java   View source code 6 votes vote down vote up
public static void addMenu(ComponentGVO vo, UIObject ui, String uuid, String parent) {
	if (vo != null && ui != null) {
		if (vo.getMenu() != null) {
			MenuBar menu = new MenuBar();
			menu.setAutoOpen(true);
			menu.setWidth("100%");
			UIObject renderedComponent = new MenuItemRenderer().render(vo.getMenu(), null, uuid, parent, vo.getContext(), null);
			if (renderedComponent instanceof MenuBar) {
				menu.addItem(vo.getMenu().getDisplayname(), (MenuBar) renderedComponent);
			} else if (renderedComponent instanceof MenuItem) {
				menu.addItem((MenuItem) renderedComponent);
			}
			if (ui instanceof DockPanel) {
				((DockPanel) ui).add(menu, DockPanel.NORTH);
			} else if (ui instanceof Grid || ui instanceof VerticalPanel || ui instanceof HorizontalPanel)
				((Panel) ui).add(menu);
		}
	}

}
 
Example 22
Project: risk   File: DiceAnimation.java   View source code 6 votes vote down vote up
public DiceAnimation(DiceImages diceImages, Panel panel, int delay, String text, 
    List<Integer> rolls) {
  diceImageList = new ArrayList<ImageResource>();
  diceImageList.add(diceImages.dice1());
  diceImageList.add(diceImages.dice2());
  diceImageList.add(diceImages.dice3());
  diceImageList.add(diceImages.dice4());
  diceImageList.add(diceImages.dice5());
  diceImageList.add(diceImages.dice6());
  diceImageList.add(diceImages.diceLeft1());
  diceImageList.add(diceImages.diceLeft2());
  diceImageList.add(diceImages.diceLeft3());
  diceImageList.add(diceImages.diceLeft4());
  diceImageList.add(diceImages.diceLeft5());
  diceImageList.add(diceImages.diceLeft6());
  diceImageList.add(diceImages.diceRight1());
  diceImageList.add(diceImages.diceRight2());
  diceImageList.add(diceImages.diceRight3());
  diceImageList.add(diceImages.diceRight4());
  diceImageList.add(diceImages.diceRight5());
  diceImageList.add(diceImages.diceRight6());
  this.delay = delay;
  this.rolls = rolls;
  this.text = text;
  this.panel = panel;
}
 
Example 23
Project: gwthtml5apps   File: ExportImage.java   View source code 6 votes vote down vote up
private IntegerBox makeIntegerBox(Panel parent,String name,int value){
	HorizontalPanel h1=new HorizontalPanel();
	//h.setWidth("100%");
	
	parent.add(h1);
	
	Label label=new Label(name);
	label.setWidth("100px");
	h1.add(label);
	
	IntegerBox box=new IntegerBox();
	box.setWidth("40px");
	box.setValue(value);
	h1.add(box);
	return box;
}
 
Example 24
Project: libgdxcn   File: GwtGraphics.java   View source code 6 votes vote down vote up
public GwtGraphics (Panel root, GwtApplicationConfiguration config) {
	Canvas canvasWidget = Canvas.createIfSupported();
	if (canvasWidget == null) throw new GdxRuntimeException("Canvas not supported");
	canvas = canvasWidget.getCanvasElement();
	root.add(canvasWidget);
	canvas.setWidth(config.width);
	canvas.setHeight(config.height);
	this.config = config;

	WebGLContextAttributes attributes = WebGLContextAttributes.create();
	attributes.setAntialias(config.antialiasing);
	attributes.setStencil(config.stencil);
	attributes.setAlpha(false);
	attributes.setPremultipliedAlpha(false);
	attributes.setPreserveDrawingBuffer(config.preserveDrawingBuffer);

	context = WebGLRenderingContext.getContext(canvas, attributes);
	context.viewport(0, 0, config.width, config.height);
	this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GwtGL20(context);
}
 
Example 25
Project: rva   File: PresentationLayoutWidget.java   View source code 6 votes vote down vote up
public void onClick(Widget sender, Event event, int eventType) {
	Panel placeholderWidget = (Panel) sender;
	
	if (eventType == Event.BUTTON_RIGHT) {
    	int x = event.getClientX() + 1;
    	int y = event.getClientY() + 1;
    	contextMenuWidget.setPopupPosition(x, y);
    	contextMenuWidget.show();
	}
	else if (eventType == Event.BUTTON_LEFT) {
		contextMenuWidget.hide();
	}
	
	if (placeholderWidget != placeholderMap.get(selectedPlaceholder) && placeholderWidget != selectedWindowPanel) {
		Object[] items = placeholderMap.keySet().toArray();
		
		deselectPlaceholder();
		for (int i = 0; i < items.length; i++) {
			if (placeholderWidget == placeholderMap.get(items[i].toString())) {
				selectedPlaceholder = items[i].toString();
				selectPlaceholder();
			}
		}
	}
}
 
Example 26
Project: empiria.player   File: PageViewSocketImpl.java   View source code 5 votes vote down vote up
@Override
public void initItemViewSockets(int count) {
    view.getItemsPanel().clear();
    Panel[] itemPanels = new Panel[count];
    items = new ItemContentView[count];
    for (int i = 0; i < count; i++) {
        itemPanels[i] = new FlowPanel();
        itemPanels[i].setStyleName(styleNames.QP_PAGE_ITEM());
        items[i] = new ItemContentView(itemPanels[i]);
        view.getItemsPanel().add(itemPanels[i]);
    }

}
 
Example 27
Project: empiria.player   File: MainController.java   View source code 5 votes vote down vote up
public void init(Panel panel) {
    if (shouldBeInitialized) {
        this.wrappingPanel = panel;
        wordsController.load();
        explanationController.init();
        shouldBeInitialized = false;
    }
}
 
Example 28
Project: empiria.player   File: InteractionMathJaxModule.java   View source code 5 votes vote down vote up
private void generateGaps(Element element) {
    Panel gapContainer = new FlowPanel();
    gapContainer.setVisible(false);
    rootPanel.getRootPanel().add(gapContainer);

    NodeList gaps = element.getElementsByTagName("gap");
    for (int i = 0; i < gaps.getLength(); i++) {
        Node gap = gaps.item(i);
        getBodyGenerator().processNode(gap, gapContainer);
    }
}
 
Example 29
Project: empiria.player   File: MultiPageController.java   View source code 5 votes vote down vote up
private void showProgressBarForPage(int pageIndex) {
    if (!loadedPages.contains(pageIndex) && isValidPageIndex(pageIndex)) {
        Panel panel = getViewForPage(pageIndex);
        panel.add(new ProgressPanel());
        pageProgressBar = pageIndex;
    }
}
 
Example 30
Project: empiria.player   File: ItemController.java   View source code 5 votes vote down vote up
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;
}
 
Example 31
Project: empiria.player   File: ReportTableGenerator.java   View source code 5 votes vote down vote up
private void generateHeaderCell(CellCoords cellCoords, Node cellNode) {
    Panel cellPanel = prepareCellPanel(cellNode);
    Element cellElement = dataSourceDataSupplier.getItem(cellCoords.getRow());
    int colspan = colspanExtractor.extract(cellElement);

    addCellToTableAndFormat(cellCoords, colspan, cellPanel, cellElement);
}
 
Example 32
Project: empiria.player   File: ReportTableGenerator.java   View source code 5 votes vote down vote up
private void addCellToTableAndFormat(CellCoords cellCoords, int colspan, Panel cellPanel, Element element) {
    table.setWidget(cellCoords.getRow(), cellCoords.getCol(), cellPanel);
    table.getFlexCellFormatter().setColSpan(cellCoords.getRow(), cellCoords.getCol(), colspan);
    rowStylesAppender.append(table, cellCoords);

    if (element != null) {
        String className = XMLUtils.getAttributeAsString(element, CLASS);
        if (className != null && !className.isEmpty()) {
            table.getRowFormatter().addStyleName(cellCoords.getRow(), className);
        }
    }
}
 
Example 33
Project: empiria.player   File: ReportTableGenerator.java   View source code 5 votes vote down vote up
private void generatePageCell(CellCoords cellCoords, Node cellNode, int pageRowIndex) {
    boolean deepCloning = true;
    Element cellElement = (Element) cellNode.cloneNode(deepCloning);
    int colspan = colspanExtractor.extract(cellElement);

    itemIndexAppender.appendToLinkTags(pageRowIndex, cellElement);
    itemIndexAppender.appendToInfoTags(pageRowIndex, cellElement);

    Panel cellPanel = prepareCellPanel(cellElement);
    Element element = dataSourceDataSupplier.getItem(pageRowIndex);
    addCellToTableAndFormat(cellCoords, colspan, cellPanel, element);

    table.getRowFormatter().addStyleName(cellCoords.getRow(), PAGE_ROW_STYLE_PREFIX + String.valueOf(pageRowIndex));
}
 
Example 34
Project: empiria.player   File: SelectionModuleViewImplTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
    gridGenerator = mock(SelectionElementGenerator.class);

    selectionView = new SelectionModuleViewImpl(gridGenerator);

    selectionView.selectionGrid = grid = mock(Grid.class);
    selectionView.mainPanel = panel = mock(Panel.class);
    selectionView.promptWidget = mock(Widget.class);
    clickHandler = mock(ClickHandler.class);
    firstButtonGridElement = mock(SelectionButtonGridElementImpl.class);
    secondButtonGridElement = mock(SelectionButtonGridElementImpl.class);
}
 
Example 35
Project: unitimes   File: UniTimeWidget.java   View source code 5 votes vote down vote up
@Deprecated
public void clear() {
	if (getWidget() instanceof ListBox)
		((ListBox)getWidget()).clear();
	if (getWidget() instanceof Panel)
		((Panel)getWidget()).clear();
}
 
Example 36
Project: optashift-employee-rostering   File: Calendar.java   View source code 5 votes vote down vote up
public Builder(Panel container, Integer tenantId, TranslationService translator) {
    this.container = container;
    this.tenantId = tenantId;
    this.translator = translator;

    dataProvider = null;
    groupProvider = null;
    instanceCreator = null;
    startAt = null;
    dateDisplay = DateDisplay.WEEK_STARTING;
}
 
Example 37
Project: appinventor-extensions   File: GalleryPage.java   View source code 5 votes vote down vote up
/**
 * Helper method to update the app image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateAppImage(String url, final Panel container) {
    image = new Image();
    image.addStyleName("app-image");
    image.setUrl(url);
    // if the user has provided a gallery app image, we'll load it. But if not
    // the error will occur and we'll load default image
    image.addErrorHandler(new ErrorHandler() {
      public void onError(ErrorEvent event) {
        image.setUrl(GalleryApp.DEFAULTGALLERYIMAGE);
      }
    });
    container.add(image);

    if(gallery.getSystemEnvironment() != null &&
        gallery.getSystemEnvironment().toString().equals("Development")){
      final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
        // failure message
        MESSAGES.galleryError()) {
          @Override
          public void onSuccess(String newUrl) {
            image.setUrl(newUrl + "?" + System.currentTimeMillis());
          }
        };
      Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
    }
}
 
Example 38
Project: appinventor-extensions   File: GalleryPage.java   View source code 5 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's stats fields
 * @param container   The container that stats fields reside
 */
private void initAppStats(Panel container) {
  // Images for stats data
  Image numDownloads = new Image();
  numDownloads.setUrl(DOWNLOAD_ICON_URL);
  Image numLikes = new Image();
  numLikes.setUrl(HOLLOW_HEART_ICON_URL);

  // Add stats data
  container.addStyleName("app-stats");
  container.add(numDownloads);
  container.add(new Label(Integer.toString(app.getDownloads())));
  // Adds dynamic like
  initLikeSection(container);
  // Adds dynamic feature
  initFeatureSection(container);
  // Adds dynamic tutorial
  initTutorialSection(container);
  // Adds dynamic salvage
  initSalvageSection(container);

  // We are not using views and comments at initial launch
  /*
  Image numViews = new Image();
  numViews.setUrl(NUM_VIEW_ICON_URL);
  Image numComments = new Image();
  numComments.setUrl(NUM_COMMENT_ICON_URL);
  container.add(numViews);
  container.add(new Label(Integer.toString(app.getViews())));
  container.add(numComments);
  container.add(new Label(Integer.toString(app.getComments())));
  */
}
 
Example 39
Project: appinventor-extensions   File: ProfilePage.java   View source code 5 votes vote down vote up
/**
 * Helper method to update the user's image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateUserImage(final String url, Panel container) {
  userAvatar = new Image();
  //setUrl if the new URL is the same one as it was before; an easy workaround is
  //to make the URL unique so it forces the browser to reload
  userAvatar.setUrl(url + "?" + System.currentTimeMillis());
  userAvatar.addStyleName("app-image");
  if (profileStatus == PRIVATE) {
    //userAvatar.addStyleName("status-updating");
  }
  // if the user has provided a gallery app image, we'll load it. But if not
  // the error will occur and we'll load default image
  userAvatar.addErrorHandler(new ErrorHandler() {
    public void onError(ErrorEvent event) {
      userAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE);
    }
  });
  container.add(userAvatar);

  if(gallery.getSystemEnvironment() != null &&
      gallery.getSystemEnvironment().toString().equals("Development")){
    final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(String newUrl) {
          userAvatar.setUrl(newUrl + "?" + System.currentTimeMillis());
        }
      };
    Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
  }
}
 
Example 40
Project: cuba   File: CubaTreeTableWidget.java   View source code 5 votes vote down vote up
@Override
protected Element getElementTdOrTr(Element eventTarget) {
    Widget widget = WidgetUtil.findWidget(eventTarget, null);
    Widget targetWidget = widget;

    if (widget != this) {
        /*
         * This is a workaround to make Labels, read only TextFields
         * and Embedded in a Table clickable (see #2688). It is
         * really not a fix as it does not work with a custom read
         * only components (not extending VLabel/VEmbedded).
         */
        while (widget != null && widget.getParent() != this) {
            widget = widget.getParent();
        }

        if (!(widget instanceof VLabel)
                && !(widget instanceof VEmbedded)
                && !(widget instanceof VTextField && ((VTextField) widget).isReadOnly())
                && !(targetWidget instanceof VLabel)
                && !(targetWidget instanceof Panel)
                && !(targetWidget instanceof VEmbedded)
                && !(widget instanceof CubaImageWidget)
                && !(targetWidget instanceof VTextField && ((VTextField) targetWidget).isReadOnly())) {
            return null;
        }
    }
    return getTdOrTr(eventTarget);
}