コード例 #1
0
ファイル: GridConnector.java プロジェクト: mekuate/vaadin
        @Override
        public void reapplyDetailsVisibility(final int rowIndex, final JsonObject row) {

          if (hasDetailsOpen(row)) {
            // Command for opening details row.
            ScheduledCommand openDetails =
                new ScheduledCommand() {
                  @Override
                  public void execute() {
                    // Re-apply to force redraw.
                    getWidget().setDetailsVisible(rowIndex, false);
                    getWidget().setDetailsVisible(rowIndex, true);
                    lazyDetailsScroller.detailsOpened(rowIndex);
                  }
                };

            if (initialChange) {
              Scheduler.get().scheduleDeferred(openDetails);
            } else {
              Scheduler.get().scheduleFinally(openDetails);
            }
          } else {
            getWidget().setDetailsVisible(rowIndex, false);
          }
        }
コード例 #2
0
ファイル: PTScheduler.java プロジェクト: remfalc/PonySDK
 @Override
 public void update(final PTInstruction update, final UIService uiService) {
   final long commandID = update.getLong(PROPERTY.COMMAND_ID);
   if (update.containsKey(PROPERTY.STOP)) {
     // Stop the command
     commandByIDs.remove(commandID).cancel();
   } else if (update.containsKey(PROPERTY.FIXDELAY)) {
     // Fix-delay
     // Wait for execution terminated before scheduling again
     final SchedulerCommand previousCmd = commandByIDs.remove(commandID);
     if (previousCmd != null) previousCmd.cancel();
     final int delay = update.getInt(PROPERTY.FIXDELAY);
     final FixDelayCommand command =
         new FixDelayCommand(uiService, update.getObjectID(), commandID, delay);
     Scheduler.get().scheduleFixedDelay(command, delay);
     commandByIDs.put(commandID, command);
   } else if (update.containsKey(PROPERTY.FIXRATE)) {
     // Fix-rate
     final SchedulerCommand previousCmd = commandByIDs.remove(commandID);
     if (previousCmd != null) previousCmd.cancel();
     final int delay = update.getInt(PROPERTY.FIXRATE);
     final FixRateCommand command =
         new FixRateCommand(uiService, update.getObjectID(), commandID, delay);
     Scheduler.get().scheduleFixedDelay(command, delay);
     commandByIDs.put(commandID, command);
   }
 }
コード例 #3
0
ファイル: VersionBrowser.java プロジェクト: ronggenliu/guvnor
 protected void clickLoadHistory() {
   showBusyIcon();
   Scheduler scheduler = Scheduler.get();
   scheduler.scheduleDeferred(
       new Command() {
         public void execute() {
           loadHistoryData();
         }
       });
 }
コード例 #4
0
  private void doBuild(
      final Panel buildResults,
      final String statusOperator,
      final String statusValue,
      final boolean enableStatusSelector,
      final String categoryOperator,
      final String category,
      final boolean enableCategorySelector,
      final String customSelector) {
    buildResults.clear();

    final HorizontalPanel busy = new HorizontalPanel();
    busy.add(new Label(constants.ValidatingAndBuildingPackagePleaseWait()));
    busy.add(new Image(images.redAnime()));

    buildResults.add(busy);

    Scheduler scheduler = Scheduler.get();
    scheduler.scheduleDeferred(
        new Command() {
          public void execute() {
            RepositoryServiceFactory.getPackageService()
                .buildPackage(
                    conf.getUuid(),
                    true,
                    buildMode,
                    statusOperator,
                    statusValue,
                    enableStatusSelector,
                    categoryOperator,
                    category,
                    enableCategorySelector,
                    customSelector,
                    new GenericCallback<BuilderResult>() {
                      public void onSuccess(BuilderResult result) {
                        LoadingPopup.close();
                        if (result == null || !result.hasLines()) {
                          showSuccessfulBuild(buildResults);
                        } else {
                          showBuilderErrors(result, buildResults, clientFactory);
                        }
                      }

                      public void onFailure(Throwable t) {
                        buildResults.clear();
                        super.onFailure(t);
                      }
                    });
          }
        });
  }
コード例 #5
0
ファイル: Updater.java プロジェクト: arrayexpress/annotare2
  private void getUpdates(int ms) {
    Scheduler.get()
        .scheduleFixedDelay(
            new Scheduler.RepeatingCommand() {
              @Override
              public boolean execute() {
                updateRequests = 0;
                onAsyncUpdate(
                    new ReportingAsyncCallback<Boolean>(FailureMessage.UNABLE_TO_LOAD_UPDATES) {
                      @Override
                      public void onFailure(Throwable caught) {
                        super.onFailure(caught);
                        stop();
                      }

                      @Override
                      public void onSuccess(Boolean result) {
                        if (result || updateRequests > 0) {
                          getUpdates(millis);
                        } else {
                          stop();
                        }
                      }
                    });
                return false;
              }
            },
            ms);
  }
コード例 #6
0
 /** @see org.artificer.ui.client.shared.services.IOntologyService#list() */
 public void list(
     boolean forceRefresh, final IServiceInvocationHandler<OntologyResultSetBean> handler) {
   if (summaryCache != null && !forceRefresh) {
     Scheduler.get()
         .scheduleDeferred(
             new Command() {
               public void execute() {
                 handler.onReturn(summaryCache);
               }
             });
   } else {
     RemoteCallback<OntologyResultSetBean> successCallback =
         new DelegatingRemoteCallback<OntologyResultSetBean>(handler) {
           @Override
           public void callback(OntologyResultSetBean response) {
             summaryCache = response;
             super.callback(response);
           }
         };
     ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
     try {
       remoteOntologyService.call(successCallback, errorCallback).list();
     } catch (ArtificerUiException e) {
       errorCallback.error(null, e);
     }
   }
 }
コード例 #7
0
  /** @see com.google.gwt.user.client.ui.FocusWidget#onAttach() */
  @Override
  protected void onAttach() {

    super.onAttach();
    if (!m_hasBeenAttached) {
      m_hasBeenAttached = true;
      Scheduler.get()
          .scheduleDeferred(
              new ScheduledCommand() {

                public void execute() {

                  if (isAttached()) {
                    m_editorHeight = calculateEditorHeight();
                    m_id = ensureId(getMainElement());
                    m_width = getElement().getOffsetWidth() - 2;
                    checkLibraries();
                    initNative();
                    if (!m_active) {
                      getElement().addClassName(I_LayoutBundle.INSTANCE.form().inActive());
                    }
                  } else {
                    resetAtachedFlag();
                  }
                }
              });
    }
  }
コード例 #8
0
  @Override
  protected void onInit(final BusEvent<?> event) {
    final OpenMillerTree e = (OpenMillerTree) event;
    maxlevelchildren = e.maxLevelChildren();
    maxlevelparents = e.maxLevelParents();
    modifyDataSource(e.datasource);
    treecolumns = new LinkedHashMap<Integer, TreeColumn>();
    layout = new ColumnStack();
    for (int i = maxlevelparents; i <= maxlevelchildren; i++) {
      final TreeColumn newcolumn = new TreeColumn(i);
      layout.addMember(newcolumn);
      treecolumns.put(i, newcolumn);
    }
    Scheduler.get()
        .scheduleIncremental(
            new Scheduler.RepeatingCommand() {
              @Override
              public boolean execute() {
                if (i <= maxlevelchildren) {
                  treecolumns.get(i).setDataSource(e.datasource);
                  ++i;
                  return true;
                } else {
                  setField(MillerTreeView.DESCRIPTION_DE);
                  asCanvas().addChild(layout);
                  layout.resize();
                  scrollToCenter();
                  return false;
                }
              }

              private int i = maxlevelparents;
            });
  }
コード例 #9
0
    void redrawParents(final int level, final int id) {
      if (level > maxlevelparents) {
        Scheduler.get()
            .scheduleIncremental(
                new Scheduler.RepeatingCommand() {

                  @Override
                  public boolean execute() {
                    if (i >= maxlevelparents) {
                      treecolumns.get(i).hideMembers();
                      --i;
                      return true;
                    } else {
                      treecolumns.get(level - 1).showMembers(id);
                      return false;
                    }
                  }

                  private int i = level - 1;
                });
      }
      if (level != 0) {
        treecolumns.get(level).resetSelectedFlag();
      }
    }
コード例 #10
0
  public DocTabLayoutPanel(boolean closeableTabs, int padding, int rightMargin) {
    super(BAR_HEIGHT, Style.Unit.PX);
    closeableTabs_ = closeableTabs;
    padding_ = padding;
    rightMargin_ = rightMargin;
    styles_ = ThemeResources.INSTANCE.themeStyles();
    addStyleName(styles_.docTabPanel());
    addStyleName(styles_.moduleTabPanel());
    dragManager_ = new DragManager();

    // listen for global drag events (these are broadcasted from other windows
    // to notify us of incoming drags)
    events_ = RStudioGinjector.INSTANCE.getEventBus();
    events_.addHandler(DocTabDragStartedEvent.TYPE, dragManager_);

    // sink drag-related events on the tab bar element; unfortunately
    // GWT does not provide bits for the drag-related events, and
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              @Override
              public void execute() {
                Element tabBar = getTabBarElement();
                DOM.sinkBitlessEvent(tabBar, "dragenter");
                DOM.sinkBitlessEvent(tabBar, "dragover");
                DOM.sinkBitlessEvent(tabBar, "dragend");
                DOM.sinkBitlessEvent(tabBar, "dragleave");
                DOM.sinkBitlessEvent(tabBar, "drop");
                Event.setEventListener(tabBar, dragManager_);
              }
            });
  }
コード例 #11
0
  public void onSuccess(UserModel user) {
    deck.showWidget(1);

    if (!GwtClientUtils.preSuccessCheck(user, null)) {
      return;
    }

    // user exist - then fill all user information form and display information.
    if (user.getUid() != null && user.getUid() > 0) {
      fillPanel(user);
      form1.fillFields(user);
      form2.fillFields(user);
      form3.fillFields(user);
      editDeck.showWidget(0);
    }
    // image loading and center
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              public void execute() {
                ProfileDialog.this.center();
              }
            });
    // TODO: user not exist, error message display
  }
コード例 #12
0
ファイル: ApplicationQuit.java プロジェクト: rowhit/rstudio
  private void sendPing(
      final String afterRestartCommand,
      int delayMs,
      final int maxRetries,
      final Command onCompleted) {
    Scheduler.get()
        .scheduleFixedDelay(
            new RepeatingCommand() {

              private int retries_ = 0;
              private boolean pingDelivered_ = false;
              private boolean pingInFlight_ = false;

              @Override
              public boolean execute() {
                // if we've already delivered the ping or our retry count
                // is exhausted then return false
                if (pingDelivered_ || (++retries_ > maxRetries)) return false;

                if (!pingInFlight_) {
                  pingInFlight_ = true;
                  server_.ping(
                      new VoidServerRequestCallback() {
                        @Override
                        protected void onSuccess() {
                          pingInFlight_ = false;

                          if (!pingDelivered_) {
                            pingDelivered_ = true;

                            // issue after restart command
                            if (!StringUtil.isNullOrEmpty(afterRestartCommand)) {
                              eventBus_.fireEvent(
                                  new SendToConsoleEvent(afterRestartCommand, true, true));
                            }
                            // otherwise make sure the console knows we
                            // restarted (ensure prompt and set focus)
                            else {
                              eventBus_.fireEvent(new ConsoleRestartRCompletedEvent());
                            }
                          }

                          if (onCompleted != null) onCompleted.execute();
                        }

                        @Override
                        protected void onFailure() {
                          pingInFlight_ = false;

                          if (onCompleted != null) onCompleted.execute();
                        }
                      });
                }

                // keep trying until the ping is delivered
                return true;
              }
            },
            delayMs);
  }
コード例 #13
0
  private ShortcutManager() {
    keyBuffer_ = new KeySequence();
    keyTimer_ =
        new Timer() {
          @Override
          public void run() {
            keyBuffer_.clear();
          }
        };

    // Defer injection because the ShortcutManager is constructed
    // very eagerly (to allow for codegen stuff in ShortcutsEmitter
    // to work)
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              @Override
              public void execute() {
                RStudioGinjector.INSTANCE.injectMembers(ShortcutManager.this);
                events_.addHandler(
                    AceKeyboardActivityEvent.TYPE,
                    new AceKeyboardActivityEvent.Handler() {
                      @Override
                      public void onAceKeyboardActivity(AceKeyboardActivityEvent event) {
                        if (!event.isChainEvent()) keyBuffer_.clear();
                      }
                    });
              }
            });

    // NOTE: Because this class is used as a singleton and is never
    // destroyed it's not necessary to manage lifetime of this event handler
    Event.addNativePreviewHandler(this);
    addPostViewHandler();
  }
コード例 #14
0
ファイル: DMRHandler.java プロジェクト: panossot/core-1
  @Override
  public DispatchRequest execute(
      DMRAction action,
      final AsyncCallback<DMRResponse> resultCallback,
      Map<String, String> properties) {
    assert action.getOperation() != null;
    final ModelNode operation = action.getOperation();

    // diagnostics, development only
    if (!GWT.isScript()) {
      Scheduler.get()
          .scheduleDeferred(
              new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                  decomposeAndLog(operation);
                }
              });
    }

    // Request request = executeRequest(resultCallback, GWT.isScript() ? operation :
    // runAsRole(operation));
    // TODO: https://issues.jboss.org/browse/HAL-100
    Request request = executeRequest(resultCallback, runAsRole(operation, properties));
    return new DispatchRequestHandle(request);
  }
コード例 #15
0
    private void setAssociatedWidgetSize(double size) {
      double maxSize = getMaxSize();
      if (size > maxSize) {
        size = maxSize;
      }

      if (snapClosedSize > 0 && size < snapClosedSize) {
        size = 0;
      } else if (size < minSize) {
        size = minSize;
      }

      LayoutData layout = (LayoutData) target.getLayoutData();
      if (size == layout.size) {
        return;
      }

      // Adjust our view until the deferred layout gets scheduled.
      centerSize += layout.size - size;
      layout.size = size;

      // Defer actually updating the layout, so that if we receive many
      // mouse events before layout/paint occurs, we'll only update once.
      if (layoutCommand == null) {
        layoutCommand =
            new ScheduledCommand() {
              @Override
              public void execute() {
                layoutCommand = null;
                forceLayout();
              }
            };
        Scheduler.get().scheduleDeferred(layoutCommand);
      }
    }
コード例 #16
0
  @Override
  public void onStateChanged(StateChangeEvent stateChangeEvent) {
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {

              @Override
              public void execute() {

                drawFeature = instantiateDrawFeature();
                listenerRegistration =
                    getMap()
                        .addLayerCreatedListener(
                            new LayerCreatedListener() {

                              @Override
                              public void onCreate(LayerCreatedEvent event) {
                                Circle layer = (Circle) event.getLayer();
                                rpc.circleAdded(U.toPoint(layer.getLatLng()), layer.getRadius());
                                getMap().removeListener(listenerRegistration);
                                listenerRegistration = null;
                              }
                            });

                drawFeature.enable();
              }
            });
  }
コード例 #17
0
  @Override
  protected void onReset() {
    super.onReset();

    Console.MODULES.getHeader().highlight(NameTokens.DomainRuntimePresenter);

    String currentToken = placeManager.getCurrentPlaceRequest().getNameToken();
    if (!currentToken.equals(getProxy().getNameToken())) {
      lastSubPlace = currentToken;
    } else if (lastSubPlace != null) {
      placeManager.revealPlace(new PlaceRequest(lastSubPlace));
    }

    // first request, select default contents
    if (!hasBeenRevealed
        && NameTokens.DomainRuntimePresenter.equals(
            placeManager.getCurrentPlaceRequest().getNameToken())) {
      placeManager.revealPlace(new PlaceRequest(NameTokens.InstancesPresenter));
      hasBeenRevealed = true;
    } else if (!NameTokens.DomainRuntimePresenter.equals(
        placeManager.getCurrentPlaceRequest().getNameToken())) {
      Scheduler.get()
          .scheduleDeferred(
              new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                  loadHostData();
                }
              });
    }
  }
コード例 #18
0
 /** @see org.artificer.ui.client.shared.services.IOntologyService#get(java.lang.String) */
 public void get(
     final String uuid,
     boolean forceRefresh,
     final IServiceInvocationHandler<OntologyBean> handler) {
   if (!forceRefresh && ontologyCache.containsKey(uuid)) {
     Scheduler.get()
         .scheduleDeferred(
             new Command() {
               public void execute() {
                 handler.onReturn(ontologyCache.get(uuid));
               }
             });
   } else {
     RemoteCallback<OntologyBean> successCallback =
         new DelegatingRemoteCallback<OntologyBean>(handler) {
           @Override
           public void callback(OntologyBean ontology) {
             ontologyCache.put(ontology.getUuid(), ontology);
             super.callback(ontology);
           }
         };
     ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler);
     try {
       remoteOntologyService.call(successCallback, errorCallback).get(uuid);
     } catch (ArtificerUiException e) {
       errorCallback.error(null, e);
     }
   }
 }
コード例 #19
0
ファイル: CmsDateBox.java プロジェクト: rinnes/opencms-core
  /**
   * The date box on key down action.
   *
   * <p>
   *
   * <ul>
   *   <li>If enter or tab is pressed in the date box the date time picker should be updated with
   *       the value from the date box.
   *   <li>If the escape key is pressed the picker should be hided.
   *   <li>If the up key is pressed the value should be taken from the date box.
   *   <li>If the down key is pressed the picker should be hided.
   * </ul>
   *
   * @param event the key down event
   */
  protected void onDateBoxKeyPress(KeyPressEvent event) {

    switch (event.getNativeEvent().getKeyCode()) {
      case KeyCodes.KEY_ENTER:
      case KeyCodes.KEY_TAB:
      case KeyCodes.KEY_ESCAPE:
      case KeyCodes.KEY_UP:
        updateFromTextBox();
        hidePopup();
        break;
      case KeyCodes.KEY_DOWN:
        showPopup();
        break;
      default:
        hidePopup();
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {

                  public void execute() {

                    updateCloseBehavior();
                    if (isValideDateBox()) {
                      setErrorMessage(null);
                    }
                  }
                });
        break;
    }
  }
コード例 #20
0
ファイル: Auth.java プロジェクト: rmcooksey/gwt-oauth2
  /**
   * Request an access token from an OAuth 2.0 provider.
   *
   * <p>If it can be determined that the user has already granted access, and the token has not yet
   * expired, and that the token will not expire soon, the existing token will be passed to the
   * callback.
   *
   * <p>Otherwise, a popup window will be displayed which may prompt the user to grant access. If
   * the user has already granted access the popup will immediately close and the token will be
   * passed to the callback. If access hasn't been granted, the user will be prompted, and when they
   * grant, the token will be passed to the callback.
   *
   * @param req Request for authentication.
   * @param callback Callback to pass the token to when access has been granted.
   */
  public void login(AuthRequest req, final Callback<String, Throwable> callback) {
    lastRequest = req;
    lastCallback = callback;

    String authUrl = req.toUrl(urlCodex) + "&redirect_uri=" + urlCodex.encode(oauthWindowUrl);

    // Try to look up the token we have stored.
    final TokenInfo info = getToken(req);
    if (info == null || info.expires == null || expiringSoon(info)) {
      // Token wasn't found, or doesn't have an expiration, or is expired or
      // expiring soon. Requesting access will refresh the token.
      doLogin(authUrl, callback);
    } else {
      // Token was found and is good, immediately execute the callback with the
      // access token.

      scheduler.scheduleDeferred(
          new ScheduledCommand() {
            @Override
            public void execute() {
              callback.onSuccess(info.accessToken);
            }
          });
    }
  }
コード例 #21
0
ファイル: FastSelectTable.java プロジェクト: harupiko/rstudio
  public void setSelected(TableRowElement row, boolean selected) {
    try {
      if (row.getParentElement().getParentElement() != table_) return;
    } catch (NullPointerException npe) {
      return;
    }

    boolean isCurrentlySelected = isSelected(row);
    if (isCurrentlySelected == selected) return;

    if (selected && !codec_.isValueRow(row)) return;

    setStyleName(row, selectedClassName_, selected);
    if (selected) selectedRows_.add(row);
    else selectedRows_.remove(row);

    if (selected && !allowMultiSelect_) {
      Scheduler.get()
          .scheduleDeferred(
              new ScheduledCommand() {
                public void execute() {
                  fireEvent(new SelectionChangedEvent());
                }
              });
    }
  }
コード例 #22
0
  public void start() {
    // avoid spinning mouse cursor in chrome by starting as a deferred command
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                if (!running) {
                  running = true;

                  if (unloadHandlerReg != null) {
                    unloadHandlerReg.removeHandler();
                  }

                  UnloadHandler handler = new UnloadHandler();
                  final HandlerRegistration reg1 = Window.addCloseHandler(handler);
                  final HandlerRegistration reg2 = Window.addWindowClosingHandler(handler);
                  unloadHandlerReg =
                      new HandlerRegistration() {
                        @Override
                        public void removeHandler() {
                          reg1.removeHandler();
                          reg2.removeHandler();
                        }
                      };

                  doConnect();
                }
              }
            });
  }
コード例 #23
0
  private void onDataObjectChange(@Observes DataObjectChangeEvent event) {
    if (event.isFromContext(context != null ? context.getContextId() : null)) {
      if (event.getChangeType() == ChangeType.CLASS_NAME_CHANGE
          || event.getChangeType() == ChangeType.PACKAGE_NAME_CHANGE
          || event.getChangeType() == ChangeType.OBJECT_NAME_CHANGE
          || MainDomainAnnotations.LABEL_ANNOTATION.equals(event.getAnnotationClassName())) {

        refreshObjectSelector(dataObject);

        // For self references: in case name or package changes redraw properties table
        skipNextFieldNotification = true;
        dataObjectPropertiesProvider.refresh();
        dataObjectPropertiesTable.redraw();

        Scheduler.get()
            .scheduleDeferred(
                new Scheduler.ScheduledCommand() {
                  @Override
                  public void execute() {
                    selectCurrentObject(false);
                  }
                });
      }
    }
  }
コード例 #24
0
    @Override
    public void show() {
      popupShowInProgress = true;
      // Find the shortcut action handler that should handle keyboard
      // events from the popup. The events do not propagate automatically
      // because the popup is directly attached to the RootPanel.

      super.show();

      /*
       * Shortcut actions could be set (and currently in 7.2 they ARE SET
       * via old style "updateFromUIDL" method, see f.e. UIConnector)
       * AFTER method show() has been invoked (which is called as a
       * reaction on change in component hierarchy). As a result there
       * could be no shortcutActionHandler set yet. So let's postpone
       * search of shortcutActionHandler.
       */
      Scheduler.get()
          .scheduleDeferred(
              new ScheduledCommand() {
                @Override
                public void execute() {
                  try {
                    if (shortcutActionHandler == null) {
                      shortcutActionHandler = findShortcutActionHandler();
                    }
                  } finally {
                    popupShowInProgress = false;
                  }
                }
              });
    }
コード例 #25
0
  @Override
  public Activity getActivity(final Place place) {
    Activity activity = null;

    if (place instanceof OverviewPlace) {
      activity = factory.createOverviewPresenter((OverviewPlace) place);
    } else if (place instanceof IncomePlace) {
      activity = factory.createIncomeActivity((IncomePlace) place);
    } else if (place instanceof ExpensePlace) {
      activity = factory.createExpenseActivity((ExpensePlace) place);
    } else if (place instanceof FinancePlace) {
      activity = factory.createFinanceActivity((FinancePlace) place);
    }

    if (activity == null) {
      Scheduler.get()
          .scheduleDeferred(
              new ScheduledCommand() {
                @Override
                public void execute() {
                  placeController.goTo(new OverviewPlace());
                }
              });
    }

    return activity;
  }
コード例 #26
0
ファイル: AceEditor.java プロジェクト: Rogaven/rstudio
    @Override
    protected void onFrameLoaded() {
      Document doc = getDocument();
      PreElement pre = doc.createPreElement();
      pre.setInnerText(code_);
      pre.getStyle().setProperty("whiteSpace", "pre-wrap");
      pre.getStyle().setFontSize(fontSize_, Unit.PT);
      doc.getBody().appendChild(pre);

      getWindow().print();

      // Bug 1224: ace: print from source causes inability to reconnect
      // This was caused by the iframe being removed from the document too
      // quickly after the print job was sent. As a result, attempting to
      // navigate away from the page at any point afterwards would result
      // in the error "Document cannot change while printing or in Print
      // Preview". The only thing you could do is close the browser tab.
      // By inserting a 5-minute delay hopefully Firefox would be done with
      // whatever print related operations are important.
      Scheduler.get()
          .scheduleFixedDelay(
              new RepeatingCommand() {
                public boolean execute() {
                  PrintIFrame.this.removeFromParent();
                  return false;
                }
              },
              1000 * 60 * 5);
    }
コード例 #27
0
  @Override
  public void onResize(ResizeEvent resizeEvent) {
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {

                lastWidth = getWidth();
                lastHeight = getHeight();

                if (lastWidth > 0 && lastHeight > 0) {

                  if (!GwtRenderingContext.this.isRun()) GwtRenderingContext.this.run();

                  ViewportResizeBus.onViewportResize(lastWidth, lastHeight);

                  GwtRenderingContext.this.canvas.setWidth(lastWidth);
                  GwtRenderingContext.this.canvas.setHeight(lastHeight);
                  GwtRenderingContext.this.renderer.setSize(lastWidth, lastHeight);
                  GwtRenderingContext.this.listener.onResize(GwtRenderingContext.this);

                } else {
                  GwtRenderingContext.this.stop();
                }
              }
            });
  }
コード例 #28
0
  public RulePackageSelector(boolean loadGlobalArea) {
    this.loadGlobalArea = loadGlobalArea;

    packageList = new ListBox();

    Scheduler scheduler = Scheduler.get();

    scheduler.scheduleDeferred(
        new ScheduledCommand() {
          public void execute() {
            loadPackageList();
          }
        });

    initWidget(packageList);
  }
コード例 #29
0
  /**
   * Update an ActionSetFieldCol column
   *
   * @param origCol The existing column in the grid
   * @param editColumn A copy (not clone) of the original column containing the modified values
   */
  public void updateColumn(final ActionSetFieldCol origColumn, final ActionSetFieldCol editColumn) {
    if (origColumn == null) {
      throw new IllegalArgumentException("origColumn cannot be null");
    }
    if (editColumn == null) {
      throw new IllegalArgumentException("editColumn cannot be null");
    }

    boolean bRedrawColumn = false;
    boolean bRedrawHeader = false;
    DynamicColumn<DTColumnConfig> column = getDynamicColumn(origColumn);

    // Update column's visibility
    if (origColumn.isHideColumn() != editColumn.isHideColumn()) {
      setColumnVisibility(origColumn, !editColumn.isHideColumn());
    }

    // Change in column's binding forces an update and redraw if FactField
    // is different; otherwise only need to update and redraw if the
    // FieldType has changed
    if (!isEqualOrNull(origColumn.getBoundName(), editColumn.getBoundName())) {
      if (!isEqualOrNull(origColumn.getFactField(), editColumn.getFactField())) {
        bRedrawColumn = true;
        updateCellsForDataType(editColumn, column);
      }

    } else if (!isEqualOrNull(origColumn.getFactField(), editColumn.getFactField())) {
      bRedrawColumn = true;
      updateCellsForDataType(editColumn, column);
    }

    // Update column's cell content if the Optional Value list has changed
    if (!isEqualOrNull(origColumn.getValueList(), editColumn.getValueList())) {
      bRedrawColumn = updateCellsForOptionValueList(editColumn, column);
    }

    // Update column header in Header Widget
    if (!origColumn.getHeader().equals(editColumn.getHeader())) {
      bRedrawHeader = true;
    }

    // Copy new values into original column definition
    populateModelColumn(origColumn, editColumn);

    if (bRedrawColumn) {
      int maxColumnIndex = widget.getGridWidget().getColumns().size() - 1;
      widget.getGridWidget().redrawColumns(column.getColumnIndex(), maxColumnIndex);
    }
    if (bRedrawHeader) {
      // Schedule redraw event after column has been redrawn
      Scheduler.get()
          .scheduleFinally(
              new ScheduledCommand() {
                public void execute() {
                  widget.getHeaderWidget().redraw();
                }
              });
    }
  }
コード例 #30
0
    @Override
    public void setSplitPositionUsingPixels(int px) {
      if (LocaleInfo.getCurrentLocale().isRTL()) {
        final Element splitElem = panel.getSplitElement();

        final int rootElemWidth = getOffsetWidth(panel.container);
        final int splitElemWidth = getOffsetWidth(splitElem);

        // This represents an invalid state where layout is incomplete. This
        // typically happens before DOM attachment, but I leave it here as a
        // precaution because negative width/height style attributes produce
        // errors on IE.
        if (rootElemWidth < splitElemWidth) {
          return;
        }

        // Compute the new right side width.
        int newRightWidth = rootElemWidth - px - splitElemWidth;

        // Constrain the dragging to the physical size of the panel.
        if (px < 0) {
          px = 0;
          newRightWidth = rootElemWidth - splitElemWidth;
        } else if (newRightWidth < 0) {
          px = rootElemWidth - splitElemWidth;
          newRightWidth = 0;
        }

        // Set the width of the right side.
        setWidth(panel.getElement(RIGHT), newRightWidth + "px");

        // Move the splitter to the right edge of the left element.
        setLeft(splitElem, px + "px");

        // Update the width of the left side
        if (px == 0) {

          // This takes care of a qurky RTL layout bug with IE6.
          // During DOM construction and layout, onResize events
          // are fired, and this method is called with px == 0.
          // If one tries to set the width of the LEFT element to
          // before layout completes, the RIGHT element will
          // appear to be blanked out.
          Scheduler.get()
              .scheduleDeferred(
                  new ScheduledCommand() {
                    public void execute() {
                      setWidth(panel.getElement(LEFT), "0px");
                    }
                  });
        } else {
          setWidth(panel.getElement(LEFT), px + "px");
        }

      } else {
        super.setSplitPositionUsingPixels(px);
      }
    }