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 Oct 5, 2011
2 parents fb4b6ef + d2decea commit bac0460
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 196 deletions.
Expand Up @@ -27,6 +27,11 @@
import java.util.HashSet;
import java.util.Set;

/**
* WARNING: If you use this, take a look at ChangelistTable.NotEditingTextCell,
* which was necessary to get the table out of a state where cellIsEditing is
* stuck on true due to this cell getting mouseover but not mouseout.
*/
public class TriStateCheckboxCell<TKey> implements Cell<Boolean>
{
interface Resources extends ClientBundle
Expand Down Expand Up @@ -95,6 +100,8 @@ else if ("mouseover".equals(event.getType()))
}
else if ("mouseout".equals(event.getType()))
{
// WARNING!!!! Sometimes we get mouseover without a corresponding
// mouseout!! See comment at top of this class!
mouseInCheckbox_ = false;
}
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.event.shared.HandlerRegistration;
Expand Down Expand Up @@ -43,6 +44,8 @@

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;

public class ChangelistTable extends Composite
implements HasKeyDownHandlers, HasClickHandlers
Expand Down Expand Up @@ -76,6 +79,50 @@ protected interface Style extends CellTable.Style
String status();
}

/**
* The whole point of this subclass is to force CellTable to update its
* cellIsEditing private member more often. This is to work around a bug
* where the ChangelistTable can get into a state where mouse clicks don't
* change the selection, because TriStateCheckboxCell gets a mouseover event
* but not a matching mouseout.
*/
protected static class NotEditingTextCell extends TextCell
{
public NotEditingTextCell()
{
super();
init();
}

public NotEditingTextCell(SafeHtmlRenderer<String> renderer)
{
super(renderer);
init();
}

private void init()
{
Set<String> inheritedEvents = getConsumedEvents();
if (inheritedEvents != null)
consumedEvents_.addAll(inheritedEvents);
consumedEvents_.add("mouseover");
}

@Override
public Set<String> getConsumedEvents()
{
return consumedEvents_;
}

@Override
public boolean isEditing(Context context, Element parent, String value)
{
return false;
}

private Set<String> consumedEvents_ = new HashSet<String>();
}

private class StatusRenderer implements SafeHtmlRenderer<String>
{

Expand Down Expand Up @@ -271,7 +318,7 @@ public int compare(StatusAndPath a, StatusAndPath b)


Column<StatusAndPath, String> statusColumn = new Column<StatusAndPath, String>(
new TextCell(new StatusRenderer()))
new NotEditingTextCell(new StatusRenderer()))
{
@Override
public String getValue(StatusAndPath object)
Expand All @@ -292,7 +339,8 @@ public int compare(StatusAndPath a, StatusAndPath b)
}
});

TextColumn<StatusAndPath> pathColumn = new TextColumn<StatusAndPath>()
Column<StatusAndPath, String> pathColumn = new Column<StatusAndPath, String>(
new NotEditingTextCell())
{
@Override
public String getValue(StatusAndPath object)
Expand Down
Expand Up @@ -15,6 +15,8 @@
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
Expand Down Expand Up @@ -80,24 +82,24 @@ public void onSelectionChange(SelectionChangeEvent event)

final Token token = invalidation_.getInvalidationToken();

server_.vcsShow(commitInfo.getId(), new SimpleRequestCallback<String>()
{
@Override
public void onResponseReceived(String response)
{
super.onResponseReceived(response);
if (token.isInvalid())
return;

UnifiedParser parser = new UnifiedParser(response);
view_.getCommitDetail().setDetails(parser);
}
});
server_.vcsShow(commitInfo.getId(),
new SimpleRequestCallback<String>()
{
@Override
public void onResponseReceived(String response)
{
super.onResponseReceived(response);
if (token.isInvalid())
return;

UnifiedParser parser = new UnifiedParser(
response);
view_.getCommitDetail().setDetails(parser);
}
});
}
});

refreshHistory();

view_.getRefreshButton().addClickHandler(new ClickHandler()
{
@Override
Expand Down Expand Up @@ -141,6 +143,11 @@ public Widget asWidget()
return view_.asWidget();
}

public void onShow()
{
refreshHistory();
}

private final VCSServerOperations server_;
private final Display view_;
private final Invalidation invalidation_ = new Invalidation();
Expand Down
Expand Up @@ -52,17 +52,16 @@
}

.diffToolbar {
float: left;
float: right;
width: auto;
}

.diffViewOptions {
position: absolute;
right: 6px;
left: 6px;
top: 2px;
bottom: 2px;
width: auto;
text-align: right;
}

.commitMessage {
Expand All @@ -83,26 +82,3 @@
float: right;
margin-right: -1px;
}

.filenameLabel {
display: inline;
position: relative;
top: 3px;
font-size: 11px;
font-weight: bold;
color: #353d4a;
margin-right: 30px;
}

.fileInfoWrapper {
float: left;
margin-left: 6px;
}

.fileIcon {
float: left;
display: block;
position: relative;
top: 2px;
margin-right: 3px;
}
Expand Up @@ -30,7 +30,6 @@
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import org.rstudio.core.client.StringUtil;
import org.rstudio.core.client.ValueSink;
import org.rstudio.core.client.files.FileSystemItem;
import org.rstudio.core.client.widget.*;
import org.rstudio.studio.client.common.filetypes.FileTypeRegistry;
Expand All @@ -40,11 +39,9 @@
import org.rstudio.studio.client.workbench.views.vcs.ChangelistTable;
import org.rstudio.studio.client.workbench.views.vcs.ChangelistTablePresenter;
import org.rstudio.studio.client.workbench.views.vcs.console.ConsoleBarFramePanel;
import org.rstudio.studio.client.workbench.views.vcs.diff.ChunkOrLine;
import org.rstudio.studio.client.workbench.views.vcs.dialog.ReviewPresenter.Display;
import org.rstudio.studio.client.workbench.views.vcs.diff.LineTablePresenter;
import org.rstudio.studio.client.workbench.views.vcs.diff.LineTableView;
import org.rstudio.studio.client.workbench.views.vcs.diff.NavGutter;
import org.rstudio.studio.client.workbench.views.vcs.dialog.ReviewPresenter.Display;

import java.util.ArrayList;

Expand Down Expand Up @@ -98,12 +95,6 @@ interface Styles extends SharedStyles
String commitButton();

String splitPanelCommit();

String filenameLabel();

String fileInfoWrapper();

String fileIcon();
}

private static class ClickCommand implements HasClickHandlers, Command
Expand Down Expand Up @@ -218,9 +209,6 @@ public ReviewPanel(ChangelistTablePresenter changelist,

initWidget(consoleBarFramePanel);

fileIcon_.setResource(RES.blankFileIcon());
fileIcon_.addStyleName(RES.styles().fileIcon());

topToolbar_.addStyleName(RES.styles().toolbar());

switchViewButton_ = new LeftRightToggleButton("Changes", "History", true);
Expand Down Expand Up @@ -375,23 +363,6 @@ public void setUnstageButtonLabel(String label)
unstageAllButton_.setText(label);
}

@Override
public void setFilename(String filename)
{
if (StringUtil.isNullOrEmpty(filename))
{
filenameLabel_.setText("");
fileIcon_.setResource(RES.blankFileIcon());
}
else
{
filenameLabel_.setText(filename);
ImageResource icon = fileTypeRegistry_.getIconForFile(
FileSystemItem.createFile(filename));
fileIcon_.setResource(icon);
}
}

@Override
public HasText getCommitMessage()
{
Expand Down Expand Up @@ -452,12 +423,6 @@ public ChangelistTable getChangelistTable()
return changelist_;
}

@Override
public ValueSink<ArrayList<ChunkOrLine>> getGutter()
{
return gutter_;
}

@Override
public HasValue<Integer> getContextLines()
{
Expand All @@ -479,18 +444,12 @@ public HasValue<Integer> getContextLines()
@UiField(provided = true)
LineTableView lines_;
@UiField
NavGutter gutter_;
@UiField
ListBox contextLines_;
@UiField
Toolbar topToolbar_;
@UiField
Toolbar diffToolbar_;
@UiField
Image fileIcon_;
@UiField
Label filenameLabel_;
@UiField
TextArea commitMessage_;
@UiField
CheckBox commitIsAmend_;
Expand Down
Expand Up @@ -43,11 +43,6 @@
<g:DockLayoutPanel>
<g:north size="28">
<g:FlowPanel styleName="{res.styles.toolbarWrapper}">
<g:FlowPanel styleName="{res.styles.fileInfoWrapper}">
<g:Image ui:field="fileIcon_" styleName="{res.styles.fileIcon}"/>
<g:Label ui:field="filenameLabel_" styleName="{res.styles.filenameLabel}"/>
</g:FlowPanel>
<rs_widget:Toolbar ui:field="diffToolbar_"/>
<g:FlowPanel styleName="{res.styles.diffViewOptions}">
<g:Label text="Show" styleName="{res.styles.stagedLabel}"/>
<g:RadioButton ui:field="stagedCheckBox_"
Expand All @@ -68,19 +63,13 @@
<g:item value="-1">All lines</g:item>
</g:ListBox>
</g:FlowPanel>
<rs_widget:Toolbar ui:field="diffToolbar_"/>
</g:FlowPanel>
</g:north>
<g:center>
<g:LayoutPanel>
<g:layer left="0" right="8px" top="0" bottom="0">
<g:ScrollPanel styleName="{res.styles.whitebg}" width="100%" height="100%">
<vcs_diff:LineTableView ui:field="lines_" width="100%"/>
</g:ScrollPanel>
</g:layer>
<g:layer right="0" width="8px" top="16px" bottom="16px">
<vcs_diff:NavGutter ui:field="gutter_" width="100%" height="100%"/>
</g:layer>
</g:LayoutPanel>
<g:ScrollPanel styleName="{res.styles.whitebg}" width="100%" height="100%">
<vcs_diff:LineTableView ui:field="lines_" width="100%"/>
</g:ScrollPanel>
</g:center>
</g:DockLayoutPanel>
</g:center>
Expand Down

0 comments on commit bac0460

Please sign in to comment.