Java Code Examples for com.google.gwt.dom.client.Style.Unit

The following are top voted examples for showing how to use com.google.gwt.dom.client.Style.Unit. 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: empiria.player   File: LabelledImgContent.java   View source code 6 votes vote down vote up
private void alignWidget(Widget widget, Point anchorPoint, String horizontalAlign, String verticalAlign) {
    Style style = widget.getElement().getStyle();
    double xPos = anchorPoint.getX();
    double yPos = anchorPoint.getY();

    if ("center".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth() / 2;
    } else if ("right".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth();
    }

    if ("center".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight() / 2;
    } else if ("bottom".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight();
    }

    style.setPosition(Position.ABSOLUTE);
    style.setTop(yPos, Unit.PX);
    style.setLeft(xPos, Unit.PX);
}
 
Example 2
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 3
Project: empiria.player   File: PanelCache.java   View source code 6 votes vote down vote up
@Override
protected KeyValue<FlowPanel, FlowPanel> getElement(Integer index) {
    parent = panelFactory.getFlowPanel();
    FlowPanel childPanel = panelFactory.getFlowPanel();

    Style style = parent.getElement().getStyle();
    parent.getElement().setId(styleNames.QP_PAGE() + index.intValue());

    if (swipeType != SwipeType.DISABLED) {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(WIDTH * index, Unit.PCT);
        style.setWidth(WIDTH, Unit.PCT);
    }

    childPanel.setHeight("100%");
    childPanel.setWidth("100%");
    parent.add(childPanel);
    return new KeyValue<FlowPanel, FlowPanel>(parent, childPanel);
}
 
Example 4
Project: empiria.player   File: MultiPageView.java   View source code 6 votes vote down vote up
public void setSwipeDisabled(boolean swipeDisabled) {
    Style style = controller.getStyle();
    Style elementStyle = getElement().getStyle();

    style.setWidth(controller.getWidth(), Unit.PCT);

    if (swipeDisabled) {
        style.clearPosition();
        style.clearTop();
        style.clearLeft();
        elementStyle.clearPosition();
    } else {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(0, Unit.PX);
        elementStyle.setPosition(Position.RELATIVE);
    }

    setSwipeLength();
}
 
Example 5
Project: empiria.player   File: MultiPageController.java   View source code 6 votes vote down vote up
@Override
public void move(boolean swipeRight, float length) {
    if (!focusDropped && UserAgentChecker.isStackAndroidBrowser()) {
        dropFocus();
    }
    if (swipeRight) {
        showProgressBarForPage(currentVisiblePage + 1);
    } else {
        showProgressBarForPage(currentVisiblePage - 1);
    }
    Style style = getStyle();
    float position = getPositionLeft();
    if (swipeRight) {
        style.setLeft(position - length, Unit.PCT);
    } else {
        style.setLeft(position + length, Unit.PCT);
    }
}
 
Example 6
Project: EasyML   File: RegisterView.java   View source code 6 votes vote down vote up
public RegisterView() {
	initWidget(ourUiBinder.createAndBindUi(this));

	register.setText( Constants.registerUIMsg.register() );
	registerUsr.setText( Constants.registerUIMsg.registerUsr() );
	registerPwd.setText( Constants.registerUIMsg.registerPwd() );
	registerVer.setText( Constants.registerUIMsg.registerVer() );
	registerCmp.setText( Constants.registerUIMsg.registerCmp() );
	registerPst.setText( Constants.registerUIMsg.registerPst() );

	confirmBtn.removeStyleName("gwt-Button");
	confirmBtn.setText( Constants.registerUIMsg.confirm() );
	confirmBtn.getElement().getStyle().setMarginLeft(100, Unit.PX);
	confirmBtn.getElement().getStyle().setMarginTop(50, Unit.PX);
	confirmBtn.getElement().getStyle().setMarginBottom(100, Unit.PX);
}
 
Example 7
Project: unitimes   File: TeachingAssignmentsWidget.java   View source code 6 votes vote down vote up
public TeachingAssignmentsWidget() {
	iHeader = new UniTimeHeaderPanel(MESSAGES.sectTeachingAssignments());
	iHeader.addCollapsibleHandler(new ValueChangeHandler<Boolean>() {
		@Override
		public void onValueChange(ValueChangeEvent<Boolean> event) {
			InstructorCookie.getInstance().setShowTeachingAssignments(event.getValue());
			if (iTable != null) {
				iTable.setVisible(event.getValue());
			} else if (event.getValue()) {
				refresh();
			}
		}
	});
	iHeader.setCollapsible(InstructorCookie.getInstance().isShowTeachingAssignments());
	iHeader.setTitleStyleName("unitime3-HeaderTitle");
	removeStyleName("unitime-NotPrintableBottomLine");
	
	addHeaderRow(iHeader);
	iHeader.getElement().getStyle().setMarginTop(10, Unit.PX);
}
 
Example 8
Project: unitimes   File: UniTimeHeaderPanel.java   View source code 6 votes vote down vote up
private Button addButton(String operation, String name, Character accessKey, String width, ClickHandler clickHandler) {
	Button button = new AriaButton(name);
	button.addClickHandler(clickHandler);
	ToolBox.setWhiteSpace(button.getElement().getStyle(), "nowrap");
	if (accessKey != null)
		button.setAccessKey(accessKey);
	if (width != null)
		ToolBox.setMinWidth(button.getElement().getStyle(), width);
	iOperations.put(operation, iButtons.getWidgetCount());
	iClickHandlers.put(operation, clickHandler);
	iButtons.add(button);
	button.getElement().getStyle().setMarginLeft(4, Unit.PX);
	for (UniTimeHeaderPanel clone: iClones) {
		Button clonedButton = clone.addButton(operation, name, null, width, clickHandler);
		clonedButton.addKeyDownHandler(iKeyDownHandler);
	}
	button.addKeyDownHandler(iKeyDownHandler);
	return button;
}
 
Example 9
Project: unitimes   File: WebTable.java   View source code 6 votes vote down vote up
public IconCell(ImageResource resource, final String title, String text) {
	super(null);
	iIcon = new Image(resource);
	iIcon.setTitle(title);
	iIcon.setAltText(title);
	if (text != null && !text.isEmpty()) {
		iLabel = new HTML(text, false);
		iPanel = new HorizontalPanel();
		iPanel.setStyleName("icon");
		iPanel.add(iIcon);
		iPanel.add(iLabel);
		iIcon.getElement().getStyle().setPaddingRight(3, Unit.PX);
		iPanel.setCellVerticalAlignment(iIcon, HasVerticalAlignment.ALIGN_MIDDLE);
	}
	iIcon.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			event.stopPropagation();
			UniTimeConfirmationDialog.info(title);
		}
	});
}
 
Example 10
Project: unitimes   File: WebTable.java   View source code 6 votes vote down vote up
public IconsCell add(ImageResource resource, final String title) {
	if (resource == null) return this;
	Image icon = new Image(resource);
	icon.setTitle(title);
	icon.setAltText(title);
	if (iPanel.getWidgetCount() > 0)
		icon.getElement().getStyle().setPaddingLeft(3, Unit.PX);
	iPanel.add(icon);
	iPanel.setCellVerticalAlignment(icon, HasVerticalAlignment.ALIGN_MIDDLE);
	if (title != null && !title.isEmpty()) {
		icon.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				event.stopPropagation();
				UniTimeConfirmationDialog.info(title);
			}
		});
	}
	return this;
}
 
Example 11
Project: unitimes   File: FilterBox.java   View source code 6 votes vote down vote up
protected void resizeFilterIfNeeded() {
	if (!isAttached()) return;
	ChipPanel last = getLastChipPanel();
	iFilterOpen.setVisible(isEnabled() && !isFilterPopupShowing());
	iFilterClear.setVisible(isEnabled() && (!iFilter.getText().isEmpty() || last != null));
	int buttonWidth = (isFilterPopupShowing() ? iFilterClose : iFilterOpen).getElement().getOffsetWidth() + iFilterClear.getElement().getOffsetWidth() + 8;
	if (last != null) {
		int width = getAbsoluteLeft() + getOffsetWidth() - last.getAbsoluteLeft() - last.getOffsetWidth() - buttonWidth;
		if (width < 100)
			width = getElement().getClientWidth() - buttonWidth;
		iFilter.getElement().getStyle().setWidth(width, Unit.PX);
	} else {
		iFilter.getElement().getStyle().setWidth(getElement().getClientWidth() - buttonWidth, Unit.PX);
	}
	if (isSuggestionsShowing())
		iSuggestionsPopup.moveRelativeTo(this);
	if (isFilterPopupShowing())
		iFilterPopup.moveRelativeTo(this);
}
 
Example 12
Project: unitimes   File: TimeGrid.java   View source code 6 votes vote down vote up
public void move() {
       switch (iMode) {
       case PROPORTIONAL:
        iWidth = Math.max(3, iNrMeetings * (iCellWidth - 6.0) / iTotalNrColumns + (iColumn + iNrMeetings != iTotalNrColumns && iTotalNrColumns > 1 ? -3 : 0));
        iLeft = 4.0 + iCellWidth * getDay() + iColumn * (iCellWidth - 6.0) / iTotalNrColumns;
        break;
       case FILLSPACE:
        iWidth = (iCellWidth - 6.0) / iNrColumns + (iColumn + 1 != iNrColumns && iNrColumns > 1 ? -3 : 0);
        iLeft = 4.0 + iCellWidth * getDay() + iColumn * (iCellWidth - 6) / iNrColumns;
        break;
       case OVERLAP:
       	int weeks = (isVerticalSplitByWeek() ? iSelectedWeeks.size() : iRoomResources.size());
       	iWidth = iNrMeetings * (iCellWidth - 6.0) / weeks + (iColumn + iNrMeetings != weeks && weeks > 1 ? -3 : 0) - 5 * iNrColumns;
       	iLeft = 4.0 + iCellWidth * getDay() + iColumn * (iCellWidth - 6) / weeks + 5 * iNrColumns;
       }
	getElement().getStyle().setWidth(iWidth, Unit.PX);
	getElement().getStyle().setLeft(iLeft, Unit.PX);
	if (hasShadow()) {
		iShadow.getElement().getStyle().setWidth(iWidth, Unit.PX);
		iShadow.getElement().getStyle().setLeft(iLeft, Unit.PX);
	}
}
 
Example 13
Project: unitimes   File: TimeGrid.java   View source code 6 votes vote down vote up
public SelectionPanel(boolean fixed) {
	setStyleName(fixed ? "selection" : "active-selection");
	if (fixed) {
		iRemove = new P("x"); iRemove.setHTML("&times;");
		iRemove.addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				iSelections.remove(SelectionPanel.this);
				if (iSelection != null)
					iAllSelections.remove(iSelection);
			}
		});
		iRemove.getElement().getStyle().setRight(2, Unit.PX);
		iRemove.getElement().getStyle().setTop(2, Unit.PX);
		iRemove.getElement().getStyle().setPosition(Position.ABSOLUTE);
		add(iRemove);
		iText = new P("text");
		add(iText, 0, 0);
	}
	
	sinkEvents(Event.ONMOUSEDOWN);
	sinkEvents(Event.ONMOUSEUP);
	sinkEvents(Event.ONMOUSEMOVE);
}
 
Example 14
Project: unitimes   File: TimeGrid.java   View source code 6 votes vote down vote up
private void move() {
       getElement().getStyle().setWidth(getWidth(), Unit.PX);
       getElement().getStyle().setLeft(getLeft(), Unit.PX);
       getElement().getStyle().setTop(getTop(), Unit.PX);
       getElement().getStyle().setHeight(getHeight(), Unit.PX);
       if (iText != null)
       	iText.setHTML(
       		(iDayOfWeeks == null ? CONSTANTS.days()[getFirstDayOfWeek()] : iDayOfWeeks.get(getFirstDayOfWeek())) + " " +
       		(isSingleRoom() ?
       			iSelectedWeeks.get(getStartWeek()).getDayNames().get(getFirstDayOfWeek()) + (getNrWeeks() <= 1 ? "" : "&nbsp;&#8209;&nbsp;" + iSelectedWeeks.get(getEndWeek()).getDayNames().get(getLastDayOfWeek())) :
       			iSelectedWeeks.get(0).getDayNames().get(getFirstDayOfWeek())) + " " +
       		(isSingleRoom() && isSingleWeek() && getNrDays() > 1 ?
       				" - " + (iDayOfWeeks == null ? CONSTANTS.days()[getLastDayOfWeek()] : iDayOfWeeks.get(getLastDayOfWeek())) + " " + iSelectedWeeks.get(getStartWeek()).getDayNames().get(getLastDayOfWeek()) + " " : "") +
       		getStartTime() + "&nbsp;&#8209;&nbsp;" + getEndTime() + " (" + (5 * getLength()) + "&nbsp;mins) " +
       		(isSingleRoom() ? iRoomResources.get(0).getName().replace(" ", "&nbsp;") :
       			iRoomResources.get(getStartWeek()).getName().replace(" ", "&nbsp;") + (getNrWeeks() <= 1 ? "" : "&nbsp;&#8209;&nbsp;" + iRoomResources.get(getEndWeek()).getName().replace(" ", "&nbsp;")))
       		);
}
 
Example 15
Project: unitimes   File: AddMeetingsDialog.java   View source code 6 votes vote down vote up
public void recenter() {
	GwtHint.getInstance().hide();
	
	iScrollRooms.getElement().getStyle().clearHeight();
	if (getElement().getClientHeight() > Window.getClientHeight() - 100)
		iScrollRooms.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);
	
	iScrollDates.getElement().getStyle().clearHeight();
	if (getElement().getClientHeight() > Window.getClientHeight() - 100) {
		iScrollDates.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);
	}

	int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
	setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max( Window.getScrollTop() + top, 0));
}
 
Example 16
Project: unitimes   File: TimeGrid.java   View source code 6 votes vote down vote up
public BusyPanel(String text, int dayOfWeek, int startSlot, int length) {
	super();
	iText = text;
	iDayOfWeek = dayOfWeek;
	iStartSlot = startSlot;
	iLength = length;
	if (iText != null || !iText.isEmpty()) {
		setTitle(iText);
		boolean empty = true;
		for (int i = 0; i < 3; i++) {
			if (iMeetingTable[iDayOfWeek].length <= iStartSlot + i) { empty = false; break; }
			if (iMeetingTable[iDayOfWeek][iStartSlot + i] != null && !iMeetingTable[iDayOfWeek][iStartSlot + i].isEmpty()) {
				empty = false; break;
			}
		}
		if (empty) {
			HTML widget = new HTML(text, false);
			widget.setStyleName("text");
			setWidget(widget);
		}
	}
	setStyleName("busy");
	getElement().getStyle().setWidth(iCellWidth + (iPrint ? 3 : iDayOfWeek + 1 < iNrDays ? 3 : 0), Unit.PX);
	getElement().getStyle().setHeight(125 * iLength / 30, Unit.PX);
	iGrid.insert(this, iCellWidth * iDayOfWeek, 125 * iStartSlot / 30 - 50 * iStart, 1);
}
 
Example 17
Project: calendar-component   File: DateCellDayItem.java   View source code 6 votes vote down vote up
public void updatePosition(long startFromMinutes, long durationInMinutes) {
    if (startFromMinutes < 0) {
        startFromMinutes = 0;
    }
    top = weekGrid.getPixelTopFor((int) startFromMinutes);

    getElement().getStyle().setTop(top, Unit.PX);
    if (durationInMinutes > 0) {
        int heightMinutes = weekGrid.getPixelLengthFor(
                (int) startFromMinutes, (int) durationInMinutes);
        setHeight(heightMinutes);
    } else {
        setHeight(-1);
    }

    boolean multiRowCaption = (durationInMinutes > 30);
    updateCaptions(multiRowCaption);
}
 
Example 18
Project: calendar-component   File: DateCell.java   View source code 6 votes vote down vote up
public void setToday(Date today, int width) {
    this.today = today;
    addStyleDependentName("today");
    Element lastChild = (Element) getElement().getLastChild();
    if (lastChild.getClassName().equals("v-calendar-current-time")) {
        todaybar = lastChild;
    } else {
        todaybar = DOM.createDiv();
        todaybar.setClassName("v-calendar-current-time");
        getElement().appendChild(todaybar);
    }

    if (width != -1) {
        todaybar.getStyle().setWidth(width, Unit.PX);
    }

    // position is calculated later, when we know the cell heights
}
 
Example 19
Project: essence   File: EssenceFrontEnd.java   View source code 6 votes vote down vote up
private void createDashboard(){
    // Add left panel
    DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
    createMenu(dockPanel);
    createLeftPanelButtons(dockPanel);

    final SplitLayoutPanel mainPanel = new SplitLayoutPanel();

    // Add header
    mainPanel.addNorth(makeHeader(), 40);

    // Add navigation
    mainPanel.addWest(dockPanel, 130);
    
    // Add content
    mainPanel.add(contentPanel);

    setupListener();
    
    RootLayoutPanel.get().add(mainPanel);
    
    setBrowserWindowTitle("ESSENCE");
}
 
Example 20
Project: document-management-system   File: HistorySearch.java   View source code 6 votes vote down vote up
/**
 * HistorySearch
 */
public HistorySearch() {
	stackPanel = new StackLayoutPanel(Unit.PX);
	searchSaved = new SearchSaved();
	userNews = new UserNews();
	scrollSearchSavedPanel = new ScrollPanel();
	scrollUserNewsSavedPanel = new ScrollPanel();

	scrollSearchSavedPanel.addStyleName("okm-PanelSelected");
	scrollUserNewsSavedPanel.addStyleName("okm-PanelSelected");

	scrollSearchSavedPanel.add(searchSaved);
	scrollSearchSavedPanel.setSize("100%", "100%");

	scrollUserNewsSavedPanel.add(userNews);
	scrollUserNewsSavedPanel.setSize("100%", "100%");

	stackPanel.add(scrollSearchSavedPanel, Util.createHeaderHTML("img/icon/stackpanel/find.gif", Main.i18n("leftpanel.label.stored.search")), true, 22);
	stackPanel.add(scrollUserNewsSavedPanel, Util.createHeaderHTML("img/icon/news.gif", Main.i18n("leftpanel.label.user.search")), true, 22);

	stackPanel.showWidget(0);
	stackPanel.setStyleName("okm-StackPanel");
	stackPanel.addStyleName("okm-DisableSelect");
	initWidget(stackPanel);
}
 
Example 21
Project: document-management-system   File: ExtendedDockPanel.java   View source code 6 votes vote down vote up
/**
 * SetWidgetsSize
 */
private void setWidgetsSize() {
	// Calculating real height
	usableHeight = Window.getClientHeight();
	if (Main.get().hasHeaderCustomization) {
		usableHeight -= 72;
		RootLayoutPanel.get().setWidgetTopBottom(Main.get().mainPanel, 72, Style.Unit.PX, 0, Style.Unit.PX);
	}

	// Initialize dockPanel size
	dockPanel.setSize("" + Window.getClientWidth() + "px", "" + usableHeight + "px");

	// The active panel must be the last on initalization because establishes coordenates
	leftBorderPanel.setSize(VERTICAL_BORDER_PANEL_WIDTH, usableHeight - (TopPanel.PANEL_HEIGHT + BottomPanel.PANEL_HEIGHT));
	rightBorderPanel.setSize(VERTICAL_BORDER_PANEL_WIDTH, usableHeight - (TopPanel.PANEL_HEIGHT + BottomPanel.PANEL_HEIGHT));

	centerWidth = Window.getClientWidth() - (2 * VERTICAL_BORDER_PANEL_WIDTH);
	centerHeight = usableHeight - (TopPanel.PANEL_HEIGHT + BottomPanel.PANEL_HEIGHT);

	topPanel.setWidth("" + Window.getClientWidth() + "px");
	desktop.setSize(centerWidth, centerHeight);
	search.setSize(centerWidth, centerHeight);
	dashboard.setSize(centerWidth, centerHeight);
	administration.setSize(centerWidth, centerHeight);
}
 
Example 22
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 23
Project: Wiab.pro   File: CursorDisplay.java   View source code 6 votes vote down vote up
@Override
public void onUpdate(EditorUpdateEvent event) {
  OffsetPosition p = NativeSelectionUtil.slowGetPosition();
  if (p != null) {
    EditorStaticDeps.logger.trace().log("x: " + p.left + "y: " + p.top);

    if (p.offsetParent == null) {
      // If offsetParent is null, interpret offsetX and offsetY as
      // absolute positions
      if (DEBUG_CURSOR.getParentElement() != Document.get().getBody()) {
        Document.get().getBody().appendChild(DEBUG_CURSOR);
      }
      DEBUG_CURSOR.getStyle().setTop(p.top - Document.get().getBody().getAbsoluteTop(), Unit.PX);
      DEBUG_CURSOR.getStyle().setLeft(p.left - Document.get().getBody().getAbsoluteLeft(),
                                      Unit.PX);
    } else {
      if (editorImpl.getElement() != null
          && DEBUG_CURSOR.getParentElement() != editorImpl.getElement()) {
        editorImpl.getElement().appendChild(DEBUG_CURSOR);
      }
      DEBUG_CURSOR.getStyle().setTop(p.top, Unit.PX);
      DEBUG_CURSOR.getStyle().setLeft(p.left, Unit.PX);
    }
  }
}
 
Example 24
Project: Wiab.pro   File: CenterPopupPositioner.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setPopupPositionAndMakeVisible(final Element relative, final Element p) {
  ScheduleCommand.addCommand(new Scheduler.Task() {
    @Override
    public void execute() {
      p.getStyle().setLeft(relative.getAbsoluteLeft() + (relative.getOffsetWidth() - p.getOffsetWidth()) / 2, Unit.PX);
      int height = PositionUtil.boundHeightToScreen(p.getOffsetHeight());
      int top = relative.getAbsoluteTop() + (relative.getOffsetHeight() - height) / 2;
      // Prevent negative top position.
      p.getStyle().setTop(Math.max(top, MIN_OFFSET_HEIGHT_DEFAULT), Unit.PX);
      p.getStyle().setHeight(height, Unit.PX);
      p.getStyle().setVisibility(Visibility.VISIBLE);
    }
  });
}
 
Example 25
Project: djvu-html5   File: Scrollbar.java   View source code 6 votes vote down vote up
public void setThumb(double center, double width) {
	Style style = getElement().getStyle();
	if (width >= 1) {
		style.setVisibility(Visibility.HIDDEN);
		return;
	} else {
		style.setVisibility(Visibility.VISIBLE);
	}
	if (isHorizontal) {
		style.setLeft(100 * (center - width / 2), Unit.PCT);
		style.setRight(100 * (1 - center - width / 2), Unit.PCT);
	} else {
		style.setTop(100.0 * (center - width / 2), Unit.PCT);
		style.setBottom(100 * (1 - center - width / 2), Unit.PCT);
	}
}
 
Example 26
Project: ephesoft   File: FolderManagementView.java   View source code 6 votes vote down vote up
public void setInitialFolderManagementView(FolderManagementController controller, String parentFolderPath, String baseFolderUrl,
		Map<String, String> batchClassesMap) {
	Label footer = new Label();
	folderTableView = new FolderTableView(footer);

	folderTablePresenter = new FolderTablePresenter(controller, folderTableView, parentFolderPath, baseFolderUrl);

	folderSystemTreeView = new FolderSystemTreeView();

	folderSystemTreePresenter = new FolderSystemTreePresenter(controller, folderSystemTreeView, parentFolderPath, footer);

	SplitLayoutPanel mainContentPanel = new SplitLayoutPanel();
	DockLayoutPanel leftLayoutPanel = new DockLayoutPanel(Unit.PCT);
	ScrollPanel treeScrollPanel = new ScrollPanel();
	treeScrollPanel.add(folderSystemTreeView);
	FolderSelectionWidget folderSelectionWidget = new FolderSelectionWidget(batchClassesMap, controller.getEventBus());
	leftLayoutPanel.addNorth(folderSelectionWidget, 10);
	leftLayoutPanel.add(treeScrollPanel);
	mainContentPanel.addWest(leftLayoutPanel, 200);
	DockLayoutPanel contentMainPanel = new DockLayoutPanel(Unit.PCT);
	contentMainPanel.add(folderTableView);
	contentMainPanel.addStyleName(FolderManagementConstants.WHITE_BACKGROUND);
	mainContentPanel.add(contentMainPanel);
	mainPanel.add(mainContentPanel);
	ScreenMaskUtility.unmaskScreen();
}
 
Example 27
Project: teiid-webui   File: DataSourceNamesTable.java   View source code 6 votes vote down vote up
/**
 * Create the panel
 * @return the panel widget
 */
protected Widget createTablePanel() {
	table = new SimpleTable<String>(TABLE_HEIGHT_PX,TABLE_WIDTH_PX,TABLE_VISIBLE_ROWS);
	
    // --------------
	// Name Column
	// --------------
    TextColumn<String> nameColumn = new TextColumn<String>() {
        public String getValue( String row ) {
            return row;
        }
    };
    table.addColumn( nameColumn, COLUMN_HEADER_NAME );
    table.setColumnWidth(nameColumn, 200, Unit.PX);
    
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.add(table);
    return verticalPanel;
}
 
Example 28
Project: appformer   File: WorkbenchLayoutImpl.java   View source code 6 votes vote down vote up
private void updateMaximizedPanelSizes() {
    for (Widget w : maximizedWidgetOriginalStyles.keySet()) {
        Style style = w.getElement().getStyle();
        style.setTop(perspectiveRootContainer.getAbsoluteTop(),
                     Unit.PX);
        style.setLeft(perspectiveRootContainer.getAbsoluteLeft(),
                      Unit.PX);
        style.setWidth(perspectiveRootContainer.getOffsetWidth(),
                       Unit.PX);
        style.setHeight(perspectiveRootContainer.getOffsetHeight(),
                        Unit.PX);

        if (w instanceof RequiresResize) {
            ((RequiresResize) w).onResize();
        }
    }
}
 
Example 29
Project: sandbox-frame   File: ProjectViewImpl.java   View source code 6 votes vote down vote up
@Override
public void setFeatures(List<Feature> features) {
    for (int i=0;i<features.size();i++) {
        Feature feature = features.get(i);
        Image image = new Image(Utils.getFeatureIcon(feature));
        image.setTitle(Utils.getFeatureText(feature));
        image.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
        Label label = new Label(Utils.getFeatureText(feature));
        featuresPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        featuresPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        featuresPanel.add(image);
        featuresPanel.setCellWidth(image, "32px");
        featuresPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
        featuresPanel.add(label);
        if (i < features.size()-1) {
            label.getElement().getStyle().setPaddingRight(10, Unit.PX);
        }
        label.getElement().getStyle().setPaddingLeft(8, Unit.PX);
        
    }
}
 
Example 30
Project: sandbox-frame   File: ProjectBundleViewImpl.java   View source code 6 votes vote down vote up
@Override
public void setSdkLanguages(List<SdkLanguage> sdkLanguages) {
       for (int i=0;i<sdkLanguages.size();i++) {
       	SdkLanguage sdkLanguage  = sdkLanguages.get(i);
           Image image = new Image(Utils.getSdkLanguageIcon(sdkLanguage));
           image.setTitle(Utils.getSdkLanguageText(sdkLanguage));
           image.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
           Label label = new Label(Utils.getSdkLanguageText(sdkLanguage));
           sdkLanguagesPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
           sdkLanguagesPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
           sdkLanguagesPanel.add(image);
           sdkLanguagesPanel.setCellWidth(image, "32px");
           sdkLanguagesPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
           sdkLanguagesPanel.add(label);
           if (i < sdkLanguages.size()-1) {
               label.getElement().getStyle().setPaddingRight(10, Unit.PX);
           }
           label.getElement().getStyle().setPaddingLeft(8, Unit.PX);
       }
}
 
Example 31
Project: sandbox-frame   File: ProjectBundleViewImpl.java   View source code 6 votes vote down vote up
@Override
public void setPlatforms(List<Platform> platforms) {
    for (int i=0;i<platforms.size();i++) {
    	Platform platform  = platforms.get(i);
        Image image = new Image(Utils.getPlatformIcon(platform));
        image.setTitle(Utils.getPlatformText(platform));
        image.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
        Label label = new Label(Utils.getPlatformText(platform));
        platformsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        platformsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        platformsPanel.add(image);
        platformsPanel.setCellWidth(image, "32px");
        platformsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
        platformsPanel.add(label);
        if (i < platforms.size()-1) {
            label.getElement().getStyle().setPaddingRight(10, Unit.PX);
        }
        label.getElement().getStyle().setPaddingLeft(8, Unit.PX);
    }
}
 
Example 32
Project: sandbox-frame   File: ProjectBundleViewImpl.java   View source code 6 votes vote down vote up
@Override
public void setFeatures(List<Feature> features) {
    for (int i=0;i<features.size();i++) {
        Feature feature = features.get(i);
        Image image = new Image(Utils.getFeatureIcon(feature));
        image.setTitle(Utils.getFeatureText(feature));
        image.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
        Label label = new Label(Utils.getFeatureText(feature));
        featuresPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        featuresPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        featuresPanel.add(image);
        featuresPanel.setCellWidth(image, "32px");
        featuresPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
        featuresPanel.add(label);
        if (i < features.size()-1) {
            label.getElement().getStyle().setPaddingRight(10, Unit.PX);
        }
        label.getElement().getStyle().setPaddingLeft(8, Unit.PX);
        
    }
}
 
Example 33
Project: sandbox-frame   File: DemoProjectWidget.java   View source code 6 votes vote down vote up
private void animate(double baseOpacity, double targetOpacity, double baseMargin,
        double targetMargin, int duration) {
    this.baseOpacity = baseOpacity;
    this.targetOpacity = targetOpacity;
    this.baseMargin = baseMargin;
    this.targetMargin = targetMargin;
    widget.getElement().getStyle().setOpacity(this.baseOpacity);
    widget.getElement().getStyle()
            .setMarginRight(this.baseMargin, Unit.PX);
    this.opacityIncrement = this.targetOpacity - this.baseOpacity;
    this.marginIncrement = this.targetMargin - this.baseMargin;
    if (duration > 0) {
        run(duration);
    } else {
        onComplete();
    }
}
 
Example 34
Project: gwt-material   File: MaterialToast.java   View source code 6 votes vote down vote up
/**
 * @param msg        Message text for your toast.
 * @param lifeMillis how long it should present itself before being removed.
 * @param className  class name to custom style your toast.
 */
public void toast(String msg, int lifeMillis, String className) {
    String genId = DOM.createUniqueId();
    if (className == null) {
        className = genId;
    } else {
        className += ' ' + genId;
    }
    toast(msg, lifeMillis, genId, className, callback);

    if (widgets != null) {
        for (Widget widget : widgets) {
            widget.getElement().getStyle().setPaddingLeft(30, Unit.PX);
            RootPanel.get(genId).add(widget);
        }
    }
}
 
Example 35
Project: gwt-material   File: MaterialSwitch.java   View source code 6 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    label.add(offLabel);
    label.add(input);
    label.add(span);
    add(label);
    add(errorLabel);
    errorLabel.getElement().getStyle().setMarginTop(16, Unit.PX);
    label.add(onLabel);

    // Register click handler here in order to have it at first position
    // and therefore it will deal with clicks as first and setup the value
    // right before others get notified.
    registerHandler(addClickHandler(event -> {
        event.preventDefault();
        event.stopPropagation();
    }));

    registerHandler(addClickHandler(event -> setValue(!getValue(), true)));
}
 
Example 36
Project: che   File: StatusBarBranchPointer.java   View source code 6 votes vote down vote up
@Override
public void update(ActionEvent e) {
  panel.clear();

  Project project = appContext.getRootProject();
  if (project != null && project.getAttributes().containsKey(GIT_CURRENT_HEAD_NAME)) {
    Label projectNameLabel = new Label(project.getName());
    projectNameLabel.ensureDebugId("statusBarProjectBranchRepositoryName");
    projectNameLabel.getElement().getStyle().setMarginLeft(5., Unit.PX);
    panel.add(projectNameLabel);

    SVGImage branchIcon = new SVGImage(resources.checkoutReference());
    branchIcon.getSvgElement().getStyle().setMarginLeft(5., Unit.PX);
    panel.add(branchIcon);

    Label headLabel = new Label(project.getAttribute(GIT_CURRENT_HEAD_NAME));
    headLabel.ensureDebugId("statusBarProjectBranchName");
    headLabel.setTitle(constant.branchesControlTitle());
    Style headLabelStyle = headLabel.getElement().getStyle();
    headLabelStyle.setCursor(Cursor.POINTER);
    headLabelStyle.setMarginLeft(5., Unit.PX);
    headLabel.addClickHandler(event -> branchPresenter.showBranches(project));
    panel.add(headLabel);
  }
}
 
Example 37
Project: riscoss-corporate   File: WaitWidget.java   View source code 6 votes vote down vote up
public void show() {
		this.panel.setPopupPositionAndShow( new PositionCallback(){
			@Override
			public void setPosition( int offsetWidth, int offsetHeight )
			{
				
				panel.getElement().getStyle().setPosition( Position.FIXED );
				panel.getElement().getStyle().setTop( 0, Unit.PX );
//				panel.getElement().getStyle().setLeft( 0, Unit.PX );
//				panel.getElement().getStyle().setBottom( 0, Unit.PX );
				panel.getElement().getStyle().setRight( 0, Unit.PX );
				panel.getElement().getStyle().setProperty( "left", "" );
				panel.getElement().getStyle().setProperty( "bottom", "" );
				
//				DOM.setStyleAttribute( panel.getElement(), "position", "fixed" );
//				DOM.setStyleAttribute( panel.getElement(), "top", "0" );
//				DOM.setStyleAttribute( panel.getElement(), "left", "" );
//				DOM.setStyleAttribute( panel.getElement(), "bottom", "" );
//				DOM.setStyleAttribute( panel.getElement(), "right", "0px" );
			}
		} );
	}
 
Example 38
Project: riscoss-corporate   File: IndicatorWidget.java   View source code 6 votes vote down vote up
NumberInput( JSONObject o ) {
	sb.setNotSelectedInFocus();
	
	sb.addBarValueChangedHandler( new BarValueChangedHandler() {
		public void onBarValueChanged(BarValueChangedEvent event) {
			label.setText( "" + sb.getValue() );
			for( Listener l : listeners ) {
				l.IndicatorValueChanged();
			}
		}
	});
	
	label.getElement().getStyle().setMarginLeft( 12, Unit.PX );
	
	panel.add( sb );
	panel.add( label );
	
	setValue( o );
}
 
Example 39
Project: ontosoft   File: CategoryPieChart.java   View source code 6 votes vote down vote up
public void updateDimensions() {
  String useragent = getUserAgent();
  // Fix some IE/iOS 7.1 bugs
  if(useragent.contains("msie") ||
      useragent.matches(".*(ipad|iphone);.*cpu.*os 7_\\d.*")) {
    final SimplePanel panel = this;
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
      @Override
      public void execute() {
        int width = panel.getOffsetWidth();
        //GWT.log(width+"px");
        if(width > 0){
          panel.getElement().getStyle().setHeight(width, Unit.PX);
        }
      } 
    });
  }
}
 
Example 40
Project: ontosoft   File: CategoryBarChart.java   View source code 6 votes vote down vote up
public void updateDimensions() { 
  String useragent = getUserAgent();
  if(useragent.matches(".*(ipad|iphone);.*cpu.*os 7_\\d.*")) {
    //GWT.log(useragent);
    final CategoryChartBase panel = this;
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
      @Override
      public void execute() {
        int width = panel.getOffsetWidth();
        if(width > 0) {
          //double height = panel.height * width / panel.width;
          //GWT.log(width+", "+ height);
          panel.getElement().getStyle().setHeight(panel.height, Unit.PX);          
        }
      }
    });
  }
}