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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   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 34
Project: social-analytics   File: SocialAnalytics.java   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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");
}