예제 #1
0
  /** This is the entry point method. */
  @Override
  public void onModuleLoad() {

    FormUtil.setupUncaughtExceptionHandler();

    FormUtil.retrieveUserDivParameters();

    Context.startup();

    // FormDesignerWidget designer = new FormDesignerWidget(true,true,true);

    // Hook the window resize event, so that we can adjust the UI.
    Window.addResizeHandler(this);

    // Get rid of scrollbars, and clear out the window's built-in margin,
    // because we want to take advantage of the entire client area.
    Window.enableScrolling(false);
    Window.setMargin("0px");

    // Different themes use different background colors for the body
    // element, but IE only changes the background of the visible content
    // on the page instead of changing the background color of the entire
    // page. By changing the display style on the body element, we force
    // IE to redraw the background correctly.
    RootPanel.getBodyElement().getStyle().setProperty("display", "none");
    RootPanel.getBodyElement().getStyle().setProperty("display", "");

    // Finally, add the designer widget to the RootPanel, so that it will be
    // displayed.
    RootPanel.get().add(loginView);

    FormUtil.dlg
        .hide(); // Temporary fix This comes from the form designer where it loads and never closes
  }
  @Inject
  public TransUnitsTableView(
      FilterViewConfirmationDisplay filterViewConfirmationDisplay, LoadingPanel loadingPanel) {
    this.filterViewConfirmationDisplay = filterViewConfirmationDisplay;
    this.loadingPanel = loadingPanel;
    initWidget(uiBinder.createAndBindUi(this));
    noContentLabel.setText(messages.noContent());
    noContentLabel.setStyleName("gamma");

    transUnitTable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            HTMLTable.Cell cellForEvent = transUnitTable.getCellForEvent(event);
            if (cellForEvent != null) {
              selectRow(cellForEvent.getRowIndex());
            }
          }
        });
    transUnitTable.resize(0, 2);
    transUnitTable.getColumnFormatter().setWidth(0, "49%");
    transUnitTable.getColumnFormatter().setWidth(1, "51%");
    Window.addResizeHandler(
        new ResizeHandler() {
          @Override
          public void onResize(ResizeEvent event) {
            listener.refreshView();
          }
        });

    transUnitTable.ensureDebugId("transUnitTable");
  }
예제 #3
0
  public GoogleCalendarPanel(CalendarTaskManager calendarManager) {

    // style this element as absolute position
    DOM.setStyleAttribute(this.getElement(), "position", "absolute");

    calendarTaskManager = calendarManager;

    configureCalendar();
    createDatePickerDialog();

    setHeaderVisible(false);
    setBodyBorder(false);
    setBorders(false);
    setTopComponent(createCalendarToolbar());
    add(calendar);

    // window events to handle resizing
    Window.enableScrolling(false);
    Window.addResizeHandler(
        new ResizeHandler() {
          public void onResize(ResizeEvent event) {
            resizeTimer.schedule(500);
            int h = event.getHeight();
          }
        });
    DeferredCommand.addCommand(
        new Command() {
          public void execute() {
            LayoutContainer center = (LayoutContainer) Registry.get(AppView.CENTER_PANEL);
            calendar.setHeight(center.getHeight() - calendarHeightSize + "px");
          }
        });
  }
예제 #4
0
  private void init() {
    // widgetListTable=new WidgetList();
    // widgetListTable.setRound(true);
    main = new FlowPanel();

    // Window.addResizeHandler(this);
    header = new HeaderMenu();
    lblCenter = new Label(constants.seleccionar());
    header.setCenterWidget(lblCenter);
    btnBack = new PushButton(new Image(MyResource.INSTANCE.getImgBack32()));
    header.setLeftWidget(btnBack);
    btnSelect = new PushButton(new Image(MyResource.INSTANCE.getImgSelect32()));
    header.setRightWidget(btnSelect);
    main.add(header);
    toolBar = new ToolBar();
    main.add(toolBar);

    txtBuscar = new MSearchBox();
    txtBuscar.setPlaceHolder(constants.buscarCliente());
    main.add(txtBuscar);

    headerGrid = new HeaderGrid();
    main.add(headerGrid);

    headerGridDni = new Label(constants.dni());
    headerGrid.add(headerGridDni);

    headerGridCliente = new Label(constants.clientes());
    headerGrid.add(headerGridCliente);

    container = new FlowPanel();
    // main.add(container);

    scrollPanel = new ScrollPanel();
    scrollPanel.setScrollingEnabledY(true);
    scrollPanel.setScrollingEnabledX(false);
    scrollPanel.setAutoHandleResize(true);

    /*scrollPanel.setScrollingEnabledX(false);
    scrollPanel.setScrollingEnabledY(true);
    scrollPanel.setAutoHandleResize(true);*/
    // scrollPanel.setUsePos(MGWT.getOsDetection().isAndroid());

    grid = new GridCliente();
    container.add(grid);
    // widgetListTable.add(container);
    scrollPanel.setWidget(container);
    // cargarTabla();
    main.add(scrollPanel);
    Window.addResizeHandler(
        new ResizeHandler() {

          @Override
          public void onResize(ResizeEvent event) {
            // TODO Auto-generated method stub
            reCalcularWindows();
          }
        });
    initWidget(main);
  }
예제 #5
0
 public GlassPanel(boolean empty) {
   if (empty) {
     initWidget(emptyUiBinder.createAndBindUi(this));
     // message.setText("");
   } else {
     initWidget(uiBinder.createAndBindUi(this));
     // message.setText("loading");
   }
   Window.addResizeHandler(this);
 }
예제 #6
0
  public ResizableDataGrid() {
    Window.addResizeHandler(
        new ResizeHandler() {

          @Override
          public void onResize(ResizeEvent event) {
            redraw();
          }
        });
    setStyleName("border-bs");
  }
예제 #7
0
 public FolderInfoWidget() {
   initWidget(uiBinder.createAndBindUi(this));
   folderInfo.getElement().setId("pnlCollectionInfo");
   folderInfo.getElement().getStyle().setHeight(Window.getClientHeight(), Unit.PX);
   titleDetailsPnl.getElement().setAttribute("style", "border-bottom: 0px solid #ddd;");
   Window.addResizeHandler(
       new ResizeHandler() {
         @Override
         public void onResize(ResizeEvent event) {
           folderInfo.getElement().getStyle().setHeight(Window.getClientHeight(), Unit.PX);
         }
       });
 }
예제 #8
0
 public MenuAndPresenterView(RootPanel rootPanel, Integer menuHeightDecreaser) {
   super();
   this.menuHeightDecreaser = menuHeightDecreaser;
   rootPanel.clear();
   rootPanel.add(uiBinder.createAndBindUi(this));
   workAreaPanel.add(getPresenterHolderPanel());
   Window.addResizeHandler(
       new ResizeHandler() {
         @Override
         public void onResize(ResizeEvent event) {
           resizeMenuPanel();
         }
       });
   resizeMenuPanel();
 }
 /**
  * Set whether or not resize checking is enabled. If disabled, elements will still be resized on
  * window events, but the timer will not check their dimensions periodically.
  *
  * @param enabled true to enable the resize checking timer
  */
 public void setResizeCheckingEnabled(boolean enabled) {
   if (enabled && !resizeCheckingEnabled) {
     resizeCheckingEnabled = true;
     if (windowHandler == null) {
       windowHandler = Window.addResizeHandler(this);
     }
     resizeCheckTimer.schedule(resizeCheckDelay);
   } else if (!enabled && resizeCheckingEnabled) {
     resizeCheckingEnabled = false;
     if (windowHandler != null) {
       windowHandler.removeHandler();
       windowHandler = null;
     }
     resizeCheckTimer.cancel();
   }
 }
  public GameControlPanel() {
    super();
    childPanel = new FlowPanel();
    childPanel.setHeight("100%");
    childPanel.setWidth("100%");
    super.add(childPanel);
    this.setStyleName("control_game_panel");
    this.initKeyModifierHandlers();
    this.setFocus(true);
    Window.addResizeHandler(
        new ResizeHandler() {

          @Override
          public void onResize(ResizeEvent event) {
            GameControlPanel.this.onResize();
          }
        });
  }
  public GwtRenderingContext(Panel root, GwtAppConfiguration config)
      throws ParallaxRuntimeException {
    this.root = root;
    root.clear();

    Canvas canvasWidget = Canvas.createIfSupported();
    if (canvasWidget == null) throw new ParallaxRuntimeException("Canvas not supported");

    int width = root.getOffsetWidth();
    int height = root.getOffsetHeight();

    if (width == 0 || height == 0)
      new ParallaxRuntimeException("Width or Height of the Panel is 0");

    lastWidth = width;
    lastHeight = height;

    canvas = canvasWidget.getCanvasElement();
    root.add(canvasWidget);
    canvas.setWidth(width);
    canvas.setHeight(height);
    this.config = config;

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

    context = WebGLRenderingContext.getContext(canvas, attributes);
    context.viewport(0, 0, width, height);

    gl = new GwtGL20(context);

    renderer = new GLRenderer(gl, width, height);

    input = new GwtInput(canvas);

    addEventListeners();

    Window.addResizeHandler(this);
  }
예제 #12
0
    /** Show or hide the glass. */
    private void maybeShowGlass() {
      if (showing) {
        if (curPanel.isGlassEnabled) {
          Document.get().getBody().appendChild(curPanel.glass);

          resizeRegistration = Window.addResizeHandler(curPanel.glassResizer);
          curPanel.glassResizer.onResize(null);

          glassShowing = true;
        }
      } else if (glassShowing) {
        Document.get().getBody().removeChild(curPanel.glass);

        resizeRegistration.removeHandler();
        resizeRegistration = null;

        glassShowing = false;
      }
    }
예제 #13
0
  /** method for enabling protective glass panel to handle scrolling and window resizing problem */
  @Override
  protected void enableScrollWithBroswer() {
    // recalculate popup panel position
    Window.addResizeHandler(
        new ResizeHandler() {

          Timer resizeTimer =
              new Timer() {
                @Override
                public void run() {
                  setPopupPosition(
                      getLeft() + Window.getScrollLeft(), getTop() + Window.getScrollTop());
                }
              };

          @Override
          public void onResize(ResizeEvent event) {
            resizeTimer.cancel();
            resizeTimer.schedule(250 / 2);
          }
        });

    Window.addWindowScrollHandler(
        new ScrollHandler() {

          Timer resizeTimer =
              new Timer() {
                @Override
                public void run() {
                  setPopupPosition(
                      getLeft() + Window.getScrollLeft(), getTop() + Window.getScrollTop());
                }
              };

          @Override
          public void onWindowScroll(ScrollEvent arg0) {
            // TODO Auto-generated method stub
            resizeTimer.cancel();
            resizeTimer.schedule(20);
          }
        });
  }
  private void buildUI() {
    FlowPanel topPanel = new FlowPanel();
    SimplePanel toolbarWrapper = new SimplePanel();
    toolbarWrapper.setWidget(new BrowserToolbar());
    toolbarWrapper.setStyleName("files-toolbar"); // $NON-NLS-1$
    topPanel.add(toolbarWrapper);
    topPanel.add(new SolutionTreeWrapper(solutionTree));

    solutionNavigatorPanel.setStyleName("puc-vertical-split-panel");
    solutionNavigatorPanel.setWidth("100%");
    solutionNavigatorPanel.addNorth(topPanel, 500);
    solutionNavigatorPanel.add(filesListPanel);

    navigatorAndContentSplit.setStyleName("puc-horizontal-split-panel");
    navigatorAndContentSplit.addWest(solutionNavigatorPanel, 300);
    navigatorAndContentSplit.add(contentTabPanel);
    navigatorAndContentSplit.getElement().setAttribute("id", "solutionNavigatorAndContentPanel");

    Window.addResizeHandler(
        new ResizeHandler() {
          @Override
          public void onResize(ResizeEvent event) {
            adjustContentPanelSize();
          }
        });

    solutionNavigatorPanel.getElement().getParentElement().addClassName("puc-navigator-panel");
    solutionNavigatorPanel.getElement().getParentElement().removeAttribute("style");

    setStyleName("panelWithTitledToolbar"); // $NON-NLS-1$
    setHeight("100%"); // $NON-NLS-1$
    setWidth("100%"); // $NON-NLS-1$

    add(navigatorAndContentSplit);

    sinkEvents(Event.MOUSEEVENTS);

    navigatorAndContentSplit.getWidget(1).setWidth("100%");
    navigatorAndContentSplit.getElement().getStyle().setHeight(1, Unit.PX);
    contentTabPanel.getElement().getStyle().setHeight(1, Unit.PX);
  }
예제 #15
0
  public FormDialog(double heightPercentage, double widthPercentage) {
    this.heightPercentage = heightPercentage;
    this.widthPercentage = widthPercentage;
    setLayout(new FitLayout());

    Window.addResizeHandler(
        new ResizeHandler() {
          @Override
          public void onResize(ResizeEvent event) {
            resize();
          }
        });

    setBorders(false);
    setBodyBorder(false);

    setModal(true);
    setHeight((int) (Window.getClientHeight() * heightPercentage));
    setWidth((int) (Window.getClientWidth() * widthPercentage));
    setButtons("");
  }
  public DocumentationDisplay() {
    this.initWidget(Binder.BINDER.createAndBindUi(this));

    Window.addResizeHandler(
        new ResizeHandler() {

          @Override
          public void onResize(ResizeEvent event) {
            DocumentationDisplay.this.redraw(false);
          }
        });

    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {

              @Override
              public void execute() {
                DocumentationDisplay.this.redraw(true);
              }
            });
  }
예제 #17
0
  public iCalCalendarPanel() {

    // style this element as absolute position
    DOM.setStyleAttribute(this.getElement(), "position", "absolute");
    DOM.setStyleAttribute(this.getElement(), "top", "0px");
    DOM.setStyleAttribute(this.getElement(), "left", "0px");
    DOM.setStyleAttribute(this.getElement(), "padding", "0px");

    DOM.setStyleAttribute(DOM.getElementById("messageBox"), "display", "none");

    mainLayoutPanel.setWidth("100%");
    add(mainLayoutPanel);

    // add header
    headerPanel.setStyleName("gwt-cal-HeaderPanel");
    DOM.setInnerHTML(headerPanel.getElement(), " ");
    footerPanel.setStyleName("gwt-cal-FooterPanel");
    DOM.setInnerHTML(headerPanel.getElement(), " ");
    mainLayoutPanel.add(headerPanel, DockPanel.NORTH);
    mainLayoutPanel.add(footerPanel, DockPanel.SOUTH);

    // add left panel
    datePicker.setValue(new Date());
    dateLayoutPanel.add(datePicker, DockPanel.SOUTH);
    dateLayoutPanel.add(splitterPanel, DockPanel.SOUTH);
    splitterPanel.setStyleName("splitter");
    mainLayoutPanel.add(dateLayoutPanel, DockPanel.WEST);

    // CalendarFormat.INSTANCE.setFirstDayOfWeek(1);

    // change hour offset to false to facilitate iCal style
    settings.setOffsetHourLabels(true);
    settings.setTimeBlockClickNumber(Click.Double);
    // create day view
    calendar = new Calendar();
    calendar.setSettings(settings);
    // set style as google-cal
    calendar.setWidth("100%");
    // set today as default date
    mainLayoutPanel.add(calendar, DockPanel.CENTER);
    mainLayoutPanel.setCellVerticalAlignment(dateLayoutPanel, HasAlignment.ALIGN_BOTTOM);
    dateLayoutPanel.setCellVerticalAlignment(datePicker, HasAlignment.ALIGN_BOTTOM);
    dateLayoutPanel.setWidth("168px");

    // add today button
    todayButton.setStyleName("todayButton");
    todayButton.setText("Today");
    todayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            datePicker.setValue(new Date(), true);
            // dayView.setDate(new Date());
          }
        });
    previousDayButton.setStyleName("previousButton");
    previousDayButton.setHTML("«");
    previousDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Date d = datePicker.getValue();
            d.setDate(d.getDate() - 1);
            datePicker.setValue(d, true);
          }
        });
    nextDayButton.setStyleName("nextButton");
    nextDayButton.setHTML("»");
    nextDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Date d = datePicker.getValue();
            d.setDate(d.getDate() + 1);
            datePicker.setValue(d, true);
          }
        });
    headerPanelLayout.setWidget(0, 0, todayButton);
    headerPanelLayout.setWidget(0, 1, previousDayButton);

    oneDayButton.setText("1 Day");
    oneDayButton.setStyleName("dayButton");
    threeDayButton.setText("3 Day");
    threeDayButton.setStyleName("dayButton");
    threeDayButton.addStyleName("active");
    activeDayButton = threeDayButton;
    weekDayButton.setText("Work Week");
    weekDayButton.setStyleName("dayButton");
    monthButton.setText("Month");
    monthButton.setStyleName("dayButton");
    headerPanelLayout.setWidget(0, 2, oneDayButton);
    headerPanelLayout.setWidget(0, 3, threeDayButton);
    headerPanelLayout.setWidget(0, 4, weekDayButton);
    headerPanelLayout.setWidget(0, 5, monthButton);
    headerPanelLayout.setWidget(0, 6, nextDayButton);
    headerPanelLayout.setHTML(0, 7, " ");

    headerPanelLayout.getCellFormatter().setWidth(0, 0, "50%");
    headerPanelLayout.getCellFormatter().setWidth(0, 7, "50%");

    headerPanelLayout.setWidth("100%");
    headerPanelLayout.setCellPadding(0);
    headerPanelLayout.setCellSpacing(0);
    headerPanel.add(headerPanelLayout);

    footerPanel.add(
        new HTML(
            "<a href='http://code.google.com/p/gwt-cal'>gwt-cal</a> widget for Google Web Toolkit, GPLv3, by <a href='http://www.google.com/profiles/Brad.Rydzewski'>Brad Rydzewski</a>"));

    oneDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = oneDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 1);
            // calendar.scrollToHour(6);
          }
        });
    threeDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = threeDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 3);
            // calendar.scrollToHour(6);
          }
        });
    weekDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = weekDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 5);
            // calendar.scrollToHour(6);
          }
        });
    monthButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = monthButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.MONTH);
          }
        });

    datePicker.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            calendar.setDate(event.getValue());
          }
        });
    calendar.addDeleteHandler(
        new DeleteHandler<Appointment>() {
          public void onDelete(DeleteEvent<Appointment> event) {
            boolean commit =
                Window.confirm(
                    "Are you sure you want to delete appointment \""
                        + event.getTarget().getTitle()
                        + "\"");
            if (commit == false) {
              event.setCancelled(true);
              System.out.println("cancelled appointment deletion");
            }
          }
        });
    calendar.addOpenHandler(
        new OpenHandler<Appointment>() {
          public void onOpen(OpenEvent<Appointment> event) {
            Window.alert("You double-clicked appointment \"" + event.getTarget().getTitle() + "\"");
          }
        });

    calendar.addSelectionHandler(
        new SelectionHandler<Appointment>() {
          public void onSelection(SelectionEvent<Appointment> event) {
            System.out.println("selected " + event.getSelectedItem().getTitle());
          }
        });

    calendar.addTimeBlockClickHandler(
        new TimeBlockClickHandler<Date>() {
          public void onTimeBlockClick(TimeBlockClickEvent<Date> event) {
            Window.alert("you clicked time block " + event.getTarget());
          }
        });

    /* Generate random appointments */
    AppointmentBuilder.appointmentsPerDay = 5;
    AppointmentBuilder.HOURS = new Integer[] {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
    AppointmentBuilder.MINUTES = new Integer[] {0, 30};
    AppointmentBuilder.DURATIONS = new Integer[] {60, 90, 120, 180, 240, 600};
    AppointmentBuilder.DESCRIPTIONS[1] = "Best show on TV!";

    ArrayList<Appointment> appointments = AppointmentBuilder.build(AppointmentBuilder.ICAL_STYLES);
    /* Add appointments to day view */
    calendar.suspendLayout();
    calendar.addAppointments(appointments);

    calendar.resumeLayout();

    // window events to handle resizing
    Window.enableScrolling(false);
    Window.addResizeHandler(
        new ResizeHandler() {
          public void onResize(ResizeEvent event) {
            int h = event.getHeight();
            calendar.setHeight(
                h - headerPanel.getOffsetHeight() - footerPanel.getOffsetHeight() + "px");
          }
        });
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              public void execute() {
                calendar.setHeight(
                    Window.getClientHeight()
                        - headerPanel.getOffsetHeight()
                        - footerPanel.getOffsetHeight()
                        + "px");
                calendar.scrollToHour(6);
              }
            });
  }
예제 #18
0
  @Override
  public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) {
    ConnectorMap paintableMap = ConnectorMap.get(getConnection());
    getWidget().rendering = true;
    getWidget().id = getConnectorId();
    boolean firstPaint = getWidget().connection == null;
    getWidget().connection = client;

    getWidget().immediate = getState().immediate;
    getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY);
    String newTheme = uidl.getStringAttribute("theme");
    if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) {
      // Complete page refresh is needed due css can affect layout
      // calculations etc
      getWidget().reloadHostPage();
    } else {
      getWidget().theme = newTheme;
    }
    // this also implicitly removes old styles
    String styles = "";
    styles += getWidget().getStylePrimaryName() + " ";
    if (ComponentStateUtil.hasStyles(getState())) {
      for (String style : getState().styles) {
        styles += style + " ";
      }
    }
    if (!client.getConfiguration().isStandalone()) {
      styles += getWidget().getStylePrimaryName() + "-embedded";
    }
    getWidget().setStyleName(styles.trim());

    getWidget().makeScrollable();

    clickEventHandler.handleEventHandlerRegistration();

    // Process children
    int childIndex = 0;

    // Open URL:s
    boolean isClosed = false; // was this window closed?
    while (childIndex < uidl.getChildCount()
        && "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
      final UIDL open = uidl.getChildUIDL(childIndex);
      final String url = client.translateVaadinUri(open.getStringAttribute("src"));
      final String target = open.getStringAttribute("name");
      if (target == null) {
        // source will be opened to this browser window, but we may have
        // to finish rendering this window in case this is a download
        // (and window stays open).
        Scheduler.get()
            .scheduleDeferred(
                new Command() {
                  @Override
                  public void execute() {
                    VUI.goTo(url);
                  }
                });
      } else if ("_self".equals(target)) {
        // This window is closing (for sure). Only other opens are
        // relevant in this change. See #3558, #2144
        isClosed = true;
        VUI.goTo(url);
      } else {
        String options;
        boolean alwaysAsPopup = true;
        if (open.hasAttribute("popup")) {
          alwaysAsPopup = open.getBooleanAttribute("popup");
        }
        if (alwaysAsPopup) {
          if (open.hasAttribute("border")) {
            if (open.getStringAttribute("border").equals("minimal")) {
              options = "menubar=yes,location=no,status=no";
            } else {
              options = "menubar=no,location=no,status=no";
            }

          } else {
            options =
                "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes";
          }

          if (open.hasAttribute("width")) {
            int w = open.getIntAttribute("width");
            options += ",width=" + w;
          }
          if (open.hasAttribute("height")) {
            int h = open.getIntAttribute("height");
            options += ",height=" + h;
          }

          Window.open(url, target, options);
        } else {
          open(url, target);
        }
      }
      childIndex++;
    }
    if (isClosed) {
      // don't render the content, something else will be opened to this
      // browser view
      getWidget().rendering = false;
      return;
    }

    // Handle other UIDL children
    UIDL childUidl;
    while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
      String tag = childUidl.getTag().intern();
      if (tag == "actions") {
        if (getWidget().actionHandler == null) {
          getWidget().actionHandler = new ShortcutActionHandler(getWidget().id, client);
        }
        getWidget().actionHandler.updateActionMap(childUidl);
      } else if (tag == "notifications") {
        for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext(); ) {
          final UIDL notification = (UIDL) it.next();
          VNotification.showNotification(client, notification);
        }
      }
    }

    if (uidl.hasAttribute("focused")) {
      // set focused component when render phase is finished
      Scheduler.get()
          .scheduleDeferred(
              new Command() {
                @Override
                public void execute() {
                  ComponentConnector paintable =
                      (ComponentConnector) uidl.getPaintableAttribute("focused", getConnection());

                  final Widget toBeFocused = paintable.getWidget();
                  /*
                   * Two types of Widgets can be focused, either implementing
                   * GWT HasFocus of a thinner Vaadin specific Focusable
                   * interface.
                   */
                  if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) {
                    final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget =
                        (com.google.gwt.user.client.ui.Focusable) toBeFocused;
                    toBeFocusedWidget.setFocus(true);
                  } else if (toBeFocused instanceof Focusable) {
                    ((Focusable) toBeFocused).focus();
                  } else {
                    VConsole.log("Could not focus component");
                  }
                }
              });
    }

    // Add window listeners on first paint, to prevent premature
    // variablechanges
    if (firstPaint) {
      Window.addWindowClosingHandler(getWidget());
      Window.addResizeHandler(getWidget());
    }

    if (uidl.hasAttribute("scrollTo")) {
      final ComponentConnector connector =
          (ComponentConnector) uidl.getPaintableAttribute("scrollTo", getConnection());
      scrollIntoView(connector);
    }

    if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) {
      String location = uidl.getStringAttribute(UIConstants.LOCATION_VARIABLE);
      int fragmentIndex = location.indexOf('#');
      if (fragmentIndex >= 0) {
        getWidget().currentFragment = location.substring(fragmentIndex + 1);
      }
      if (!getWidget().currentFragment.equals(History.getToken())) {
        History.newItem(getWidget().currentFragment, true);
      }
    }

    if (firstPaint) {
      // Queue the initial window size to be sent with the following
      // request.
      getWidget().sendClientResized();
    }
    getWidget().rendering = false;
  }
예제 #19
0
파일: IntroPanel.java 프로젝트: Cuc4N/se7en
 public IntroPanel() {
   initWidget(uiBinder.createAndBindUi(this));
   Window.addResizeHandler(resizeHandler);
 }
예제 #20
0
  private void showChartAndTable(
      final String[] intervalsOrNames,
      final Integer[] values,
      final HashMap<String, Integer[]> userValues,
      final boolean showCharts) {

    final Runnable runnable =
        new Runnable() {

          @Override
          public void run() {

            if (showCharts) {
              int pieIndex = chartsLayout.getMemberNumber(htmlPieFlow);
              htmlPieFlow.removeFromParent();
              if (pieIndex < 0) {
                chartsLayout.addMember(htmlPieFlow);
              } else {
                chartsLayout.addMember(htmlPieFlow, pieIndex);
              }

              int index = chartsLayout.getMemberNumber(htmlLineFlow);
              htmlLineFlow.removeFromParent();
              if (index < 0) {
                chartsLayout.addMember(htmlLineFlow);
              } else {
                chartsLayout.addMember(htmlLineFlow, index);
              }
            } else {
              removeMember(chartsLayout);
            }

            setWidth100();

            if (userValues == null) {
              if (showCharts) {
                ChartUtils.drawPieChart(
                    JSOHelper.convertToJavaScriptArray(intervalsOrNames),
                    JSOHelper.convertToJavaScriptArray(values),
                    values.length,
                    PIE_CHART_NESTED_DIV_ID + userId,
                    (int) (UserStatisticsLayout.this.getWidth() * PIE_SIZE_CONVERSION));

                ChartUtils.drawLineChart(
                    JSOHelper.convertToJavaScriptArray(intervalsOrNames),
                    JSOHelper.convertToJavaScriptArray(values),
                    values.length,
                    LINE_CHART_NESTED_DIV_ID + userId,
                    (int) (UserStatisticsLayout.this.getWidth() * LINE_BAR_SIZE_CONVERSION));
              } else {
                setHeight(100);
                redraw();
              }
              HashMap<String, Integer[]> userVal = new HashMap<String, Integer[]>();
              userVal.put(userName, values);
              if (table == null) {
                table = new TableListGrid(intervalsOrNames, userVal);
                addMember(table);
              }
            } else {
              drawUnifyingChartsAndTables(intervalsOrNames, userValues, showCharts);
            }
          }
        };

    VisualizationUtils.loadVisualizationApi(runnable, PieChart.PACKAGE);

    Window.addResizeHandler(
        new ResizeHandler() {

          @Override
          public void onResize(ResizeEvent event) {
            com.google.gwt.user.client.Timer timer =
                new com.google.gwt.user.client.Timer() {

                  @Override
                  public void run() {
                    VisualizationUtils.loadVisualizationApi(
                        runnable,
                        com.google.gwt.visualization.client.visualizations.PieChart.PACKAGE);
                  }
                };
            timer.schedule(1);
          }
        });
  }
예제 #21
0
  /** initializeMap */
  private void initializeMap() {

    m_map = MQATileMap.newInstance(m_mapHolder.getElement());

    m_map.addControl(MQALargeZoomControl.newInstance());
    m_map.setZoomLevel(1);
    m_map.setCenter(MQALatLng.newInstance("0,0"));

    m_map.addMoveEndHandler(
        new MoveEndHandler() {
          @Override
          public void onMoveEnd(final MoveEndEvent event) {
            m_eventBus.fireEvent(new MapPanelBoundsChangedEvent(getBounds()));
          }
        });

    m_map.addClickHandler(
        new com.googlecode.gwtmapquest.transaction.event.ClickHandler() {

          @Override
          public void onClicked(
              final com.googlecode.gwtmapquest.transaction.event.ClickEvent event) {
            m_clickCounter.incrementCounter(event.getLL());
          }
        });

    m_map.addDblClickHandler(
        new DblClickHandler() {

          @Override
          public void onDblClicked(DblClickEvent event) {
            m_clickCounter.incrementCounter(event.getLL());
          }
        });

    m_map.addZoomEndHandler(
        new ZoomEndHandler() {
          @Override
          public void onZoomEnd(ZoomEndEvent event) {
            m_eventBus.fireEvent(new MapPanelBoundsChangedEvent(getBounds()));
          }
        });

    m_map.addShapeAddedHandler(
        new ShapeAddedHandler() {

          @Override
          public void onShapeAdded(ShapeAddedEvent event) {
            Element mqPoiDiv = DOM.getElementById("mqpoidiv");
            Element markerElement = Element.as(mqPoiDiv.getLastChild());
            updatePOILayer(markerElement);
          }
        });

    Window.addResizeHandler(
        new ResizeHandler() {
          @Override
          public void onResize(ResizeEvent event) {
            syncMapSizeWithParent();
          }
        });
  }
예제 #22
0
  public ExplorerViewImpl() {
    checkBoxList = new ArrayList<CheckBox>();
    selectedFileSet = new TreeSet<String>();
    clickHandlerStopPropagation =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            event.stopPropagation();
          }
        };

    DockPanel dockPanel = new DockPanel();
    dockPanel.setWidth("100%");

    viewPanel = new SimplePanel(dockPanel);
    initWidget(viewPanel);

    MenuBar menuBar = new MenuBar(false);
    dockPanel.add(menuBar, DockPanel.NORTH);
    menuBar.setHeight("30px");

    MenuBar mnbrFile = new MenuBar(true);

    MenuItem mntmFile = new MenuItem("File", false, mnbrFile);
    menuBar.addItem(mntmFile);

    mntmMakeDirectory =
        new MenuItem(
            "Make Directory",
            false,
            new Command() {
              public void execute() {
                new FileDialogBox(presenter, Operation.MAKE_DIRECTORY).center();
              }
            });
    mnbrFile.addItem(mntmMakeDirectory);

    mntmUploadFile =
        new MenuItem(
            "Upload",
            false,
            new Command() {
              public void execute() {
                new FileDialogBox(presenter, Operation.UPLOAD).center();
              }
            });
    mnbrFile.addItem(mntmUploadFile);

    mntmDownloadFile =
        new MenuItem(
            "Download",
            false,
            new Command() {
              public void execute() {
                presenter.downloadFiles(selectedFileSet);
              }
            });
    mnbrFile.addItem(mntmDownloadFile);
    mntmDownloadFile.setEnabled(false);

    mntmDeleteFile =
        new MenuItem(
            "Delete",
            false,
            new Command() {
              public void execute() {}
            });
    mnbrFile.addItem(mntmDeleteFile);
    mntmDeleteFile.setEnabled(false);

    mntmRenameFile =
        new MenuItem(
            "Rename",
            false,
            new Command() {
              public void execute() {}
            });
    mnbrFile.addItem(mntmRenameFile);
    mntmRenameFile.setEnabled(false);

    MenuItemSeparator misFile = new MenuItemSeparator();
    mnbrFile.addSeparator(misFile);

    MenuItem mntmCloseVolume =
        new MenuItem(
            "Close volume",
            false,
            new Command() {
              public void execute() {
                presenter.closeVolume();
              }
            });
    mnbrFile.addItem(mntmCloseVolume);

    MenuBar mnbrHelp = new MenuBar(true);

    MenuItem mntmHelp = new MenuItem("Help", false, mnbrHelp);
    menuBar.addItem(mntmHelp);

    MenuItem mntmAbout =
        new MenuItem(
            "About",
            false,
            new Command() {
              public void execute() {
                Window.alert("");
              }
            });
    mnbrHelp.addItem(mntmAbout);

    flowPanel = new FlowPanel();

    explorerScrollPanel = new ScrollPanel(flowPanel);
    dockPanel.add(explorerScrollPanel, DockPanel.CENTER);
    explorerScrollPanel.sinkEvents(Event.ONCLICK);
    explorerScrollPanel.addHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            setAllCheckBoxFalse();
          }
        },
        ClickEvent.getType());
    explorerScrollPanel.sinkEvents(Event.ONCONTEXTMENU);
    explorerScrollPanel.addHandler(
        new ContextMenuHandler() {
          public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
            event.stopPropagation();
            FileContextMenu fileContextMenu =
                new FileContextMenu(presenter, ContextMenuType.BACKGROUND);
            fileContextMenu.setPopupPosition(
                event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
            fileContextMenu.show();
            setAllCheckBoxFalse();
          }
        },
        ContextMenuEvent.getType());

    Tree tree = new Tree();

    treeScrollPanel = new ScrollPanel(tree);
    dockPanel.add(treeScrollPanel, DockPanel.WEST);
    treeScrollPanel.setWidth("120px");

    resizeScrollPanel();
    Window.addResizeHandler(
        new ResizeHandler() {
          public void onResize(ResizeEvent event) {
            resizeScrollPanel();
          }
        });

    tree.setAnimationEnabled(true);
    // tree.addOpenHandler(new OpenHandler<TreeItem>() {
    // public void onOpen(OpenEvent<TreeItem> event) {
    // TreeItem trtmTarget = event.getTarget();
    // String path = getPath(trtmTarget);
    // for (int i = 0; i < trtmTarget.getChildCount(); i++) {
    // TreeItem trtmChild = trtmTarget.getChild(i);
    // String childPath = path + trtmChild.getText();
    // presenter.getFiles(trtmChild, childPath);
    // }
    // }
    // });
    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {
          public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem selectedItem = event.getSelectedItem();
            String path = getPath(selectedItem);
            selectedItem.setState(true, true);
            presenter.changeDirectory(path);
          }
        });

    trtmRoot = new TreeItem();
    trtmSelectedItem = trtmRoot;
    tree.addItem(trtmRoot);
    trtmRoot.setText("/");
  }
 public void bind() {
   windowResizeRegistration = Window.addResizeHandler(this);
   forceResizeEventRegistration = eventBus.addHandler(ForceResizeEvent.getType(), this);
 }
 public ExamplePanel() {
   initWidget(uiBinder.createAndBindUi(this));
   setWidgetToMaxWidthAndHeight();
   Window.addResizeHandler(resizeHandler);
   setWidgetAsExample(new IntroPanel());
 }
예제 #25
0
  public GeoStory() {
    panel = new SplitLayoutPanel();
    types = new GeoEventTypes();
    model = new GeoStoryModel(types);
    space = new Space(LatLng.newInstance(45.50, -73.60), 4, types, model);
    time = new TimeLine(model, types);
    list = new ListBox(true);
    list.setVisibleItemCount(20);
    for (GeoStoryItem i : model.getItems()) {
      list.addItem(i.toString());
    }
    {
      controls = new VerticalPanel();
      {
        email = new TextBox();
        email.setText("*****@*****.**");
        controls.add(email);
        email.addChangeHandler(
            new ChangeHandler() {
              @Override
              public void onChange(ChangeEvent event) {}
            });
      }
      {
        Button getFromServer = new Button("Get from server");
        getFromServer.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                types.getEventFromServer.shareEvent(getEmail());
              }
            });
        controls.add(getFromServer);
      }
      {
        Button dump = new Button("Json dump");
        dump.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                StringBuilder sb = new StringBuilder();
                for (GeoStoryItem item : model.getItems()) {
                  sb.append(item.toJSON() + "\n");
                }
                DialogBox db = new DialogBox(true);
                TextArea ta = new TextArea();
                ta.setEnabled(true);
                ta.setText(sb.toString());
                db.add(ta);
                db.center();
                db.show();
              }
            });
        controls.add(dump);
      }
      {
        Button jsonload = new Button("Json load");
        jsonload.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                Question<String> q = new ContentQuestion("Entrer la cha”ne JSON");
                final QPanel textContent = new QPanel(new Questionnaire(q));
                textContent.center();
                textContent.show();
                q.answerChannel()
                    .registerHandler(
                        new WHandler<String>() {
                          @Override
                          public void onEvent(WEvent<String> elt) {
                            String[] lines = elt.getElement().split("\n");
                            for (String item : lines) {
                              JSONValue json = JSONParser.parse(item);
                              JSONObject object = json.isObject();
                              GeoStoryItem gsi = GeoStoryItem.fromJSON(object);
                              types.itemAdded.shareEvent(gsi);
                              types.centerEvent.shareEvent(null);
                            }
                          }
                        });
              }
            });
        controls.add(jsonload);
      }
      {
        Button popRandom = new Button("Populate at random");
        controls.add(popRandom);
        popRandom.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent event) {
                model.populateRandomly(10);
                types.centerEvent.shareEvent(null);
              }
            });
      }
      {
        Button popFromText = new Button("Populate from text");
        controls.add(popFromText);
        popFromText.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                Question<String> q = new ContentQuestion("Description des evenements");
                final QPanel textContent = new QPanel(new Questionnaire(q));
                textContent.center();
                textContent.show();
                q.answerChannel()
                    .registerHandler(
                        new WHandler<String>() {
                          @Override
                          public void onEvent(WEvent<String> elt) {
                            List<Triple<String, Interval, String>> res =
                                GeoStoryParser.parse(elt.getElement());
                            int delay = 0;
                            final Geocoder geo = new Geocoder();
                            for (final Triple<String, Interval, String> indiv : res) {
                              geodecode(geo, indiv, delay = delay + 100);
                            }
                            textContent.hide();
                          }
                        });
              }
            });
      }
      {
        Button cia = new Button("Draw borders");
        controls.add(cia);
        cia.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                for (final Polyline poly : CIA.segments(CIA.northamerica)) {
                  space.space.addOverlay(poly);
                }
                for (final Polyline poly : CIA.segments(CIA.europe)) {
                  space.space.addOverlay(poly);
                }
              }
            });
      }
      {
        Button family = new Button("Genealogy info");
        controls.add(family);
        family.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                Geocoder geo = new Geocoder();
                for (final Triple<String, Interval, String> indiv : Genea.people()) {
                  geodecode(geo, indiv, 100);
                }
              }
            });
      }
      {
        Button addOne = new Button("Add one");
        addOne.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                ContentQuestion desc = new ContentQuestion("Description?");
                WhenQuestion when = new WhenQuestion("Quand?");
                ContentQuestion plac = new ContentQuestion("Nom du lieu?");
                WhereQuestion wher = new WhereQuestion("Sur la carte?", plac.answerChannel());
                Questionnaire q = new Questionnaire(desc, when, plac, wher);
                QPanel tested = new QPanel(q);
                // tested.setSize("50%", "50%");
                q.answerChannel()
                    .registerHandler(
                        new WHandler<Map<String, String>>() {
                          @Override
                          public void onEvent(WEvent<Map<String, String>> elt) {
                            Map<String, String> map = elt.getElement();
                            // Window.alert("Questionnaire are  "+ elt.getElement().toString());
                            String[] coord = map.get("Sur la carte?").split("\\|");
                            // Window.alert("Questionnaire are  "+ elt.getElement().toString()+"
                            // "+Arrays.toString(coord));
                            LatLng ll =
                                LatLng.newInstance(
                                    Double.parseDouble(coord[0]),
                                    Double.parseDouble(coord[1])); // ;
                            String[] dates = map.get("Quand?").split("->");
                            Interval interval =
                                new Interval(
                                    WhenQuestion.dtf.parse(dates[0]),
                                    WhenQuestion.dtf.parse(dates[1]));
                            GeoStoryItem geo =
                                new GeoStoryItem(
                                    interval, map.get("Nom du lieu?"), ll, map.get("Description?"));
                            Window.alert(
                                "GeoStory "
                                    + geo
                                    + " "
                                    + Arrays.toString(dates)
                                    + " "
                                    + map.get("Quand?"));
                            types.itemAdded.shareEvent(geo);
                            types.centerEvent.shareEvent(null);
                          }
                        });
                tested.center();
                tested.show();
              }
            });
        controls.add(addOne);
      }
      {
        Button reset = new Button("Reset");
        reset.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                model.reset();
                types.centerEvent.shareEvent(null);
              }
            });
        controls.add(reset);
      }
      {
        final TextBox search = new TextBox();
        search.setTitle("Search");
        final Button go = new Button("go");
        go.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                Set<GeoStoryItem> itemsSet = model.getItems();
                // filtering
                if (search.getText() != null && !search.getText().isEmpty()) {
                  for (GeoStoryItem geoStoryItem : itemsSet) {
                    if (geoStoryItem.getDescription().contains(search.getText())) {
                      geoStoryItem.setVisible(true);
                    } else {
                      geoStoryItem.setVisible(false);
                    }
                  }
                }
                types.centerEvent.shareEvent(null);
              }
            });
        controls.add(go);
        controls.add(search);
      }
      {
        final Button removeFilter = new Button("remove filter");
        removeFilter.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                Set<GeoStoryItem> itemsSet = model.getItems();
                // filtering
                for (GeoStoryItem geoStoryItem : itemsSet) {
                  geoStoryItem.setVisible(true);
                }
                types.centerEvent.shareEvent(null);
              }
            });
        controls.add(removeFilter);
      }
      panel.addSouth(time, 150);
      panel.addWest(controls, 150);
      panel.add(space);
      Window.addResizeHandler(this);
    }
    this.initWidget(panel);
    // Short term timer to check and resize the badly initialized map.
    Timer t =
        new Timer() {
          public void run() {
            space.checkResizeAndCenter();
            time.init();
          }
        };
    t.schedule(1);
  }
예제 #26
0
파일: GSS.java 프로젝트: davideuler/gss
  @Override
  public void onModuleLoad() {
    // Initialize the singleton before calling the constructors of the
    // various widgets that might call GSS.get().
    singleton = this;
    parseUserCredentials();

    topPanel = new TopPanel(GSS.images);
    topPanel.setWidth("100%");

    messagePanel.setWidth("100%");
    messagePanel.setVisible(false);

    search = new Search(images);
    searchStatus.add(search, DockPanel.WEST);
    searchStatus.add(userDetailsPanel, DockPanel.EAST);
    searchStatus.setCellHorizontalAlignment(userDetailsPanel, HasHorizontalAlignment.ALIGN_RIGHT);
    searchStatus.setCellVerticalAlignment(search, HasVerticalAlignment.ALIGN_MIDDLE);
    searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    searchStatus.setWidth("100%");

    fileList = new FileList(images);

    searchResults = new SearchResults(images);

    // Inner contains the various lists.
    inner.sinkEvents(Event.ONCONTEXTMENU);
    inner.setAnimationEnabled(true);
    inner.getTabBar().addStyleName("gss-MainTabBar");
    inner.getDeckPanel().addStyleName("gss-MainTabPanelBottom");
    inner.add(
        fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);

    inner.add(
        groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true);
    inner.add(
        searchResults,
        createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"),
        true);
    // inner.add(new CellTreeView(images),
    // createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true);
    inner.setWidth("100%");
    inner.selectTab(0);

    inner.addSelectionHandler(
        new SelectionHandler<Integer>() {

          @Override
          public void onSelection(SelectionEvent<Integer> event) {
            int tabIndex = event.getSelectedItem();
            //				TreeItem treeItem = GSS.get().getFolders().getCurrent();
            switch (tabIndex) {
              case 0:
                //						Files tab selected
                // fileList.clearSelectedRows();
                fileList.updateCurrentlyShowingStats();
                break;
              case 1:
                //						Groups tab selected
                groups.updateCurrentlyShowingStats();
                updateHistory("Groups");
                break;
              case 2:
                //						Search tab selected
                searchResults.clearSelectedRows();
                searchResults.updateCurrentlyShowingStats();
                updateHistory("Search");
                break;
            }
          }
        });
    //		If the application starts with no history token, redirect to a new "Files" state
    String initToken = History.getToken();
    if (initToken.length() == 0) History.newItem("Files");
    //		   Add history listener to handle any history events
    History.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            String tokenInput = event.getValue();
            String historyToken = handleSpecialFolderNames(tokenInput);
            try {
              if (historyToken.equals("Search")) inner.selectTab(2);
              else if (historyToken.equals("Groups")) inner.selectTab(1);
              else if (historyToken.equals("Files") || historyToken.length() == 0)
                inner.selectTab(0);
              else {
                /*TODO: CELLTREE
                PopupTree popupTree = GSS.get().getFolders().getPopupTree();
                TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken);
                SelectionEvent.fire(popupTree, treeObj);
                */
              }
            } catch (IndexOutOfBoundsException e) {
              inner.selectTab(0);
            }
          }
        });

    // Add the left and right panels to the split panel.
    splitPanel.setLeftWidget(treeView);
    splitPanel.setRightWidget(inner);
    splitPanel.setSplitPosition("25%");
    splitPanel.setSize("100%", "100%");
    splitPanel.addStyleName("gss-splitPanel");

    // Create a dock panel that will contain the menu bar at the top,
    // the shortcuts to the left, the status bar at the bottom and the
    // right panel taking the rest.
    VerticalPanel outer = new VerticalPanel();
    outer.add(topPanel);
    outer.add(searchStatus);
    outer.add(messagePanel);
    outer.add(splitPanel);
    outer.add(statusPanel);
    outer.setWidth("100%");
    outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);

    outer.setSpacing(4);

    // Hook the window resize event, so that we can adjust the UI.
    Window.addResizeHandler(this);
    // Clear out the window's built-in margin, because we want to take
    // advantage of the entire client area.
    Window.setMargin("0px");
    // Finally, add the outer panel to the RootPanel, so that it will be
    // displayed.
    RootPanel.get().add(outer);
    // 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() {
            onWindowResized(Window.getClientHeight());
          }
        });
  }
예제 #27
0
파일: GWTGraphics.java 프로젝트: ylck/LGame
  public GWTGraphics(final Panel panel, final LGame game, final GWTSetting cfg) {
    super(game, new GWTGL20(), new Scale(cfg.scaleFactor));

    this.config = cfg;
    Document doc = Document.get();
    this.dummyCanvas = doc.createCanvasElement();
    this.dummyCtx = dummyCanvas.getContext2d();

    Element root = panel.getElement();

    this.rootElement = root;

    measureElement = doc.createDivElement();
    measureElement.getStyle().setVisibility(Style.Visibility.HIDDEN);
    measureElement.getStyle().setPosition(Style.Position.ABSOLUTE);
    measureElement.getStyle().setTop(-500, Unit.PX);
    measureElement.getStyle().setOverflow(Style.Overflow.VISIBLE);
    measureElement.getStyle().setWhiteSpace(Style.WhiteSpace.NOWRAP);
    root.appendChild(measureElement);

    mouseScale = config.scaleFactor / Loon.devicePixelRatio();

    canvas = Document.get().createCanvasElement();
    root.appendChild(canvas);
    if (config.scaling()) {
      setSize(
          config.width_zoom > 0 ? config.width_zoom : root.getOffsetWidth(),
          config.height_zoom > 0 ? config.height_zoom : root.getOffsetHeight());
    } else {
      setSize(
          config.width > 0 ? config.width : root.getOffsetWidth(),
          config.height > 0 ? config.height : root.getOffsetHeight());
    }
    WebGLContextAttributes attrs = WebGLContextAttributes.create();
    attrs.setAntialias(config.antiAliasing);
    attrs.setStencil(config.stencil);
    attrs.setAlpha(config.transparentCanvas);
    attrs.setPremultipliedAlpha(config.premultipliedAlpha);
    attrs.setPreserveDrawingBuffer(config.preserveDrawingBuffer);

    WebGLRenderingContext glc = WebGLRenderingContext.getContext(canvas, attrs);
    if (glc == null) {
      throw new RuntimeException("Unable to create GL context");
    }

    ((GWTGL20) gl).init(glc);

    if (config.scaling()) {
      glc.viewport(0, 0, config.width_zoom, config.height_zoom);
    } else {
      glc.viewport(0, 0, config.width, config.height);
    }

    if (config.fullscreen) {
      Window.addResizeHandler(
          new ResizeHandler() {
            @Override
            public void onResize(ResizeEvent event) {
              if (getScreenWidthJSNI() == event.getWidth()
                  && getScreenHeightJSNI() == event.getHeight()) {
                float width = LSystem.viewSize.width(), height = LSystem.viewSize.height();
                experimentalScale =
                    Math.min(getScreenWidthJSNI() / width, getScreenHeightJSNI() / height);

                int yOfs = (int) ((getScreenHeightJSNI() - height * experimentalScale) / 3.f);
                int xOfs = (int) ((getScreenWidthJSNI() - width * experimentalScale) / 2.f);
                rootElement.setAttribute(
                    "style",
                    "width:"
                        + experimentalScale * width
                        + "px; "
                        + "height:"
                        + experimentalScale * height
                        + "px; "
                        + "position:absolute; left:"
                        + xOfs
                        + "px; top:"
                        + yOfs);
                Document.get().getBody().addClassName("fullscreen");
              } else {
                experimentalScale = 1;
                rootElement.removeAttribute("style");
                Document.get().getBody().removeClassName("fullscreen");
              }
            }
          });
    }

    Loon.self.addHandler(
        new OrientationChangedHandler() {
          @Override
          public void onChanged(Orientation newOrientation) {
            int width = Loon.self.getContainerWidth();
            int height = Loon.self.getContainerHeight();
            game.log().info("update screen size width :" + width + " height :" + height);
            setSize(width, height);
          }
        });
  }