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

The following are top voted examples for showing how to use com.google.gwt.user.client.ui.RootPanel. 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: sig-seguimiento-vehiculos   File: PreviewWidget.java   Source Code and License 7 votes vote down vote up
private Frame createFrame() {
	final Frame frame = new Frame(DEFAULT_TEMPLATE_PATH);
	frame.getElement().setId(DEFAULT_FRAME_NAME);
	frame.setTitle(UIMessages.INSTANCE.previewTitle());
	frame.setWidth("500px");
	frame.setHeight("500px");
	frame.getElement().getStyle().setBackgroundColor("gray");

	frame.setVisible(true);
	RootPanel.get().add(frame);

	frame.addLoadHandler(new LoadHandler() {

		@Override
		public void onLoad(LoadEvent event) {
			frame.getElement().getStyle().setBackgroundColor("white");
			zoomPageComboBox.setValue(75);
		}

	});

	return frame;
}
 
Example 2
Project: empiria.player   File: VideoFullScreenHelper.java   Source Code and License 6 votes vote down vote up
protected void openFullscreenIE(MediaWrapper<?> mediaWrapper, Element template) {
    if (mediaWrapper != null && template != null) {
        clearFullScreenView();
        lastMediaWrapper = mediaWrapper;
        VideoFullScreenView parent = getFullScreenView();
        Widget widget = mediaWrapper.getMediaObject();
        parent.getContainer().add(widget);
        resizeToFullScreen(parent.asWidget(), Position.FIXED);
        resizeToFullScreen(widget, Position.ABSOLUTE);
        parseTemplate(mediaWrapper, template, parent.getControls());
        fireEvent(true, mediaWrapper);
        RootPanel.get().add(parent);
        resizeToFullScreen(lastMediaWrapper.getMediaObject(), Position.FIXED);
        resizeToFullScreen(view.asWidget(), Position.FIXED);
        resizeToFullScreen(widget, Position.ABSOLUTE);
    }
}
 
Example 3
Project: empiria.player   File: MultiPageController.java   Source Code and License 6 votes vote down vote up
private void configureSwipe() {
    if (isSwipeDisabled()) {
        for (HandlerRegistration registration : touchHandlers) {
            registration.removeHandler();
        }
        touchHandlers.clear();
        setVisiblePageCount(1);
    } else {
        RootPanel rootPanel = rootPanelDelegate.getRootPanel();
        HasTouchHandlers touchHandler = touchRecognitionFactory.getTouchRecognition(rootPanel, false);
        touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_START)));
        touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_MOVE)));
        touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_END)));
        setVisiblePageCount(3);
    }
    panelsCache.setSwipeType(swipeType.get());
}
 
Example 4
Project: gwt-rxjs-jsinterop   File: OnPageTest.java   Source Code and License 6 votes vote down vote up
@Override
public void onModuleLoad() {
    RootPanel rootPanel = RootPanel.get("main");
    final Button button = new Button("Click me");
    rootPanel.add(button);
    
    ObservableEx.fromKeyboardEvent(button.getElement(), "keydown")
            .map(event -> event.ctrlKey)
            .take(5)
            .subscribe(v -> log("ctrlKey " + v));
    
    ObservableEx.fromMouseEvent(button.getElement(), "click")
            .map(event -> event.clientX)
            .take(5)
            .subscribe(v -> log("clientX " + v));        
}
 
Example 5
Project: errai-spring-boot-sample   File: App.java   Source Code and License 6 votes vote down vote up
@AfterInitialization
public void afterInitialization() {
    authenticationServiceCaller.call(new RemoteCallback<User>() {
        @Override
        public void callback(User user) {
            Label userLabel = new Label(
                    "User logged in: username=" + user.getIdentifier() + ", roles=" + user.getRoles());
            RootPanel.get().add(userLabel);
            SimplePanel panel = new SimplePanel();
            Anchor logoutLink = new Anchor("Spring Security Logout URL", GWT.getHostPageBaseURL() + "logout");
            panel.add(logoutLink);
            RootPanel.get().add(panel);
            initBtns();
        }
    }).getUser();
}
 
Example 6
Project: unitimes   File: TeachingRequestDetailPage.java   Source Code and License 6 votes vote down vote up
public void showRequestDetail(Long id) {
	iAssignmentTable.clearTable(1);
	LoadingWidget.getInstance().show(MESSAGES.waitLoadTeachingRequestDetail());
	ToolBox.setMaxHeight(iScroll.getElement().getStyle(), Math.round(0.9 * Window.getClientHeight()) + "px");
	RPC.execute(new TeachingRequestDetailRequest(id), new AsyncCallback<TeachingRequestInfo>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequestDetail(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}

		@Override
		public void onSuccess(TeachingRequestInfo result) {
			LoadingWidget.getInstance().hide();
			populate(result, null, null);
			GwtHint.hideHint();
			center();
			RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
		}
	});
}
 
Example 7
Project: unitimes   File: TeachingRequestDetailPage.java   Source Code and License 6 votes vote down vote up
public void showInstructorDetail(Long id) {
	iAssignmentTable.clearTable(1);
	LoadingWidget.getInstance().show(MESSAGES.waitLoadTeachingRequestDetail());
	ToolBox.setMaxHeight(iScroll.getElement().getStyle(), Math.round(0.9 * Window.getClientHeight()) + "px");
	RPC.execute(new TeachingAssignmentsDetailRequest(id), new AsyncCallback<InstructorInfo>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequestDetail(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}

		@Override
		public void onSuccess(InstructorInfo result) {
			LoadingWidget.getInstance().hide();
			populate(null, null, result);
			GwtHint.hideHint();
			center();
			RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
		}
	});
}
 
Example 8
Project: unitimes   File: AriaStatus.java   Source Code and License 6 votes vote down vote up
public static AriaStatus getInstance() {
	if (sStatus == null) {
		RootPanel statusPanel = RootPanel.get("UniTimeGWT:AriaStatus");
		if (statusPanel != null && "1".equals(Window.Location.getParameter("aria"))) {
			sStatus = new AriaStatus(statusPanel.getElement(), false);
			sStatus.setStyleName("unitime-VisibleAriaStatus");
		} else {
			sStatus  = new AriaStatus(false);
			RootPanel.get().add(sStatus);
		}
		
		RootPanel.get().addDomHandler(new KeyUpHandler() {
			@Override
			public void onKeyUp(KeyUpEvent event) {
   				if (event.getNativeEvent().getKeyCode() == 191 && (event.isControlKeyDown() || event.isAltKeyDown())) {
   					sStatus.setHTML(sStatus.getHTML());
   				}
   			}
   		}, KeyUpEvent.getType());
	}
	return sStatus;
}
 
Example 9
Project: unitimes   File: Client.java   Source Code and License 6 votes vote down vote up
public void initPageAsync(final String page) {
	GWT.runAsync(new RunAsyncCallback() {
		public void onSuccess() {
			init(page);
			LoadingWidget.getInstance().hide();
		}
		public void onFailure(Throwable reason) {
			Label error = new Label(MESSAGES.failedToLoadPage(reason.getMessage()));
			error.setStyleName("unitime-ErrorMessage");
			RootPanel loading = RootPanel.get("UniTimeGWT:Loading");
			if (loading != null) loading.setVisible(false);
			RootPanel.get("UniTimeGWT:Body").add(error);
			LoadingWidget.getInstance().hide();
			UniTimeNotifications.error(MESSAGES.failedToLoadPage(reason.getMessage()), reason);
		}
	});
}
 
Example 10
Project: unitimes   File: RoomSharingWidget.java   Source Code and License 6 votes vote down vote up
public void insert(final RootPanel panel, boolean eventAvailability) {
	Long locationId = Long.valueOf(panel.getElement().getInnerHTML().trim());
	RPC.execute(RoomInterface.RoomSharingRequest.load(locationId, eventAvailability), new AsyncCallback<RoomSharingModel>() {
		@Override
		public void onFailure(Throwable caught) {
			UniTimeNotifications.error(MESSAGES.failedToLoadRoomAvailability(caught.getMessage()));
		}

		@Override
		public void onSuccess(RoomSharingModel result) {
			panel.getElement().setInnerText(null);
			setModel(result);
			panel.add(RoomSharingWidget.this);
			panel.setVisible(true);
		}
	});
}
 
Example 11
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
public void insert(final RootPanel panel, Long eventAvailability) {
	String[] ids = panel.getElement().getInnerHTML().trim().split(":");
	Long locationId = Long.valueOf(ids[0]);
	Long examTypeId = Long.valueOf(ids[1]);
	RPC.execute(RoomInterface.PeriodPreferenceRequest.load(locationId, examTypeId), new AsyncCallback<PeriodPreferenceModel>() {
		@Override
		public void onFailure(Throwable caught) {
			UniTimeNotifications.error(MESSAGES.failedToLoadPeriodPreferences(caught.getMessage()));
		}

		@Override
		public void onSuccess(PeriodPreferenceModel result) {
			panel.getElement().setInnerText(null);
			setModel(result);
			panel.add(PeriodPreferencesWidget.this);
			panel.setVisible(true);
		}
	});
}
 
Example 12
Project: unitimes   File: SolverAllocatedMemory.java   Source Code and License 6 votes vote down vote up
public void insert(final RootPanel panel) {
	String id = panel.getElement().getInnerText();
	panel.getElement().setInnerText(null);
	panel.add(this);
	panel.setVisible(true);
	RPC.execute(new SolverAllocatedMemoryRpcRequest(id), new AsyncCallback<SolverAllocatedMemoryRpcResponse>() {
		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(SolverAllocatedMemoryRpcResponse result) {
			setWidget(new Label(result.getValue()));
		}
	});
}
 
Example 13
Project: unitimes   File: LoadingWidget.java   Source Code and License 6 votes vote down vote up
public void show(String message, int warningDelayInMillis) {
	if (iCount == 0) {
		RootPanel.get().add(this, Window.getScrollLeft(), Window.getScrollTop());
		RootPanel.get().add(iImage, Window.getScrollLeft() + Window.getClientWidth() / 2, Window.getScrollTop() + Window.getClientHeight() / 2);
		iWarningTimer.schedule(warningDelayInMillis);
	}
	if (message != null) {
		boolean showing = (iCount > 0 && !iMessage.getText().isEmpty());
		iMessage.setHTML(message);
		if (!showing && !iMessage.getText().isEmpty()) {
			RootPanel.get().add(iMessage, Window.getScrollLeft() + Window.getClientWidth() / 2 - 225, Window.getScrollTop() + Window.getClientHeight() / 3);
		} else if (showing && iMessage.getText().isEmpty()) {
			RootPanel.get().remove(iMessage);
		}
		AriaStatus.getInstance().setText(message.replace("...", "."));
	}
	iCount ++;
}
 
Example 14
Project: unitimes   File: CourseNumbersSuggestBox.java   Source Code and License 6 votes vote down vote up
public static AriaSuggestBox insert(RootPanel panel) {
	String config = panel.getElement().getAttribute("configuration");
	final String onchange = panel.getElement().getAttribute("onchange");
	AriaTextBox text = new AriaTextBox(panel.getElement().getFirstChildElement());
	text.getElement().setAttribute("autocomplete", "off");
	AriaSuggestBox box = new AriaSuggestBox(text, new CourseNumbersSuggestBox(config));
	if (onchange != null)
		box.addValueChangeHandler(new ValueChangeHandler<String>() {
			@Override
			public void onValueChange(ValueChangeEvent<String> event) {
				ToolBox.eval(onchange);
			}
		});
	panel.add(box);
	return box;
}
 
Example 15
Project: unitimes   File: ApproveDialog.java   Source Code and License 6 votes vote down vote up
public void show(List<EventMeetingRow> meetings, ApproveEventRpcRequest.Operation operation) {
	iTable.setValue(meetings);
	switch (operation) {
	case APPROVE: setText(MESSAGES.dialogApprove()); break;
	case REJECT: setText(MESSAGES.dialogReject()); break;
	case INQUIRE: setText(MESSAGES.dialogInquire()); break;
	case CANCEL: setText(MESSAGES.dialogCancel()); break;
	}
	iFooter.setEnabled("approve", operation == ApproveEventRpcRequest.Operation.APPROVE);
	iFooter.setEnabled("reject", operation == ApproveEventRpcRequest.Operation.REJECT);
	iFooter.setEnabled("inquire", operation == ApproveEventRpcRequest.Operation.INQUIRE);
	iFooter.setEnabled("cancel", operation == ApproveEventRpcRequest.Operation.CANCEL);
	iFileUpload.check();
	center();
	if (iStandardNotes.getItemCount() == 0)
		iNotes.setFocus(true);
	else
		iStandardNotes.setFocus(true);
	RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
}
 
Example 16
Project: unitimes   File: AddMeetingsDialog.java   Source Code and License 6 votes vote down vote up
public void showDialog(Long eventId, List<MeetingConflictInterface> conflicts) {
	iStep = Math.max(1, (Window.getClientWidth() - 100) / 105);
	ToolBox.setMaxHeight(iScrollRooms.getElement().getStyle(), (Window.getClientHeight() - 100) + "px");
	ToolBox.setMaxHeight(iScrollDates.getElement().getStyle(), (Window.getClientHeight() - 100) + "px");
	int nrMonths = Math.max(1, Math.min(5, (Window.getClientWidth() - 100) / 225));
	iDates.setWidth((225 * nrMonths) + "px");
	iConflicts = conflicts;
	
	iResponse = null;
	iEventId = eventId;
	setWidget(iDatesForm);

	center();
	RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
	iDates.setFocus(true);
}
 
Example 17
Project: unitimes   File: StudentScheduleTable.java   Source Code and License 6 votes vote down vote up
public void insert(final RootPanel panel) {
	String studentId = panel.getElement().getInnerText().trim();
	panel.getElement().setInnerText(null);
	panel.add(this);
	sSectioningService.lookupStudent(iOnline, studentId, new AsyncCallback<ClassAssignmentInterface.Student>() {
		@Override
		public void onSuccess(Student result) {
			if (result != null) {
				panel.setVisible(true);
				setStudent(result);
				if (SectioningCookie.getInstance().getEnrollmentCoursesDetails()) {
					refresh();
				} else {
					clear();
					iHeader.clearMessage();
					iHeader.setCollapsible(false);
				}
			}
		}
		@Override
		public void onFailure(Throwable caught) {}
	});
}
 
Example 18
Project: unitimes   File: UniTimeMenuBar.java   Source Code and License 6 votes vote down vote up
private void attach(final RootPanel rootPanel) {
	RPC.execute(new MenuInterface.MenuRpcRequest(), new AsyncCallback<GwtRpcResponseList<MenuInterface>>() {
		@Override
		public void onSuccess(GwtRpcResponseList<MenuInterface> result) {
			initMenu(iMenu, result, 0);
			if (iSimple != null)
				rootPanel.add(iSimple);
			rootPanel.add(UniTimeMenuBar.this);
			if (iSimple != null)
				iSimple.setHeight(iMenu.getOffsetHeight() + "px");
		}
		@Override
		public void onFailure(Throwable caught) {
		}
	});
}
 
Example 19
Project: unitimes   File: ReservationTable.java   Source Code and License 6 votes vote down vote up
public void insert(final RootPanel panel) {
	initCallbacks();
	iOfferingId = Long.valueOf(panel.getElement().getInnerText());
	if (ReservationCookie.getInstance().getReservationCoursesDetails()) {
		refresh();
	} else {
		clear(false);
		iHeader.clearMessage();
		iHeader.setCollapsible(false);
	}
	panel.getElement().setInnerText(null);
	panel.add(this);
	panel.setVisible(true);
	addReservationClickHandler(new ReservationClickHandler() {
		@Override
		public void onClick(ReservationClickedEvent evt) {
			ToolBox.open(GWT.getHostPageBaseURL() + "gwt.jsp?page=reservation&id=" + evt.getReservation().getId() + "&reservations=" + getReservationIds());
		}
	});
}
 
Example 20
Project: sig-seguimiento-vehiculos   File: LinksWidget.java   Source Code and License 6 votes vote down vote up
private TextButton createLegendAnchor() {
	TextButton legendButton = new TextButton();
	legendButton.setIcon(ImageProvider.INSTANCE.mapLegend24());
	legendButton.setTitle(UIMessages.INSTANCE.mapLegendTitle());
	legendButton.addSelectHandler(new SelectHandler() {
		@Override
		public void onSelect(SelectEvent event) {
			if (mapLegend != null && mapLegend.isVisible()) {
				mapLegend.getElement().<FxElement> cast().fadeToggle();
				RootPanel.get().remove(mapLegend);
			} else {
				mapLegend = new SimpleMapVerticalLegend(layerManager);
				RootPanel.get().add(mapLegend);
				mapLegend.getElement().<FxElement> cast().fadeToggle();
				mapLegend.setVisible(true);
			}
		}
	});
	return legendButton;
}
 
Example 21
Project: sig-seguimiento-vehiculos   File: ChangeStyleTool.java   Source Code and License 6 votes vote down vote up
private void applyLengendVisibility(VectorLayer selectedLayer) {
	VectorStyleDef currentStyle = selectedLayer.getVectorStyle();
	
	if (currentStyle.isEnableLegend()) {
		if (legendPanel != null) {
			RootPanel.get().remove(legendPanel);				
		}
		
		legendPanel = new SimpleThemingVerticalLegend(selectedLayer,
				currentStyle.getColorThemingAttribute().getName());

		RootPanel.get().add(legendPanel);
		legendPanel.getElement().<FxElement> cast().fadeToggle();
		legendPanel.setVisible(true);
	} else {			
		hideLegendPanel();
	}
}
 
Example 22
Project: sig-seguimiento-vehiculos   File: App.java   Source Code and License 6 votes vote down vote up
@PostConstruct
public void buildUI() {

	OpenLayers.setProxyHost("gwtOpenLayersProxy?targetURL=");
	RootLayoutPanel.get().add(geoMap.getMapWidget());
	RootPanel.get().add(actionBar);
	RootPanel.get().add(linksWidget);
	RootPanel.get().add(zoomStatusWidget);

	logger.info("Map initialize...");
	geoMapInitializer.initialize();
	rasterLayerInitializer.initialize();
	vectorLayerInitializer.initialize();
	widgetInitializer.initialize();
	eventListenerInitializer.initialize();

	showDisclaimer();

	RestClient.setJacksonMarshallingActive(true);
	RootPanel.get("splash").setVisible(false);
}
 
Example 23
Project: WebConsole   File: BrowserUtils.java   Source Code and License 6 votes vote down vote up
public static int[] getSizeFromStyle(String style, boolean useText) {
	if (!probeElement.isAttached()) {
		RootPanel.get().add(probeElement);
	}
	
	if (useText) {
		probeElement.setHTML("M");
	} else {
		probeElement.setHTML("");
	}
	
	int[] values = new int[4];
	probeElement.getElement().addClassName(style);
	values[0] = probeElement.getElement().getOffsetWidth();
	values[1] = probeElement.getElement().getOffsetHeight();
	values[2] = probeElement.getElement().getClientWidth();
	values[3] = probeElement.getElement().getClientHeight();
	probeElement.getElement().removeClassName(style);
	return values;
}
 
Example 24
Project: WebConsole   File: ImageContainer.java   Source Code and License 6 votes vote down vote up
private void onLoaded() {
	if (loadAttempted) return;
	
	nativeWidth = image.getWidth();
	nativeHeight = image.getHeight();
	exists = true;
	loadAttempted = true;
	if (!existCheckDone) {
		RootPanel.get().remove(image);
		existCheckDone = true;
	}
	for (ImageLoadedCallback loadedCallback : loadedCallbacks) {
		if (loadedCallback != null) {
			loadedCallback.onImageLoaded(this);
		}
	}
	loadedCallbacks.clear();
}
 
Example 25
Project: LAS   File: WindowBox.java   Source Code and License 6 votes vote down vote up
@Override
protected void beginDragging(MouseDownEvent event) {
	int dm = -1;
	
	if (this.resizable && !this.minimized)
		dm = this.calcDragMode(event.getClientX(),event.getClientY());
	
	if (this.resizable && dm >= 0) {
		this.dragMode = dm;
		
		DOM.setCapture(getElement());
		
		this.dragX = event.getClientX();
		this.dragY = event.getClientY();
		
		updateCursor(dm,RootPanel.get().getElement());
		
	} else {
		super.beginDragging(event);
	}
}
 
Example 26
Project: LAS   File: WindowBox.java   Source Code and License 6 votes vote down vote up
@Override
protected void endDragging(MouseUpEvent event) {
	if (this.dragMode >= 0 && this.resizable) {
		DOM.releaseCapture(getElement());

	    this.dragX = event.getClientX() - this.dragX;
	    this.dragY = event.getClientY() - this.dragY;
	    
	    this.dragMode = -1;
	    this.updateCursor(this.dragMode);
	    RootPanel.get().getElement().getStyle().setCursor(Cursor.AUTO);
	}
	else {
		super.endDragging(event);
	}
}
 
Example 27
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testAddCategoryBeforeAttached() throws Exception {
    // given
    T table = createTable();
    table.setUseCategories(true);
    AbstractDataView<Person> dataView = (AbstractDataView<Person>)table.getView();
    addSampleColumns(table);

    String categoryName = "Test Category";

    // when
    dataView.addCategory(categoryName);
    RootPanel.get().add(table);

    // then
    assertTrue(dataView.hasCategory(categoryName));

    CategoryComponent category = dataView.getCategory(categoryName);
    assertNotNull(category);
    assertTrue(category.isRendered());
    assertTrue(category.getWidget().isAttached());
}
 
Example 28
Project: LAS   File: ClimateAnalysis.java   Source Code and License 6 votes vote down vote up
private void setBackground(int id) {
	for (int i = 0; i < panelIDs.length; i++) {
		RootPanel.get(panelIDs[i]).removeStyleName(highLightStyle);
		RootPanel.get(selectionIDs[i]).removeStyleName(selectionStyle);
	}
	if ( set.contains(0) && set.contains(1) && set.contains(2) && set.contains(3)) {
		RootPanel.get(panelIDs[4]).addStyleName(highLightStyle);
		RootPanel.get(selectionIDs[4]).addStyleName(selectionStyle);
	} else {
		if ( xSecondID.equals(xInitialId) ) {
			RootPanel.get("DatasetSelection").addStyleName(highLightStyle);
			RootPanel.get("DatasetWidget").addStyleName(selectionStyle);
		} else{ 
			if ( !set.contains(id) ) {
				RootPanel.get(panelIDs[id]).addStyleName(highLightStyle);
				RootPanel.get(selectionIDs[id]).addStyleName(selectionStyle);
			}
		}
	}
}
 
Example 29
Project: gwt-material-table   File: DataTableTestCase.java   Source Code and License 6 votes vote down vote up
protected T attachTableWithOnLoad(boolean includeData) throws Exception {
    // given
    T table = createTable();

    table.addAttachHandler(event -> {
        // when
        try {
            addSampleColumns(table);
            if(includeData) {
                addSampleRows(table);
            }

        // then
        } catch (final AssertionError ae) {
            throw ae;
        } catch (final Throwable t) {
            throw new AssertionError("Could not load table in onLoad.", t);
        }
    });

    RootPanel.get().add(table);
    return table;
}
 
Example 30
Project: LAS   File: IESafeImage.java   Source Code and License 6 votes vote down vote up
/**
 * Returns the original width when when using IE.
 * 
 * @see com.google.gwt.user.client.ui.Image#getWidth()
 */
@Override
public int getWidth() {
    int superWidth = super.getWidth();
    logger.log(Level.INFO, "superWidth:" + superWidth);
    logger.log(Level.INFO, "isAttached():" + isAttached());
    if ( (superWidth <= 0) ) {
        // If this is being run under IE the default answer may be 0 when it
        // shouldn't be, so return the height from a hidden and attached
        // temp image
        Image temp = new Image(this.getUrl());
        temp.getElement().getStyle().setVisibility(Visibility.HIDDEN);
        RootPanel.get().add(temp);
        logger.log(Level.WARNING, "temp.isAttached():" + temp.isAttached());
        int tempWidth = temp.getWidth();
        logger.log(Level.WARNING, "tempWidth:" + tempWidth);
        temp.removeFromParent();
        return tempWidth;
    }
    return superWidth;
}
 
Example 31
Project: document-management-system   File: Util.java   Source Code and License 6 votes vote down vote up
/**
 * Download files exported as zip
 *
 * @author danilo
 */
@Deprecated
public static void downloadFiles(List<String> path, String params) {
	if (!params.equals("")) {
		params = "&" + params;
	}

	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.DownloadServlet + "?export" + params;

	for (String p : path) {
		url += "&pathList=" + URL.encodeQueryString(p);
	}

	DOM.setElementAttribute(downloadIframe, "src", url);
}
 
Example 32
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testAddCategory() throws Exception {
    // given
    T table = createTable();
    table.setUseCategories(true);
    AbstractDataView<Person> dataView = (AbstractDataView<Person>)table.getView();
    addSampleColumns(table);

    RootPanel.get().add(table);
    String categoryName = "Test Category";

    // when
    assertFalse(dataView.hasCategory(categoryName));
    dataView.addCategory(categoryName);

    // then
    assertTrue(dataView.hasCategory(categoryName));

    CategoryComponent category = dataView.getCategory(categoryName);
    assertNotNull(category);
    assertTrue(category.isRendered());
    assertTrue(category.getWidget().isAttached());
}
 
Example 33
Project: walkaround   File: Walkaround.java   Source Code and License 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 34
Project: social-analytics   File: SocialAnalytics.java   Source Code and License 6 votes vote down vote up
@Override
public void onModuleLoad() {

    ClientFactory clientFactory = GWT.create(ClientFactory.class);
    EventBus eventBus = clientFactory.getEventBus();
    PlaceController placeController = clientFactory.getPlaceController();

    // Start ActivityManager for the twitter widget with our ActivityMapper
    ActivityMapper activityMapper = new AppActivityMapper(clientFactory);
    ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
    activityManager.setDisplay(appWidget);

    // Start PlaceHistoryHandler with our PlaceHistoryMapper
    AppPlaceHistoryMapper historyMapper= GWT.create(AppPlaceHistoryMapper.class);
    PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
    historyHandler.register(placeController, eventBus, defaultPlace);

    RootPanel.get().add(appWidget);
    // Goes to the place represented on URL else default place
    historyHandler.handleCurrentHistory();

}
 
Example 35
Project: cuba   File: CubaFileDownloaderConnector.java   Source Code and License 6 votes vote down vote up
public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
 
Example 36
Project: gwt-uploader   File: GwtUploaderDemo.java   Source Code and License 6 votes vote down vote up
@Override
public void onModuleLoad() {
  uploaderPanels.put("TextButtonAndProgressText", new TextButtonAndProgressText());
  uploaderPanels.put("ImageButtonAndProgressText", new ImageButtonAndProgressText());
  uploaderPanels.put("ImageButtonAndProgressBar", new ImageButtonAndProgressBar());
  uploaderPanels.put("MultiUploadWithProgressBar", new MultiUploadWithProgressBar());
  uploaderPanels.put("MultiUploadWithProgressBarAndDragAndDrop",
                     new MultiUploadWithProgressBarAndDragAndDrop());

  for (Map.Entry<String, UploaderSample> entry : uploaderPanels.entrySet()) {
    final UploaderSample sample = entry.getValue();
    final Widget uploaderPanel = sample.getUploaderPanel();
    final Button btnViewSource = new Button("View Source");
    btnViewSource.getElement().getStyle().setMarginTop(10, Style.Unit.PX);
    btnViewSource.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        sourceCodePopup.showSourceCode(sample.getUploaderCode());
      }
    });
    VerticalPanel panel = new VerticalPanel();
    panel.add(uploaderPanel);
    panel.add(btnViewSource);
    RootPanel.get(entry.getKey()).add(panel);
  }
}
 
Example 37
Project: Wiab.pro   File: ErrorHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void onUncaughtException(Throwable e) {
  if (!hasFired) {
    hasFired = true;
    final ErrorIndicatorPresenter error =
        ErrorIndicatorPresenter.create(RootPanel.get("banner"));
    if (LogLevel.showErrors()) {
      getStackTraceAsync(e, new AsyncHolder.Accessor<SafeHtml>() {
        @Override
        public void use(SafeHtml stack) {
          error.addDetail(stack, null);
          REMOTE_LOG.severe(stack.asString().replace("<br>", "\n"));
        }
      });
    }
  }

  if (next != null) {
    next.onUncaughtException(e);
  }
}
 
Example 38
Project: Wiab.pro   File: WebClient.java   Source Code and License 6 votes vote down vote up
private void setupVersionChecker() {
  versionChecker = new ClientVersionChecker(new ClientVersionChecker.Listener() {

    @Override
    public void onClientUpdated() {
      UpdateIndicatorWidget.create(RootPanel.get("banner"), new UpdateIndicatorWidget.Listener() {

        @Override
        public void refresh() {
          completeWave(new Command() {

            @Override
            public void execute() {
              Location.assign(GWT.getHostPageBaseURL());
            }
          });
        }
      });
    }
  }, LOG);
}
 
Example 39
Project: Wiab.pro   File: ImageThumbnailWidget.java   Source Code and License 6 votes vote down vote up
private void cleanUp() {
  RootPanel.get().remove(doubleLoadedImage);

  final HandlerRegistration onLoadReg = onLoadHandlerRegistration;
  final HandlerRegistration onErrorReg = onErrorHandlerRegistration;

  // HACK(user): There is a bug in GWT which stops us from removing a listener in HOSTED
  // mode inside the invoke context.  Put the remove in a deferred command to avoid this
  // error
  ScheduleCommand.addCommand(new Scheduler.Task() {
    
    @Override
    public void execute() {
      onLoadReg.removeHandler();
      onErrorReg.removeHandler();
    }
  });

  onLoadHandlerRegistration = null;
  onErrorHandlerRegistration = null;

  completed = true;
}
 
Example 40
Project: Wiab.pro   File: SuggestionButton.java   Source Code and License 6 votes vote down vote up
public SuggestionButton(final ContentElement element) {
  Widget clickButton =
      ButtonFactory.createIconClickButton(IconButtonStyle.LIGHTBULB, TOOLTIP,
      new ClickButtonListener() {
        @Override
        public void onClick() {
          HasSuggestions suggestion =
              element.getProperty(SuggestionRenderer.HAS_SUGGESTIONS_PROP);
          element.getSuggestionsManager().showSuggestionsFor(suggestion);
        }
      });
  clickButton.getElement().getStyle().setDisplay(Display.INLINE_BLOCK);
  // Logically attach it to the root panel to listen to events, but then
  // manually move the dom to the desired location.
  RootPanel.get().add(clickButton);
  this.element = clickButton.getElement();
  NodeManager.setTransparency(this.element, Skip.DEEP);
  DomHelper.makeUnselectable(this.element);
  this.element.setAttribute("contentEditable", "false");
}
 
Example 41
Project: Wiab.pro   File: FocusManager.java   Source Code and License 6 votes vote down vote up
/**
 * Installs a key handler for key events on this window.
 *
 * @param handler handler to receive key events.
 */
static void install(KeySignalHandler handler) {
  //
  // NOTE: There are three potential candidate elements for sinking keyboard
  // events: the window, the document, and the document body. IE7 does not
  // fire events on the window element, and GWT's RootPanel is already a
  // listener on the body, leaving the document as the only cross-browser
  // whole-window event-sinking 'element'.
  //
  DocumentPanel panel = new DocumentPanel(handler);
  panel.setElement(Document.get().<Element>cast());
  panel.addDomHandler(panel, KeyDownEvent.getType());
  panel.addDomHandler(panel, KeyPressEvent.getType());
  panel.addDomHandler(panel, KeyUpEvent.getType());
  RootPanel.detachOnWindowClose(panel);
  panel.onAttach();
}
 
Example 42
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testEnableCategory() throws Exception {
    // given
    T table = createTable();
    table.setUseCategories(true);
    AbstractDataView<Person> dataView = (AbstractDataView<Person>)table.getView();
    addSampleColumns(table);

    String categoryName = "Test Category";
    dataView.addCategory(categoryName);
    RootPanel.get().add(table);

    CategoryComponent category = dataView.getCategory(categoryName);
    dataView.disableCategory(categoryName);
    assertFalse(category.getWidget().isEnabled());

    // when
    dataView.enableCategory(categoryName);

    // then
    assertTrue(category.getWidget().isEnabled());
}
 
Example 43
Project: Wiab.pro   File: DialogBox.java   Source Code and License 6 votes vote down vote up
/**
 * Standard information dialog with prompt and "OK" button.
 *
 * @param message message to display
 */
public static void information(String message) {
  PopupChrome chrome = PopupChromeFactory.createPopupChrome();
  final UniversalPopup popup = PopupFactory.createPopup(RootPanel.getBodyElement(),
      new CenterPopupPositioner(), chrome, true);

  VerticalPanel verticalPanel = new VerticalPanel();
  verticalPanel.setStyleName(Dialog.getCss().verticalPanel());
  Label label = new Label(message);
  verticalPanel.add(label);

  DialogButton okButton = new DialogButton(messages.ok(), new Command() {

    @Override
    public void execute() {
      popup.hide();
    }
  });

  DialogBox.create(popup, messages.confirmation(), verticalPanel,
      new DialogButton[] { okButton });

  popup.show();
  requestFocus(okButton.getButton());
}
 
Example 44
Project: Wiab.pro   File: PasteExtractorGwtTest.java   Source Code and License 6 votes vote down vote up
private TestBundle(String initialContent) {
  local = createEditor();
  RootPanel.get().add(local);

  ContentWithSelection content = new ContentWithSelection(initialContent);
  ContentSerialisationUtil.setContentString(local, content.content);
  local.getAggressiveSelectionHelper().setSelectionRange(
      new FocusedRange(content.selection, true));

  remote = createEditor();
  RootPanel.get().add(remote);

  remote.setContent(local.getDocumentInitialization(),
      ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS);

  local.setOutputSink(
      new SilentOperationSink<DocOp>() {
        
        @Override
        public void consume(DocOp op) {
          remote.getContent().consume(op);
        }
      });

  extractor = local.debugGetPasteExtractor();
}
 
Example 45
Project: gwt-olcs   File: OLCesiumPanel.java   Source Code and License 6 votes vote down vote up
public OLCesiumPanel(OLCesiumOptions options) {
    super();
    final Element element = getElement();
    // Some strange, but ol-cesium set style for div's elements to absolute. Fix this.
    element.getStyle().setProperty("position", "relative");
    options.target = element;
    RootPanel.getBodyElement().appendChild(element);
    olCesium = new OLCesium(options);
    super.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {
            if (!attachEvent.isAttached()) {
                element.removeAllChildren();
                element.removeFromParent();
            }
        }
    });
}
 
Example 46
Project: gwt-oauth2   File: OAuth2SampleEntryPoint.java   Source Code and License 6 votes vote down vote up
private void addFoursquareAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Foursquare");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(FOURSQUARE_AUTH_URL, FOURSQUARE_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
Example 47
Project: gwt-oauth2   File: OAuth2SampleEntryPoint.java   Source Code and License 6 votes vote down vote up
private void addDailymotionAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Dailymotion");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(DAILYMOTION_AUTH_URL, DAILYMOTION_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
Example 48
Project: gwt-oauth2   File: OAuth2SampleEntryPoint.java   Source Code and License 6 votes vote down vote up
private void addWindowsLiveAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Windows Live");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(WINDOWS_LIVE_AUTH_URL, WINDOWS_LIVE_CLIENT_ID)
          .withScopes(WINDOWS_LIVE_BASIC_SCOPE);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
Example 49
Project: gwt-oauth2   File: OAuth2SampleEntryPoint.java   Source Code and License 6 votes vote down vote up
private void addGoogleAuthNative() {
  Button button = new Button("Authenticate with Google (using native JS)");
  button.addClickHandler(new ClickHandler() {
    @Override
    public native void onClick(ClickEvent event) /*-{
      $wnd.oauth2.login({
        "authUrl" : "https://accounts.google.com/o/oauth2/auth",
        "clientId" : "452237527106.apps.googleusercontent.com",
        "scopes" : [
          "https://www.googleapis.com/auth/plus.me"
        ]
      }, function(token) {
        $wnd.alert("Got an OAuth token:\n" + token + "\n"
            + "Token expires in " + $wnd.oauth2.expiresIn(req) + " ms\n");
      }, function(error) {
        $wnd.alert("Error:\n" + error);
      });
    }-*/;
  });
  RootPanel.get().add(button);
}
 
Example 50
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testSetupPendingRows() throws Exception {
    // given
    T table = createTable();
    AbstractDataView<Person> dataView = (AbstractDataView<Person>) table.getView();

    table.setRowData(0, people);

    table.addRenderedHandler(e -> {
        assertFalse(dataView.isRendering());
    });

    // when
    RootPanel.get().add(table);

    // then
    checkRowComponents(table, people.size());
}
 
Example 51
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testRenderColumn() throws Exception {
    // given
    T table = createTable();
    table.setSelectionType(SelectionType.NONE);
    AbstractDataView<Person> dataView = (AbstractDataView<Person>)table.getView();
    RootPanel.get().add(table);

    TextColumn<Person> column = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            return object.getFirstName();
        }
    };
    dataView.getColumns().add(column);

    // when
    dataView.renderColumn(column);

    // then
    List<TableHeader> header = dataView.getHeaders();
    assertTrue(!header.isEmpty());
}
 
Example 52
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testAutoSortColumnBeforeAttached() throws Exception {
    // given
    T table = createTable();
    DataView<Person> dataView = table.getView();
    addSampleColumns(table);

    // when
    table.setRowData(0, people);

    table.addRenderedHandler(event -> {
        // First column is autoSort'ing
        checkColumnSort(dataView, 0);
    });

    // then
    RootPanel.get().add(table);

    assertFalse(dataView.isRedraw());
    assertFalse(dataView.isRendering());
}
 
Example 53
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testAutoSortColumnAfterAttached() throws Exception {
    // given
    T table = createTable();
    DataView<Person> dataView = table.getView();
    addSampleColumns(table);

    // when
    RootPanel.get().add(table);

    // then
    table.addRenderedHandler(event -> {
        // First column is autoSort'ing
        checkColumnSort(dataView, 0);
    });

    table.setRowData(0, people);

    assertFalse(dataView.isRedraw());
    assertFalse(dataView.isRendering());
}
 
Example 54
Project: gwt-material-table   File: AbstractDataViewTest.java   Source Code and License 6 votes vote down vote up
public void testCustomRenderer() throws Exception {
    // given
    T table = createTable();
    table.setRenderer(new CustomRenderer<>());
    AbstractDataView<Person> dataView = (AbstractDataView<Person>)table.getView();

    // when
    RootPanel.get().add(table);

    // then
    for(RowComponent<Person> row : dataView.getRows()) {
        try {
            TableData td = (TableData) row.getWidget().getWidget(0);
            assertTrue(td.getId().equals("col0"));
            assertEquals(CssName.FILLED_IN, td.getElement().getAttribute("class"));
        }
        catch (ClassCastException | IndexOutOfBoundsException ex) {
            throw new AssertionError("Issue testing selection column.", ex);
        }
    }
}
 
Example 55
Project: empiria.player   File: MathTextModule.java   Source Code and License 5 votes vote down vote up
private boolean temporaryAttach() {
    if (!mainPanel.isAttached()) {
        RootPanel.get().add(mainPanel);
        return true;
    }
    return false;
}
 
Example 56
Project: empiria.player   File: VideoFullScreenHelper.java   Source Code and License 5 votes vote down vote up
private VideoFullScreenView getFullScreenView() {
    if (view == null) {
        view = fullScreenViewProvider.get();
        controlsHideTimer = mediaFactory.getVideoControlHideTimer(view);
        RootPanel.get().addDomHandler(this, KeyUpEvent.getType());
    }
    return view;
}
 
Example 57
Project: empiria.player   File: VideoFullScreenHelper.java   Source Code and License 5 votes vote down vote up
protected void openFullScreenDesktop(MediaWrapper<?> mediaWrapper, Element template) {
    if (mediaWrapper != null && template != null) {
        clearFullScreenView();
        lastMediaWrapper = mediaWrapper;
        VideoFullScreenView parent = getFullScreenView();
        parseTemplate(mediaWrapper, template, parent.getControls());
        fireEvent(true, mediaWrapper);
        RootPanel.get().add(parent);
        html5FullScreenHelper.requestFullScreen(parent.getElement());
        resizeToFullScreen(lastMediaWrapper.getMediaObject(), Position.FIXED);
    }
}
 
Example 58
Project: empiria.player   File: SoundExecutorSwfSimple.java   Source Code and License 5 votes vote down vote up
@Inject
public SoundExecutorSwfSimple(LocalSwfMediaWrapper localSwfMediaWrapper) {
    panelMain = new FlowPanel();
    RootPanel.get().add(panelMain, PANEL_OFFSET, PANEL_OFFSET);
    localSwfMediaWrapper.setMediaWidget(panelMain);
    mediaWrapper = localSwfMediaWrapper;
}
 
Example 59
Project: empiria.player   File: ContentPreloader.java   Source Code and License 5 votes vote down vote up
public void setPreloader() {
    RootPanel preloaderWidget = rootPanelDelegate.getRootPanel(MAIN_PRELOADER_ID);
    if (preloaderWidget == null) {
        ImageResource progressImage = progressBundle.getProgressImage();
        mainPreloader = new Image(progressImage);
    } else {
        mainPreloader = Image.wrap(preloaderWidget.getElement());
    }
    RootPanel rootPanel = rootPanelDelegate.getRootPanel();
    rootPanel.add(mainPreloader);

    int halfWidth = windowDelegate.getClientWidth() / 2;
    int halfHeight = windowDelegate.getClientHeight() / 2;
    centerMainPreloader(halfWidth, halfHeight, mainPreloader.getElement());
}
 
Example 60
Project: empiria.player   File: Player.java   Source Code and License 5 votes vote down vote up
@Inject
public Player(@Assisted String id, @Assisted JavaScriptObject jsObject, ViewEngine viewEngine, DeliveryEngine deliveryEngine,
              IPlayerContainersAccessor accessor) {
    this.accessor = accessor;
    this.deliveryEngine = deliveryEngine;
    try {
        RootPanel.get(id);
    } catch (Exception e) {
    }
    RootPanel root = RootPanel.get(id);
    viewEngine.mountView(root);
    getAccessor().setPlayerContainer(root);

    deliveryEngine.init(jsObject);
}