}
private EditingTarget addTab(SourceDocument doc)
{
final EditingTarget target = editingTargetSource_.getEditingTarget(
doc, fileContext_, new Provider<String>()
{
public String get()
{
return getNextDefaultName();
}
});
final Widget widget = target.asWidget();
editors_.add(target);
view_.addTab(widget,
target.getIcon(),
target.getName().getValue(),
target.getTabTooltip(), // used as tooltip, if non-null
true);
fireDocTabsChanged();
target.getName().addValueChangeHandler(new ValueChangeHandler<String>()
{
public void onValueChange(ValueChangeEvent<String> event)
{
view_.renameTab(widget,
target.getIcon(),
event.getValue(),
target.getPath());
fireDocTabsChanged();
}
});
view_.setDirty(widget, target.dirtyState().getValue());
target.dirtyState().addValueChangeHandler(new ValueChangeHandler<Boolean>()
{
public void onValueChange(ValueChangeEvent<Boolean> event)
{
view_.setDirty(widget, event.getValue());
manageCommands();
}
});
target.addEnsureVisibleHandler(new EnsureVisibleHandler()
{
public void onEnsureVisible(EnsureVisibleEvent event)
{
view_.selectTab(widget);
}
});
target.addCloseHandler(new CloseHandler<Void>()
{
public void onClose(CloseEvent<Void> voidCloseEvent)
{
view_.closeTab(widget, false);
}