Skip to content

Commit

Permalink
UI improvements to VCS integration
Browse files Browse the repository at this point in the history
- Show progress when refreshing changelist
- Maintain selection when bringing up VCS dialog
  • Loading branch information
jcheng5 committed Sep 28, 2011
1 parent 32f5db5 commit 0a5a61c
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 20 deletions.
30 changes: 21 additions & 9 deletions src/gwt/src/org/rstudio/core/client/widget/ProgressPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,36 @@ public ProgressPanel(Image progressImage)

public void beginProgressOperation(int delayMs)
{
clearTimer();
progressImage_.setVisible(false);
progressOperationPending_ = true ;

Timer timer = new Timer() {

timer_ = new Timer() {
public void run() {
if (progressOperationPending_)
progressImage_.setVisible(true);
if (timer_ != this)
return; // This should never happen, but, just in case

progressImage_.setVisible(true);
}
};
timer.schedule(delayMs);
timer_.schedule(delayMs);
}

public void endProgressOperation()
{
progressOperationPending_ = false ;
clearTimer();
progressImage_.setVisible(false);
}


private void clearTimer()
{
if (timer_ != null)
{
timer_.cancel();
timer_ = null;
}
}

private final Image progressImage_ ;
private boolean progressOperationPending_ = false ;
private Timer timer_;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
*/
package org.rstudio.studio.client.workbench.views.vcs;

import com.google.gwt.cell.client.*;
import com.google.gwt.cell.client.FieldUpdater;
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.Style.Unit;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtml;
Expand All @@ -27,10 +29,12 @@
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.view.client.*;
import org.rstudio.core.client.cellview.ColumnSortInfo;
import org.rstudio.core.client.cellview.TriStateCheckboxCell;
import org.rstudio.core.client.widget.ProgressPanel;
import org.rstudio.studio.client.common.vcs.StatusAndPath;
import org.rstudio.studio.client.workbench.views.vcs.events.StageUnstageEvent;
import org.rstudio.studio.client.workbench.views.vcs.events.StageUnstageHandler;
Expand Down Expand Up @@ -163,7 +167,39 @@ public Object getKey(StatusAndPath item)

table_.setSize("100%", "auto");

initWidget(new ScrollPanel(table_));
layout_ = new LayoutPanel();
ScrollPanel scrollPanel = new ScrollPanel(table_);
layout_.add(scrollPanel);
layout_.setWidgetTopBottom(scrollPanel, 0, Unit.PX, 0, Unit.PX);
layout_.setWidgetLeftRight(scrollPanel, 0, Unit.PX, 0, Unit.PX);
progressPanel_ = new ProgressPanel();
progressPanel_.getElement().getStyle().setBackgroundColor("white");
layout_.add(progressPanel_);
layout_.setWidgetTopBottom(progressPanel_, 0, Unit.PX, 0, Unit.PX);
layout_.setWidgetLeftRight(progressPanel_, 0, Unit.PX, 0, Unit.PX);

setProgress(true);

initWidget(layout_);
}

public void showProgress()
{
setProgress(true);
}

protected void setProgress(boolean showProgress)
{
if (showProgress)
{
layout_.setWidgetVisible(progressPanel_, true);
progressPanel_.beginProgressOperation(300);
}
else
{
layout_.setWidgetVisible(progressPanel_, false);
progressPanel_.endProgressOperation();
}
}

private void configureTable()
Expand Down Expand Up @@ -259,6 +295,7 @@ public HandlerRegistration addSelectionChangeHandler(

public void setItems(ArrayList<StatusAndPath> items)
{
setProgress(false);
table_.setPageSize(items.size());
dataProvider_.getList().clear();
dataProvider_.getList().addAll(items);
Expand Down Expand Up @@ -293,6 +330,12 @@ public ArrayList<String> getSelectedPaths()
return results;
}

public void setSelectedStatusAndPaths(ArrayList<StatusAndPath> selectedPaths)
{
for (StatusAndPath path : selectedPaths)
selectionModel_.setSelected(path, true);
}

public ArrayList<String> getSelectedDiscardablePaths()
{
SelectionModel<? super StatusAndPath> selectionModel = table_.getSelectionModel();
Expand Down Expand Up @@ -326,9 +369,20 @@ public int getSortOrderHashCode()
return table_.getColumnSortList().hashCode();
}

public ArrayList<StatusAndPath> getSelectedStatusAndPaths()
{
ArrayList<StatusAndPath> results = new ArrayList<StatusAndPath>();
for (StatusAndPath path : dataProvider_.getList())
if (table_.getSelectionModel().isSelected(path))
results.add(path);
return results;
}

private final CellTable<StatusAndPath> table_;
private final MultiSelectionModel<StatusAndPath> selectionModel_;
private final ColumnSortEvent.ListHandler<StatusAndPath> sortHandler_;
private final ListDataProvider<StatusAndPath> dataProvider_;
private final ProgressPanel progressPanel_;
private LayoutPanel layout_;
private static final CellTableResources resources_ = GWT.<CellTableResources>create(CellTableResources.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public interface Display extends WorkbenchView, IsWidget
{
void setItems(ArrayList<StatusAndPath> items);
ArrayList<String> getSelectedPaths();
ArrayList<StatusAndPath> getSelectedStatusAndPaths();

void showProgress();
void onRefreshBegin();
}

@Inject
Expand All @@ -77,7 +78,6 @@ public VCS(Display view,

commandBinder.bind(commands, this);

view_.setProgress(true);
vcsState_.addVcsRefreshHandler(new VcsRefreshHandler()
{
@Override
Expand Down Expand Up @@ -136,7 +136,9 @@ void onVcsDiff()

private void showReviewPane(boolean showHistory)
{
VCSPopup.show(pReviewPresenter_.get(),
ReviewPresenter rpres = pReviewPresenter_.get();
rpres.setSelectedPaths(view_.getSelectedStatusAndPaths());
VCSPopup.show(rpres,
pHistoryPresenter_.get(),
showHistory);
}
Expand Down Expand Up @@ -181,7 +183,7 @@ void onVcsCommit()
@Handler
void onVcsRefresh()
{
view_.showProgress();
view_.onRefreshBegin();
vcsState_.refresh();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected Widget createMainWidget()
@Override
public void setItems(ArrayList<StatusAndPath> items)
{
this.setProgress(false);
table_.setItems(items);
}

Expand All @@ -94,9 +93,15 @@ public ArrayList<String> getSelectedPaths()
}

@Override
public void showProgress()
public ArrayList<StatusAndPath> getSelectedStatusAndPaths()
{
this.setProgress(true);
return table_.getSelectedStatusAndPaths();
}

@Override
public void onRefreshBegin()
{
table_.showProgress();
}

private final Commands commands_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.rstudio.core.client.files.FileSystemItem;
import org.rstudio.core.client.widget.*;
import org.rstudio.studio.client.common.filetypes.FileTypeRegistry;
import org.rstudio.studio.client.common.vcs.StatusAndPath;
import org.rstudio.studio.client.workbench.commands.Commands;
import org.rstudio.studio.client.workbench.views.vcs.BranchToolbarButton;
import org.rstudio.studio.client.workbench.views.vcs.ChangelistTable;
Expand Down Expand Up @@ -197,7 +198,7 @@ interface Binder extends UiBinder<Widget, ReviewPanel>
public ReviewPanel(ChangelistTablePresenter changelist,
LineTableView diffPane,
ConsoleBarFramePanel consoleBarFramePanel,
Commands commands,
final Commands commands,
FileTypeRegistry fileTypeRegistry,
BranchToolbarButton branchToolbarButton)
{
Expand Down Expand Up @@ -247,7 +248,14 @@ public ReviewPanel(ChangelistTablePresenter changelist,

topToolbar_.addRightWidget(new ToolbarButton(
"Refresh", commands.vcsRefresh().getImageResource(),
commands.vcsRefresh()));
new ClickHandler() {
@Override
public void onClick(ClickEvent event)
{
changelist_.showProgress();
commands.vcsRefresh();
}
}));

topToolbar_.addRightSeparator();

Expand Down Expand Up @@ -405,6 +413,12 @@ public ArrayList<String> getSelectedPaths()
return changelist_.getSelectedPaths();
}

@Override
public void setSelectedStatusAndPaths(ArrayList<StatusAndPath> selectedPaths)
{
changelist_.setSelectedStatusAndPaths(selectedPaths);
}

@Override
public ArrayList<String> getSelectedDiscardablePaths()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public interface Display extends IsWidget, HasAttachHandlers
{
ArrayList<String> getSelectedPaths();
ArrayList<String> getSelectedDiscardablePaths();
void setSelectedStatusAndPaths(ArrayList<StatusAndPath> selectedPaths);

HasValue<Boolean> getStagedCheckBox();
HasValue<Boolean> getUnstagedCheckBox();
Expand Down Expand Up @@ -488,6 +489,11 @@ public void onClick(ClickEvent event)
});
}

public void setSelectedPaths(ArrayList<StatusAndPath> selectedPaths)
{
view_.setSelectedStatusAndPaths(selectedPaths);
}

private final Invalidation diffInvalidation_ = new Invalidation();
private final VCSServerOperations server_;
private final Display view_;
Expand Down

0 comments on commit 0a5a61c

Please sign in to comment.