Skip to content

Commit

Permalink
add label to the top of source viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Oct 4, 2011
1 parent 0fe44b6 commit 44c255b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/gwt/src/org/rstudio/studio/client/RStudio.java
Expand Up @@ -54,6 +54,7 @@
import org.rstudio.studio.client.workbench.views.packages.ui.PackagesCellTableResources;
import org.rstudio.studio.client.workbench.views.plots.ui.export.ExportPlotResources;
import org.rstudio.studio.client.workbench.views.plots.ui.manipulator.ManipulatorResources;
import org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTargetWidget;
import org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor;
import org.rstudio.studio.client.workbench.views.source.editors.text.findreplace.FindReplaceBar;
import org.rstudio.studio.client.workbench.views.source.editors.text.ui.PublishPdfDialog;
Expand Down Expand Up @@ -159,6 +160,7 @@ private void load(final Command dismissProgressAnimation)
LineTableView.ensureStylesInjected();
ProjectOptionsDialog.ensureStylesInjected();
NewProjectDialog.ensureStylesInjected();
CodeBrowserEditingTargetWidget.ensureStylesInjected();

StyleInjector.inject(
"button::-moz-focus-inner {border:0}");
Expand Down
@@ -0,0 +1,34 @@
package org.rstudio.studio.client.workbench.views.source.editors.codebrowser;

import org.rstudio.studio.client.workbench.codesearch.model.SearchPathFunctionDefinition;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;

public class CodeBrowserContextLabel extends Composite
{
public CodeBrowserContextLabel(CodeBrowserEditingTargetWidget.Styles styles)
{
HorizontalPanel panel = new HorizontalPanel();

nameLabel_ = new Label();
nameLabel_.addStyleName(styles.functionName());
panel.add(nameLabel_);

namespaceLabel_ = new Label();
namespaceLabel_.addStyleName(styles.functionNamespace());
panel.add(namespaceLabel_);

initWidget(panel);
}

public void setCurrentFunction(SearchPathFunctionDefinition functionDef)
{
nameLabel_.setText(functionDef.getName());
namespaceLabel_.setText("{" + functionDef.getNamespace() + "}");
}

private Label nameLabel_;
private Label namespaceLabel_;
}
@@ -0,0 +1,14 @@

.functionName {
margin-right: 5px;
}

.functionNamespace {


}

.readOnly {
margin-right: 7px;
color: #888;
}
Expand Up @@ -12,8 +12,12 @@
*/
package org.rstudio.studio.client.workbench.views.source.editors.codebrowser;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget;

Expand Down Expand Up @@ -188,7 +192,8 @@ public void onActivate()
public void showFunction(SearchPathFunctionDefinition functionDef)
{
currentFunctionNamespace_ = functionDef.getNamespace();
docDisplay_.setCode(StringUtil.notNull(functionDef.getCode()), false);
docDisplay_.setCode(StringUtil.notNull(functionDef.getCode()), false);
contextLabel_.setCurrentFunction(functionDef);
}

@Override
Expand All @@ -206,18 +211,45 @@ public void run()
private Toolbar createToolbar()
{
Toolbar toolbar = new EditingTargetToolbar(commands_);
toolbar.addLeftWidget(commands_.printSourceDoc().createToolbarButton());
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands_.goToFunctionDefinition().createToolbarButton());
toolbar.addLeftWidget(
contextLabel_ = new CodeBrowserContextLabel(RES.styles()));


Label readOnlyLabel = new Label("(Read-only)");
readOnlyLabel.addStyleName(RES.styles().readOnly());
toolbar.addRightWidget(readOnlyLabel);



return toolbar;
}

public static void ensureStylesInjected()
{
RES.styles().ensureInjected();
}

interface Resources extends ClientBundle
{
@Source("CodeBrowserEditingTargetWidget.css")
Styles styles();

}

interface Styles extends CssResource
{
String functionName();
String functionNamespace();
String readOnly();
}

static Resources RES = GWT.create(Resources.class);

private final PanelWithToolbar panel_;
private CodeBrowserContextLabel contextLabel_;
private final Commands commands_;
private final DocDisplay docDisplay_;
private String currentFunctionNamespace_ = null;


}

0 comments on commit 44c255b

Please sign in to comment.