Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rstudio/rstudio
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Mar 11, 2011
2 parents 285660f + 47f2d4c commit e0b6587
Show file tree
Hide file tree
Showing 15 changed files with 445 additions and 192 deletions.
15 changes: 15 additions & 0 deletions src/gwt/src/org/rstudio/core/client/StringUtil.java
Expand Up @@ -15,6 +15,8 @@
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;

import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

Expand Down Expand Up @@ -185,6 +187,19 @@ public static String indent(String str, String indent)
return indent + str.replaceAll("\n", "\n" + indent);
}

public static String join(AbstractCollection<?> collection,
String delim)
{
String currDelim = "";
StringBuilder output = new StringBuilder();
for (Object el : collection)
{
output.append(currDelim).append(el == null ? "" : el.toString());
currDelim = delim;
}
return output.toString();
}

private static final long[] SIZES = {
1024L, // kilobyte
1024L * 1024L, // megabyte
Expand Down
Expand Up @@ -102,18 +102,6 @@ well as menu structures (for main menu and popup menus).
<cmd refid="activatePlots"/>
<cmd refid="activatePackages"/>
<cmd refid="activateHelp"/>
<separator/>
<menu label="Pane Layout">
<cmd refid="consoleOnTop"/>
<cmd refid="plotsOnTop"/>
</menu>
<menu label="Font Size">
<cmd refid="fontSize10"/>
<cmd refid="fontSize12"/>
<cmd refid="fontSize14"/>
<cmd refid="fontSize16"/>
<cmd refid="fontSize18"/>
</menu>
</menu>

<separator/>
Expand Down Expand Up @@ -303,12 +291,6 @@ well as menu structures (for main menu and popup menus).
<cmd id="lastTab"
menuLabel="_Last Tab"/>

<cmd id="fontSize10" menuLabel="10pt"/>
<cmd id="fontSize12" menuLabel="12pt"/>
<cmd id="fontSize14" menuLabel="14pt"/>
<cmd id="fontSize16" menuLabel="16pt"/>
<cmd id="fontSize18" menuLabel="18pt"/>

<cmd id="findReplace"
menuLabel="_Find and Replace..."/>
<cmd id="executeAllCode"
Expand Down Expand Up @@ -462,14 +444,6 @@ well as menu structures (for main menu and popup menus).
buttonLabel=""
desc="Refresh package listing"/>

<!-- consoleOnTop has a dynamic menuLabel -->
<cmd id="consoleOnTop"
menuLabel=""/>

<!-- plotsOnTop has a dynamic menuLabel -->
<cmd id="plotsOnTop"
menuLabel=""/>

<cmd id="showOptions"
menuLabel="Pr_eferences..."/>

Expand Down
Expand Up @@ -60,21 +60,12 @@ public abstract class Commands extends CommandBundle
public abstract AppCommand showFolder();

// View
public abstract AppCommand consoleOnTop();
public abstract AppCommand plotsOnTop();
public abstract AppCommand switchToTab();
public abstract AppCommand previousTab();
public abstract AppCommand nextTab();
public abstract AppCommand firstTab();
public abstract AppCommand lastTab();

// Font Sizes
public abstract AppCommand fontSize10();
public abstract AppCommand fontSize12();
public abstract AppCommand fontSize14();
public abstract AppCommand fontSize16();
public abstract AppCommand fontSize18();

// History
public abstract AppCommand historySendToSource();
public abstract AppCommand historySendToConsole();
Expand Down
Expand Up @@ -63,4 +63,9 @@ public PrefValue<Boolean> softWrapRFiles()
{
return bool("soft_wrap_r_files", false);
}

public PrefValue<String> fontSize()
{
return string("font_size", "Pt12");
}
}
@@ -1,14 +1,38 @@
package org.rstudio.studio.client.workbench.prefs.views;

import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.ListBox;
import com.google.inject.Inject;
import org.rstudio.studio.client.workbench.prefs.model.UIPrefs;

public class AppearancePreferencesPane extends PreferencesPane
{
@Inject
public AppearancePreferencesPane(PreferencesDialogResources res)
public AppearancePreferencesPane(PreferencesDialogResources res,
UIPrefs uiPrefs)
{
res_ = res;
uiPrefs_ = uiPrefs;

String[] labels = {"10", "12", "14", "16", "18"};
String[] values = {"Pt10", "Pt12", "Pt14", "Pt16", "Pt18"};

fontSize_ = new SelectWidget("Console/Source Font Size",
labels,
values);
String value = uiPrefs.fontSize().getValue();
boolean matched = false;
for (int i = 0; i < values.length; i++)
if (values[i].equals(value))
{
fontSize_.getListBox().setSelectedIndex(i);
matched = true;
break;
}
if (!matched)
fontSize_.getListBox().setSelectedIndex(1);

add(fontSize_);
}

@Override
Expand All @@ -20,6 +44,8 @@ public ImageResource getIcon()
@Override
public void onApply()
{
ListBox list = fontSize_.getListBox();
uiPrefs_.fontSize().setValue(list.getValue(list.getSelectedIndex()));
}

@Override
Expand All @@ -29,4 +55,6 @@ public String getName()
}

private final PreferencesDialogResources res_;
private final UIPrefs uiPrefs_;
private SelectWidget fontSize_;
}

0 comments on commit e0b6587

Please sign in to comment.