List of usage examples for com.google.gwt.user.client Window addResizeHandler
public static HandlerRegistration addResizeHandler(ResizeHandler handler)
From source file:com.codenvy.ide.client.workspace.WorkspaceViewImpl.java
License:Open Source License
@Inject public WorkspaceViewImpl(WorkspaceViewImplUiBinder ourUiBinder) { initWidget(ourUiBinder.createAndBindUi(this)); Window.addResizeHandler(new ResizeHandler() { @Override//from w w w .j av a 2s . c o m public void onResize(ResizeEvent event) { delegate.onWindowResize(); } }); }
From source file:com.dianaui.universal.core.client.ui.DropDownMenu.java
License:Apache License
public void show(final Widget relativeWidget) { if (this.relativeWidget != relativeWidget) { this.relativeWidget = relativeWidget; if (resizeHandler != null) { resizeHandler.removeHandler(); resizeHandler = null;/* w w w .ja v a 2 s . c o m*/ } } if (!isAttached()) { RootPanel.get().add(this); } relativeTo(relativeWidget); getElement().getStyle().setDisplay(Style.Display.BLOCK); getElement().getStyle().setZIndex(1500); if (resizeHandler == null) { resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (isShowing()) { relativeTo(relativeWidget); } } }); } }
From source file:com.dianaui.universal.gwtp.client.ModalViewImpl.java
License:Apache License
/** * @param eventBus The {@link EventBus}. * @param positioner The {@link PopupPositioner} used to position the popup onReveal(); * @see com.gwtplatform.mvp.client.view.CenterPopupPositioner * @see com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner * @see com.gwtplatform.mvp.client.view.TopLeftPopupPositioner *//* w ww . ja v a2s. co m*/ protected ModalViewImpl(EventBus eventBus, PopupPositioner positioner) { this.eventBus = eventBus; setPopupPositioner(positioner); if (repositionOnWindowResize()) { Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (isShowing()) { showAndReposition(); } } }); } }
From source file:com.edgenius.wiki.gwt.client.widgets.Lightbox.java
License:Open Source License
/** * Only show background mask on owner scope. if owner is null, then it is entire page scope. * @param owner//from w w w . j a va2s . c om * @param popup */ public Lightbox(UIObject owner, final PopupPanel popup) { this.popup = popup; this.owner = owner; background = new PopupPanel(); background.setStyleName(Css.LIGHT_BOX_BK); if (owner == null) { DOM.setStyleAttribute(background.getElement(), "width", "100%"); DOM.setStyleAttribute(background.getElement(), "height", "5000px"); //Window.getClientHeight() evtReg = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { //background need be adjust size, but popup won't display if it is not showing. if (popup.isShowing()) { popup.center(); if (popup instanceof DialogBox) { List<DialogListener> listeners = ((DialogBox) popup).getDialogListeners(); if (listeners != null) { for (DialogListener listener : listeners) { listener.dialogRelocated((DialogBox) popup); } } } } } }); } else { background.setPopupPosition(owner.getAbsoluteLeft(), owner.getAbsoluteTop()); DOM.setStyleAttribute(background.getElement(), "width", owner.getOffsetWidth() + "px"); DOM.setStyleAttribute(background.getElement(), "height", owner.getOffsetHeight() + "px"); } }
From source file:com.emitrom.lienzo.client.widget.LienzoPanel.java
License:Open Source License
private void addHandlers() { Window.addResizeHandler(new ResizeHandler() { @Override//from www . j a va2s. c o m public void onResize(ResizeEvent event) { int w = getElement().getParentElement().getClientWidth(); int h = getElement().getParentElement().getClientHeight(); setPixelSize(w, h); if (!m_resizing) { m_resizing = true; getViewport().getHandlerManager().fireEvent(new ResizeStartEvent(w, h)); m_resize_timer.scheduleRepeating(m_resize_check_repeat_interval); } m_resizing = true; getViewport().getHandlerManager().fireEvent(new ResizeChangeEvent(w, h)); Orientation orientation; if (w > h) { orientation = Orientation.LANDSCAPE; } else { orientation = Orientation.PORTRAIT; } if (orientation != m_orientation) { m_orientation = orientation; getViewport().getHandlerManager().fireEvent(new OrientationChangeEvent(w, h)); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { m_view.draw(); } }); } }); }
From source file:com.ephesoft.gxt.rv.client.layout.ReviewValidateLayout.java
License:Open Source License
public ReviewValidateLayout(final ReviewValidateController controller, final ReviewValidateServiceAsync rpcService) { initWidget(binder.createAndBindUi(this)); mainPage.sync(false);/*from w w w . ja va 2 s. c o m*/ this.controller = controller; this.rpcService = rpcService; ephesoftPoweredLabel.setText(EphesoftUIContext.getFooterText()); treePanel.addStyleName("documentTreeContentPanel"); eventBinder.bindEventHandlers(this, controller.getEventBus()); reviewDetailView = new ReviewDetailView(); reviewDetailPresenter = new ReviewDetailPresenter(controller, reviewDetailView); validationDetailView = new ValidationDetailView(); validationDetailView.addStyleName("viewPort"); reviewDetailView.addStyleName("viewPort"); treePanel.setAnimCollapse(true); validationDetailPresenter = new ValidationDetailPresenter(controller, validationDetailView); tableExtractionView = new TableExtractionView(); tableExtractionPresenter = new TableExtractionPresenter(controller, tableExtractionView); this.addWindowClosingHandler(); WidgetUtil.setID(reviewDetailView, "review-Panel"); WidgetUtil.setID(validationDetailView, "validation-Detail-Panel"); addStyleNameforContentPanel(); initializeTableViewPanel(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (null != tableViewPanel && tableViewPanel.isVisible() && tableViewPanel.isAttached()) { Timer timer = new Timer() { @Override public void run() { showTableView(false); } }; timer.schedule(100); } } }); ephesoftPoweredLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open(CoreCommonConstants.EPHESOFT_LINK, "", ""); } }); }
From source file:com.extjs.gxt.ui.client.widget.Component.java
License:sencha.com license
@Override protected void onLoad() { super.onLoad(); if (disableTextSelection > 0) { disableTextSelection(disableTextSelection == 1); }/* w w w . ja v a2 s. co m*/ DeferredCommand.addCommand(new Command() { public void execute() { if (monitorWindowResize && isAttached()) { if (windowResizeTask == null) { windowResizeTask = new DelayedTask(new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { onWindowResize(Window.getClientWidth(), Window.getClientHeight()); } }); } resizeHandler = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { windowResizeTask.delay(windowResizeDelay); } }); } } }); fireEvent(Events.Attach); ComponentManager.get().register(this); }
From source file:com.fullmetalgalaxy.client.game.board.MAppBoard.java
License:Open Source License
/** * /*from w w w . j a va2 s .c o m*/ */ public MAppBoard() { s_instance = this; initWgtBoard(); AppRoot.getEventBus().addHandler(ModelUpdateEvent.TYPE, this); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(this); initWidget(m_wgtScroll); }
From source file:com.google.appinventor.client.editor.youngandroid.YaBlocksEditor.java
License:Open Source License
YaBlocksEditor(YaProjectEditor projectEditor, YoungAndroidBlocksNode blocksNode) { super(projectEditor, blocksNode); this.blocksNode = blocksNode; COMPONENT_DATABASE = SimpleComponentDatabase.getInstance(getProjectId()); fullFormName = blocksNode.getProjectId() + "_" + blocksNode.getFormName(); formToBlocksEditor.put(fullFormName, this); blocksArea = new BlocklyPanel(this, fullFormName); // [lyn, 2014/10/28] pass in editor so can extract form json from it blocksArea.setWidth("100%"); // This code seems to be using a rather old layout, so we cannot simply pass 100% for height. // Instead, it needs to be calculated from the client's window, and a listener added to Window // We use VIEWER_WINDOW_OFFSET as an approximation of the size of the top navigation bar // New layouts don't need all this messing; see comments on selected answer at: // http://stackoverflow.com/questions/86901/creating-a-fluid-panel-in-gwt-to-fill-the-page blocksArea.setHeight(Window.getClientHeight() - VIEWER_WINDOW_OFFSET + "px"); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { int height = event.getHeight(); blocksArea.setHeight(height - VIEWER_WINDOW_OFFSET + "px"); }//from ww w .j a v a 2s . c o m }); initWidget(blocksArea); addComponentDatabaseChangeListener(blocksArea); // Get references to the source structure explorer sourceStructureExplorer = BlockSelectorBox.getBlockSelectorBox().getSourceStructureExplorer(); // Listen for selection events for built-in drawers BlockSelectorBox.getBlockSelectorBox().addBlockDrawerSelectionListener(this); // Create palettePanel, which will be used as the content of the PaletteBox. myFormEditor = projectEditor.getFormFileEditor(blocksNode.getFormName()); if (myFormEditor != null) { palettePanel = new YoungAndroidPalettePanel(myFormEditor); palettePanel.loadComponents(new DropTargetProvider() { // TODO(sharon): make the tree in the BlockSelectorBox a drop target @Override public DropTarget[] getDropTargets() { return new DropTarget[0]; } }); palettePanel.setSize("100%", "100%"); } else { palettePanel = null; OdeLog.wlog("Can't get form editor for blocks: " + getFileId()); } }
From source file:com.google.appinventor.client.Ode.java
License:Open Source License
private void initializeUi() { BlocklyPanel.initUi();//from w w w . j a v a2s . co m rpcStatusPopup = new RpcStatusPopup(); // Register services with RPC status popup rpcStatusPopup.register((ExtendedServiceProxy<?>) helpService); rpcStatusPopup.register((ExtendedServiceProxy<?>) projectService); rpcStatusPopup.register((ExtendedServiceProxy<?>) galleryService); rpcStatusPopup.register((ExtendedServiceProxy<?>) userInfoService); Window.setTitle(MESSAGES.titleYoungAndroid()); Window.enableScrolling(true); topPanel = new TopPanel(); statusPanel = new StatusPanel(); DockPanel mainPanel = new DockPanel(); mainPanel.add(topPanel, DockPanel.NORTH); // Create tab panel for subsequent tabs deckPanel = new DeckPanel() { @Override public final void onBrowserEvent(Event event) { switch (event.getTypeInt()) { case Event.ONCONTEXTMENU: event.preventDefault(); break; } } }; deckPanel.setAnimationEnabled(true); deckPanel.sinkEvents(Event.ONCONTEXTMENU); deckPanel.setStyleName("ode-DeckPanel"); // Projects tab VerticalPanel pVertPanel = new VerticalPanel(); pVertPanel.setWidth("100%"); pVertPanel.setSpacing(0); HorizontalPanel projectListPanel = new HorizontalPanel(); projectListPanel.setWidth("100%"); projectToolbar = new ProjectToolbar(); projectListPanel.add(ProjectListBox.getProjectListBox()); pVertPanel.add(projectToolbar); pVertPanel.add(projectListPanel); projectsTabIndex = deckPanel.getWidgetCount(); deckPanel.add(pVertPanel); // Design tab VerticalPanel dVertPanel = new VerticalPanel(); dVertPanel.setWidth("100%"); dVertPanel.setHeight("100%"); // Add the Code Navigation arrow // switchToBlocksButton = new VerticalPanel(); // switchToBlocksButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); // switchToBlocksButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); // switchToBlocksButton.setStyleName("ode-NavArrow"); // switchToBlocksButton.add(new Image(RIGHT_ARROW_IMAGE_URL)); // switchToBlocksButton.setWidth("25px"); // switchToBlocksButton.setHeight("100%"); // Add the Code Navigation arrow // switchToDesignerButton = new VerticalPanel(); // switchToDesignerButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); // switchToDesignerButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); // switchToDesignerButton.setStyleName("ode-NavArrow"); // switchToDesignerButton.add(new Image(LEFT_ARROW_IMAGE_URL)); // switchToDesignerButton.setWidth("25px"); // switchToDesignerButton.setHeight("100%"); designToolbar = new DesignToolbar(); dVertPanel.add(designToolbar); workColumns = new HorizontalPanel(); workColumns.setWidth("100%"); //workColumns.add(switchToDesignerButton); Box palletebox = PaletteBox.getPaletteBox(); palletebox.setWidth("222px"); workColumns.add(palletebox); Box viewerbox = ViewerBox.getViewerBox(); workColumns.add(viewerbox); workColumns.setCellWidth(viewerbox, "97%"); workColumns.setCellHeight(viewerbox, "97%"); structureAndAssets = new VerticalPanel(); structureAndAssets.setVerticalAlignment(VerticalPanel.ALIGN_TOP); // Only one of the SourceStructureBox and the BlockSelectorBox is visible // at any given time, according to whether we are showing the form editor // or the blocks editor. They share the same screen real estate. structureAndAssets.add(SourceStructureBox.getSourceStructureBox()); structureAndAssets.add(BlockSelectorBox.getBlockSelectorBox()); // initially not visible structureAndAssets.add(AssetListBox.getAssetListBox()); workColumns.add(structureAndAssets); Box propertiesbox = PropertiesBox.getPropertiesBox(); propertiesbox.setWidth("222px"); workColumns.add(propertiesbox); //switchToBlocksButton.setHeight("650px"); //workColumns.add(switchToBlocksButton); dVertPanel.add(workColumns); designTabIndex = deckPanel.getWidgetCount(); deckPanel.add(dVertPanel); // Gallery list tab VerticalPanel gVertPanel = new VerticalPanel(); gVertPanel.setWidth("100%"); gVertPanel.setSpacing(0); galleryListToolbar = new GalleryToolbar(); gVertPanel.add(galleryListToolbar); HorizontalPanel appListPanel = new HorizontalPanel(); appListPanel.setWidth("100%"); appListPanel.add(GalleryListBox.getGalleryListBox()); gVertPanel.add(appListPanel); galleryTabIndex = deckPanel.getWidgetCount(); deckPanel.add(gVertPanel); // Gallery app tab VerticalPanel aVertPanel = new VerticalPanel(); aVertPanel.setWidth("100%"); aVertPanel.setSpacing(0); galleryPageToolbar = new GalleryToolbar(); aVertPanel.add(galleryPageToolbar); HorizontalPanel appPanel = new HorizontalPanel(); appPanel.setWidth("100%"); appPanel.add(GalleryAppBox.getGalleryAppBox()); aVertPanel.add(appPanel); galleryAppTabIndex = deckPanel.getWidgetCount(); deckPanel.add(aVertPanel); // User Admin Panel VerticalPanel uaVertPanel = new VerticalPanel(); uaVertPanel.setWidth("100%"); uaVertPanel.setSpacing(0); HorizontalPanel adminUserListPanel = new HorizontalPanel(); adminUserListPanel.setWidth("100%"); adminUserListPanel.add(AdminUserListBox.getAdminUserListBox()); uaVertPanel.add(adminUserListPanel); userAdminTabIndex = deckPanel.getWidgetCount(); deckPanel.add(uaVertPanel); // KM: DEBUGGING BEGIN // User profile tab VerticalPanel uVertPanel = new VerticalPanel(); uVertPanel.setWidth("100%"); uVertPanel.setSpacing(0); HorizontalPanel userProfilePanel = new HorizontalPanel(); userProfilePanel.setWidth("100%"); userProfilePanel.add(ProfileBox.getUserProfileBox()); uVertPanel.add(userProfilePanel); userProfileTabIndex = deckPanel.getWidgetCount(); deckPanel.add(uVertPanel); // KM: DEBUGGING END // Private User Profile TabPanel VerticalPanel ppVertPanel = new VerticalPanel(); ppVertPanel.setWidth("100%"); ppVertPanel.setSpacing(0); HorizontalPanel privateUserProfileTabPanel = new HorizontalPanel(); privateUserProfileTabPanel.setWidth("100%"); privateUserProfileTabPanel.add(PrivateUserProfileTabPanel.getPrivateUserProfileTabPanel()); ppVertPanel.add(privateUserProfileTabPanel); privateUserProfileIndex = deckPanel.getWidgetCount(); deckPanel.add(ppVertPanel); // Moderation Page tab VerticalPanel mPVertPanel = new VerticalPanel(); mPVertPanel.setWidth("100%"); mPVertPanel.setSpacing(0); HorizontalPanel moderationPagePanel = new HorizontalPanel(); moderationPagePanel.setWidth("100%"); moderationPagePanel.add(ModerationPageBox.getModerationPageBox()); mPVertPanel.add(moderationPagePanel); moderationPageTabIndex = deckPanel.getWidgetCount(); deckPanel.add(mPVertPanel); // Debugging tab if (AppInventorFeatures.hasDebuggingView()) { Button dismissButton = new Button(MESSAGES.dismissButton()); dismissButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (currentView == DESIGNER) switchToDesignView(); else switchToProjectsView(); } }); ColumnLayout defaultLayout = new ColumnLayout("Default"); Column column = defaultLayout.addColumn(100); column.add(MessagesOutputBox.class, 300, false); column.add(OdeLogBox.class, 300, false); final WorkAreaPanel debuggingTab = new WorkAreaPanel(new OdeBoxRegistry(), defaultLayout); debuggingTab.add(dismissButton); debuggingTabIndex = deckPanel.getWidgetCount(); deckPanel.add(debuggingTab); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { resizeWorkArea(debuggingTab); } }); // Call the window resized handler to get the initial sizes setup. Doing this in a deferred // command causes it to occur after all widgets' sizes have been computed by the browser. DeferredCommand.addCommand(new Command() { @Override public void execute() { resizeWorkArea(debuggingTab); } }); resizeWorkArea(debuggingTab); } // We do not select the designer tab here because at this point there is no current project. // Instead, we select the projects tab. If the user has a previously opened project, we will // open it and switch to the designer after the user settings are loaded. // Remember, the user may not have any projects at all yet. // Or, the user may have deleted their previously opened project. // ***** THE DESIGNER TAB DOES NOT DISPLAY CORRECTLY IF THERE IS NO CURRENT PROJECT. ***** deckPanel.showWidget(projectsTabIndex); mainPanel.add(deckPanel, DockPanel.CENTER); mainPanel.setCellHeight(deckPanel, "100%"); mainPanel.setCellWidth(deckPanel, "100%"); // mainPanel.add(switchToDesignerButton, DockPanel.WEST); // mainPanel.add(switchToBlocksButton, DockPanel.EAST); //Commenting out for now to gain more space for the blocks editor mainPanel.add(statusPanel, DockPanel.SOUTH); mainPanel.setSize("100%", "100%"); RootPanel.get().add(mainPanel); // Add a handler to the RootPanel to keep track of Google Chrome Pinch Zooming and // handle relevant bugs. Chrome maps a Pinch Zoom to a MouseWheelEvent with the // control key pressed. RootPanel.get().addDomHandler(new MouseWheelHandler() { @Override public void onMouseWheel(MouseWheelEvent event) { if (event.isControlKeyDown()) { // Trip the appropriate flag in PZAwarePositionCallback when the page // is Pinch Zoomed. Note that this flag does not need to be removed when // the browser is un-zoomed because the patched function for determining // absolute position works in all circumstances. PZAwarePositionCallback.setPinchZoomed(true); } } }, MouseWheelEvent.getType()); // There is no sure-fire way of preventing people from accidentally navigating away from ODE // (e.g. by hitting the Backspace key). What we do need though is to make sure that people will // not lose any work because of this. We hook into the window closing event to detect the // situation. Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(Window.ClosingEvent event) { onClosing(); } }); setupMotd(); }