Example usage for com.google.gwt.core.client JavaScriptObject cast

List of usage examples for com.google.gwt.core.client JavaScriptObject cast

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptObject cast.

Prototype

@Override
@SuppressWarnings("unchecked")
public <T extends JavascriptObjectEquivalent> T cast() 

Source Link

Document

A helper method to enable cross-casting from any JavaScriptObject type to any other JavaScriptObject type.

Usage

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ChunkSatelliteWindow.java

License:Open Source License

@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
    chunkWindowParams_ = params.cast();

    String title = "RStudio: Notebook Output";
    Window.setTitle(title);/*from w ww. jav  a 2 s  .  co m*/

    ChunkOutputHost chunkOutputHost = new ChunkOutputHost() {
        @Override
        public void onOutputRemoved(final ChunkOutputWidget widget) {
        }

        @Override
        public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
        }
    };

    chunkOutputWidget_ = new ChunkOutputWidget(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(),
            RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, false, // can close
            chunkOutputHost, ChunkOutputSize.Full);

    Element ele = chunkOutputWidget_.getElement();
    ele.addClassName(ThemeStyles.INSTANCE.selectableText());

    // Append the chunkOutputWidget as an HTML element, not as a widget.
    // Why? Chunks are widgets that are attached to the ACE editor as HTML
    // elements, not as widgets. The reason being that GWT does not support
    // triggering events for widgets that are not attached to their hierarchy.
    // Therefore, if we attach this element as a widget, GWT will remove 
    // events in some cases which will cause functionality to be lost.
    mainPanel.getElement().appendChild(chunkOutputWidget_.getElement());

    chunkOutputWidget_.getElement().getStyle().setHeight(100, Unit.PCT);

    mainPanel.addStyleName("ace_editor_theme");

    pEventBus_.get().addHandler(ChunkSatelliteCodeExecutingEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkSatelliteCacheEditorStyleEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkPlotRefreshedEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkPlotRefreshFinishedEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkChangeEvent.TYPE, this);
    pEventBus_.get().addHandler(RmdChunkOutputFinishedEvent.TYPE, this);
    pEventBus_.get().addHandler(RmdChunkOutputEvent.TYPE, this);

    Window.addWindowClosingHandler(new ClosingHandler() {
        @Override
        public void onWindowClosing(ClosingEvent arg0) {
            server_.cleanReplayNotebookChunkPlots(chunkWindowParams_.getDocId(),
                    chunkWindowParams_.getChunkId(), new ServerRequestCallback<Void>() {
                        @Override
                        public void onError(ServerError error) {
                        }
                    });
        }
    });

    pEventBus_.get().fireEventToMainWindow(new ChunkSatelliteWindowOpenedEvent(chunkWindowParams_.getDocId(),
            chunkWindowParams_.getChunkId()));
}

From source file:org.rstudio.studio.client.workbench.views.source.SourceSatelliteWindow.java

License:Open Source License

@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
    // read the params and set up window ordinal / title
    SourceWindowParams windowParams = params.cast();
    String title = null;/* www  .  j a v  a  2s .c o  m*/
    if (windowParams != null) {
        pWindowManager_.get().setSourceWindowOrdinal(windowParams.getOrdinal());
        title = windowParams.getTitle();
    }
    if (title == null)
        title = "";
    else
        title += " - ";
    title += "RStudio Source Editor";
    Window.setTitle(title);

    // set up the source window
    SourceWindow sourceWindow = pSourceWindow_.get();
    if (windowParams != null && windowParams.getDocId() != null && windowParams.getSourcePosition() != null) {
        // if this source window is being opened to pop out a particular doc,
        // read that doc's ID and current position so we can restore it 
        sourceWindow.setInitialDoc(windowParams.getDocId(), windowParams.getSourcePosition());
    }

    SourceSatellitePresenter appPresenter = pPresenter_.get();

    // initialize build commands (we want these to work from source windows)
    BuildCommands.setBuildCommandState(RStudioGinjector.INSTANCE.getCommands(),
            RStudioGinjector.INSTANCE.getSession().getSessionInfo());

    // initialize MRUs on Cocoa desktop (on Qt and in server mode the MRU
    // menu entries aren't accessible from the source window)
    if (Desktop.isDesktop() && Desktop.getFrame().isCocoa()) {
        pFileMRUList_.get();
        pProjectMRUList_.get();
    }

    // initialize working directory
    if (!StringUtil.isNullOrEmpty(windowParams.getWorkingDir())) {
        pEventBus_.get().fireEvent(new WorkingDirChangedEvent(windowParams.getWorkingDir()));
    }

    // make it fill the containing layout panel
    Widget presWidget = appPresenter.asWidget();
    mainPanel.add(presWidget);
    mainPanel.setWidgetLeftRight(presWidget, 0, Unit.PX, 0, Unit.PX);
    mainPanel.setWidgetTopBottom(presWidget, 0, Unit.PX, 0, Unit.PX);
}

From source file:org.rstudio.studio.client.workbench.views.source.SourceWindow.java

License:Open Source License

private void saveWithPrompt(JavaScriptObject jsoItem, Command onCompleted) {
    UnsavedChangesItem item = jsoItem.cast();
    sourceShim_.saveWithPrompt(item, onCompleted, null);
}

From source file:org.rstudio.studio.client.workbench.views.source.SourceWindow.java

License:Open Source License

private void handleUnsavedChangesBeforeExit(JavaScriptObject jsoItems, Command onCompleted) {
    JsArray<UnsavedChangesItem> items = jsoItems.cast();
    ArrayList<UnsavedChangesTarget> targets = new ArrayList<UnsavedChangesTarget>();
    for (int i = 0; i < items.length(); i++) {
        targets.add(items.get(i));//from   ww  w . j a va  2  s  . c  o  m
    }
    sourceShim_.handleUnsavedChangesBeforeExit(targets, onCompleted);
}

From source file:org.rstudio.studio.client.workbench.views.vcs.common.VCSFileOpener.java

License:Open Source License

private void satelliteOpenFiles(JavaScriptObject items) {
    JsArray<FileSystemItem> itemsArray = items.cast();
    doOpenFiles(itemsArray);
}

From source file:org.unitime.timetable.gwt.client.GwtHint.java

License:Apache License

/** Never use from GWT code */
public static void _showHint(JavaScriptObject source, String content) {
    showHint((Element) source.cast(), content);
}

From source file:org.unitime.timetable.gwt.client.instructor.InstructorAvailabilityHint.java

License:Apache License

/** Never use from GWT code */
public static void _showInstructorSharingHint(JavaScriptObject source, String instructorId) {
    showHint((Element) source.cast(), instructorId);
}

From source file:org.unitime.timetable.gwt.client.rooms.PeriodPreferencesHint.java

License:Apache License

/** Never use from GWT code */
public static void _showPeriodPreferencesHint(JavaScriptObject source, String locationId, String examTypeId) {
    showHint((Element) source.cast(), toLong(locationId), toLong(examTypeId));
}

From source file:org.unitime.timetable.gwt.client.rooms.PeriodPreferencesHint.java

License:Apache License

public static void _showExamPeriodPreferencesHint(JavaScriptObject source, String examId, String periodId) {
    showHintForExam((Element) source.cast(), toLong(examId), toLong(periodId));
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomHint.java

License:Apache License

/** Never use from GWT code */
public static void _showRoomHint(JavaScriptObject source, String locationId, String prefix, String distance,
        String note) {//from w  ww. j a v a  2 s .  c  o m
    showHint((Element) source.cast(), Long.valueOf(locationId), prefix, distance, note, true);
}