Search in sources :

Example 1 with CodeBrowserContents

use of org.rstudio.studio.client.workbench.views.source.model.CodeBrowserContents in project rstudio by rstudio.

the class CodeBrowserEditingTarget method initialize.

@Override
public void initialize(SourceDocument document, FileSystemContext fileContext, FileType type, Provider<String> defaultNameProvider) {
    doc_ = document;
    codeExecution_ = new EditingTargetCodeExecution(docDisplay_, getId());
    view_ = new CodeBrowserEditingTargetWidget(commands_, globalDisplay_, events_, server_, docDisplay_);
    TextEditingTarget.registerPrefs(releaseOnDismiss_, prefs_, docDisplay_, document);
    TextEditingTarget.syncFontSize(releaseOnDismiss_, events_, view_, fontSizeManager_);
    releaseOnDismiss_.add(prefs_.softWrapRFiles().addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> evt) {
            view_.adaptToFileType(FileTypeRegistry.R);
        }
    }));
    // if we have contents then set them
    CodeBrowserContents contents = getContents();
    if (contents.getContext().length() > 0) {
        ensureContext(contents.getContext(), new Command() {

            @Override
            public void execute() {
            }
        });
    } else {
        docDisplay_.setCode("", false);
    }
}
Also used : ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) CodeBrowserContents(org.rstudio.studio.client.workbench.views.source.model.CodeBrowserContents) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) EditingTargetCodeExecution(org.rstudio.studio.client.workbench.views.source.editors.EditingTargetCodeExecution)

Example 2 with CodeBrowserContents

use of org.rstudio.studio.client.workbench.views.source.model.CodeBrowserContents in project rstudio by rstudio.

the class CodeBrowserEditingTarget method showFunction.

public void showFunction(SearchPathFunctionDefinition functionDef) {
    // set the current function
    currentFunction_ = functionDef;
    view_.showFunction(functionDef);
    view_.scrollToLeft();
    name_.setValue(functionDef.getName(), true);
    // we only show the warning bar (for debug line matching) once per 
    // function; don't keep showing it if the user dismisses
    shownWarningBar_ = false;
    // update document properties if necessary
    final CodeBrowserContents contents = CodeBrowserContents.create(getContext());
    if (!contents.equalTo(getContents())) {
        HashMap<String, String> props = new HashMap<String, String>();
        contents.fillProperties(props);
        server_.modifyDocumentProperties(doc_.getId(), props, new SimpleRequestCallback<Void>("Error") {

            @Override
            public void onResponseReceived(Void response) {
                contents.fillProperties(doc_.getProperties());
            }
        });
    }
}
Also used : CodeBrowserContents(org.rstudio.studio.client.workbench.views.source.model.CodeBrowserContents) HashMap(java.util.HashMap) Void(org.rstudio.studio.client.server.Void)

Aggregations

CodeBrowserContents (org.rstudio.studio.client.workbench.views.source.model.CodeBrowserContents)2 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 Command (com.google.gwt.user.client.Command)1 HashMap (java.util.HashMap)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 Void (org.rstudio.studio.client.server.Void)1 EditingTargetCodeExecution (org.rstudio.studio.client.workbench.views.source.editors.EditingTargetCodeExecution)1