Skip to content

Commit

Permalink
Migrate from our Widgetable interface to GWT's IsWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Jun 24, 2011
1 parent ef220c2 commit 52742d2
Show file tree
Hide file tree
Showing 34 changed files with 83 additions and 103 deletions.
Expand Up @@ -12,16 +12,17 @@
*/
package org.rstudio.core.client.widget;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;

public class WidgetableAdapter implements Widgetable
public class IsWidgetAdapter implements IsWidget
{
public WidgetableAdapter(Widget widget)
public IsWidgetAdapter(Widget widget)
{
widget_ = widget;
}

public Widget toWidget()
public Widget asWidget()
{
return widget_;
}
Expand Down
Expand Up @@ -12,7 +12,9 @@
*/
package org.rstudio.core.client.widget;

public interface WidgetableWithHeight extends Widgetable
import com.google.gwt.user.client.ui.IsWidget;

public interface IsWidgetWithHeight extends IsWidget
{
int getHeight();
}
20 changes: 0 additions & 20 deletions src/gwt/src/org/rstudio/core/client/widget/Widgetable.java

This file was deleted.

Expand Up @@ -590,7 +590,7 @@ private void initializeWorkbench()
commands_.rstudioAgreement().setVisible(false);

// show workbench
view_.showWorkbenchView(wb.getMainView().toWidget());
view_.showWorkbenchView(wb.getMainView().asWidget());

clientStateUpdaterInstance_ = clientStateUpdater_.get();
}
Expand Down
Expand Up @@ -12,9 +12,9 @@
*/
package org.rstudio.studio.client.application.ui;

import org.rstudio.core.client.widget.Widgetable;
import com.google.gwt.user.client.ui.IsWidget;

public interface ApplicationHeader extends Widgetable
public interface ApplicationHeader extends IsWidget
{
int getPreferredHeight();
}
Expand Up @@ -47,7 +47,7 @@ public ApplicationWindow(ApplicationHeader applicationHeader,
applicationPanel_ = new LayoutPanel();

// header bar
applicationHeader_ = applicationHeader.toWidget();
applicationHeader_ = applicationHeader.asWidget();
applicationHeader_.setWidth("100%");
applicationPanel_.add(applicationHeader_);
headerHeight_ = applicationHeader.getPreferredHeight();
Expand Down
Expand Up @@ -158,7 +158,7 @@ public int getPreferredHeight()
return 32;
}

public Widget toWidget()
public Widget asWidget()
{
return toolbar_;
}
Expand Down
Expand Up @@ -324,7 +324,7 @@ private Widget createCommandLink(String caption, ClickHandler clickHandler)
return link;
}

public Widget toWidget()
public Widget asWidget()
{
return this;
}
Expand Down
Expand Up @@ -13,9 +13,8 @@

package org.rstudio.studio.client.workbench;

import org.rstudio.core.client.widget.Widgetable;
import com.google.gwt.user.client.ui.IsWidget;


public interface WorkbenchMainView extends Widgetable
public interface WorkbenchMainView extends IsWidget
{
}
Expand Up @@ -12,14 +12,14 @@
*/
package org.rstudio.studio.client.workbench.ui;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import org.rstudio.core.client.AsyncShim;
import org.rstudio.core.client.events.EnsureVisibleEvent;
import org.rstudio.core.client.events.EnsureVisibleHandler;
import org.rstudio.core.client.events.HasEnsureVisibleHandlers;
import org.rstudio.core.client.widget.Widgetable;

public abstract class DelayLoadTabShim<T extends Widgetable,
public abstract class DelayLoadTabShim<T extends IsWidget,
TParentTab extends DelayLoadWorkbenchTab<T>> extends AsyncShim<T>
{

Expand All @@ -38,7 +38,7 @@ public void setParentTab(DelayLoadWorkbenchTab<T> parentTab)
protected void onDelayLoadSuccess(T obj)
{
super.onDelayLoadSuccess(obj);
final Widget child = obj.toWidget();
final Widget child = obj.asWidget();

if (child instanceof HasEnsureVisibleHandlers)
{
Expand Down
Expand Up @@ -17,15 +17,15 @@
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
import org.rstudio.core.client.SerializedCommandQueue;
import org.rstudio.core.client.events.EnsureVisibleEvent;
import org.rstudio.core.client.events.EnsureVisibleHandler;
import org.rstudio.core.client.widget.Widgetable;
import org.rstudio.studio.client.RStudioGinjector;

public abstract class DelayLoadWorkbenchTab<T extends Widgetable>
public abstract class DelayLoadWorkbenchTab<T extends IsWidget>
implements WorkbenchTab
{
protected DelayLoadWorkbenchTab(
Expand All @@ -38,7 +38,7 @@ protected DelayLoadWorkbenchTab(
shimmed_.setParentTab(this);
}

public Widget toWidget()
public Widget asWidget()
{
return panel_;
}
Expand Down
Expand Up @@ -293,7 +293,7 @@ private LogicalWindow createConsole()
private LogicalWindow createSource()
{
WindowFrame sourceFrame = new WindowFrame();
sourceFrame.setFillWidget(source_.toWidget());
sourceFrame.setFillWidget(source_.asWidget());
source_.forceLoad();
return sourceLogicalWindow_ = new LogicalWindow(
sourceFrame,
Expand Down
Expand Up @@ -29,7 +29,7 @@
public abstract class ToolbarPane extends LazyPanel implements RequiresResize,
HasEnsureVisibleHandlers
{
public Widget toWidget()
public Widget asWidget()
{
ensureWidget();
return this;
Expand Down
Expand Up @@ -294,7 +294,7 @@ void onShowOptions()
optionsLoader_.showOptions();
}

public Widget toWidget()
public Widget asWidget()
{
return this;
}
Expand Down
Expand Up @@ -13,10 +13,10 @@
package org.rstudio.studio.client.workbench.ui;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.IsWidget;
import org.rstudio.core.client.events.HasEnsureVisibleHandlers;
import org.rstudio.core.client.widget.Widgetable;

public interface WorkbenchTab extends Widgetable, HasEnsureVisibleHandlers
public interface WorkbenchTab extends IsWidget, HasEnsureVisibleHandlers
{
String getTitle();
void onBeforeSelected();
Expand Down
Expand Up @@ -89,7 +89,7 @@ public void setTabs(ArrayList<WorkbenchTab> tabs)
private void add(WorkbenchTab tab)
{
tabs_.add(tab);
final Widget widget = tab.toWidget();
final Widget widget = tab.asWidget();
tabPanel_.add(widget, tab.getTitle());

tab.addEnsureVisibleHandler(new EnsureVisibleHandler()
Expand Down
Expand Up @@ -12,18 +12,18 @@
*/
package org.rstudio.studio.client.workbench.views;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import org.rstudio.core.client.widget.Widgetable;
import org.rstudio.studio.client.workbench.WorkbenchView;

public abstract class BasePresenter implements Widgetable
public abstract class BasePresenter implements IsWidget
{
protected BasePresenter(WorkbenchView view)
{
view_ = view;
}

public Widget toWidget()
public Widget asWidget()
{
return (Widget) view_;
}
Expand Down
Expand Up @@ -78,7 +78,7 @@ public ShellPane(AceEditor editor, UIPrefs uiPrefs)
input_.setUseWrapMode(true);
input_.setPadding(0);
input_.autoHeight();
final Widget inputWidget = input_.toWidget();
final Widget inputWidget = input_.asWidget();
input_.addClickHandler(secondaryInputHandler) ;
inputWidget.addStyleName(styles_.input());
input_.addCursorChangedHandler(new CursorChangedHandler()
Expand Down Expand Up @@ -141,8 +141,8 @@ public void execute(Boolean arg)
inputLine_.setVerticalAlignment(DockPanel.ALIGN_TOP);
inputLine_.add(prompt_, DockPanel.WEST);
inputLine_.setCellWidth(prompt_, "1");
inputLine_.add(input_.toWidget(), DockPanel.CENTER);
inputLine_.setCellWidth(input_.toWidget(), "100%");
inputLine_.add(input_.asWidget(), DockPanel.CENTER);
inputLine_.setCellWidth(input_.asWidget(), "100%");
inputLine_.setWidth("100%");

verticalPanel_ = new VerticalPanel() ;
Expand Down Expand Up @@ -251,7 +251,7 @@ public void consolePrompt(String prompt)

// Deal gracefully with multi-line prompts
int promptLines = StringUtil.notNull(prompt).split("\\n").length;
input_.toWidget().getElement().getStyle().setPaddingTop((promptLines - 1) * 15,
input_.asWidget().getElement().getStyle().setPaddingTop((promptLines - 1) * 15,
Unit.PX);
}

Expand Down Expand Up @@ -499,7 +499,7 @@ public void onKeyDown(KeyDownEvent event)
}
}
input_.setFocus(true);
delegateEvent(input_.toWidget(), event);
delegateEvent(input_.asWidget(), event);
}

public void setInput(AceEditor input)
Expand Down
Expand Up @@ -73,7 +73,7 @@ protected void onDelayLoadSuccess(Plots plots)
loaded = true;
super.onDelayLoadSuccess(plots);

Widget child = plots.toWidget();
Widget child = plots.asWidget();
((HasResizeHandlers)child).addResizeHandler(new ResizeHandler()
{
public void onResize(ResizeEvent event)
Expand Down
Expand Up @@ -17,7 +17,7 @@
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget;
import org.rstudio.core.client.widget.Toolbar;
import org.rstudio.core.client.widget.WidgetableWithHeight;
import org.rstudio.core.client.widget.IsWidgetWithHeight;

public class PanelWithToolbar extends ResizeComposite
{
Expand All @@ -28,14 +28,14 @@ public PanelWithToolbar(Toolbar toolbar, Widget mainWidget)

public PanelWithToolbar(Toolbar toolbar,
Widget mainWidget,
WidgetableWithHeight statusBar)
IsWidgetWithHeight statusBar)
{
mainWidget_ = mainWidget;

panel_ = new DockLayoutPanel(Unit.PX);
panel_.addNorth(toolbar, toolbar.getHeight());
if (statusBar != null)
panel_.addSouth(statusBar.toWidget(), statusBar.getHeight());
panel_.addSouth(statusBar.asWidget(), statusBar.getHeight());

panel_.add(mainWidget_);

Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Provider;
Expand All @@ -32,7 +33,6 @@
import org.rstudio.core.client.widget.OperationWithInput;
import org.rstudio.core.client.widget.ProgressIndicator;
import org.rstudio.core.client.widget.ProgressOperationWithInput;
import org.rstudio.core.client.widget.Widgetable;
import org.rstudio.studio.client.application.Desktop;
import org.rstudio.studio.client.application.events.EventBus;
import org.rstudio.studio.client.common.FileDialogs;
Expand Down Expand Up @@ -71,7 +71,7 @@
import java.util.HashSet;

public class Source implements InsertSourceHandler,
Widgetable,
IsWidget,
OpenSourceFileHandler,
TabClosingHandler,
SelectionHandler<Integer>,
Expand All @@ -81,7 +81,7 @@ public class Source implements InsertSourceHandler,
ShowDataHandler,
BeforeShowHandler
{
public interface Display extends Widgetable,
public interface Display extends IsWidget,
HasTabClosingHandlers,
HasTabClosedHandlers,
HasBeforeSelectionHandlers<Integer>,
Expand Down Expand Up @@ -291,9 +291,9 @@ private void ensureVisible(boolean isNewTabPending)
}
}

public Widget toWidget()
public Widget asWidget()
{
return view_.toWidget();
return view_.asWidget();
}

private void restoreDocuments(final Session session)
Expand Down Expand Up @@ -593,7 +593,7 @@ public void execute()
@Override
public void execute(EditingTarget target, Command continuation)
{
view_.closeTab(target.toWidget(), false, continuation);
view_.closeTab(target.asWidget(), false, continuation);
}
});

Expand Down Expand Up @@ -797,7 +797,7 @@ public String get()
}
});

final Widget widget = target.toWidget();
final Widget widget = target.asWidget();

editors_.add(target);
view_.addTab(widget,
Expand Down
Expand Up @@ -210,7 +210,7 @@ public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Inte
return tabPanel_.addBeforeSelectionHandler(handler);
}

public Widget toWidget()
public Widget asWidget()
{
return this;
}
Expand Down

0 comments on commit 52742d2

Please sign in to comment.