use of com.google.gwt.user.client.ui.UIObject in project rstudio by rstudio.
the class TextEditingTarget method initStatusBar.
private void initStatusBar() {
statusBar_ = view_.getStatusBar();
docDisplay_.addCursorChangedHandler(new CursorChangedHandler() {
public void onCursorChanged(CursorChangedEvent event) {
updateStatusBarPosition();
if (docDisplay_.isScopeTreeReady(event.getPosition().getRow()))
updateCurrentScope();
}
});
updateStatusBarPosition();
updateStatusBarLanguage();
// build file type menu dynamically (so it can change according
// to whether e.g. knitr is installed)
statusBar_.getLanguage().addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
// build menu with all file types - also track whether we need
// to add the current type (may be the case for types which we
// support but don't want to expose on the menu -- e.g. Rmd
// files when knitr isn't installed)
boolean addCurrentType = true;
final StatusBarPopupMenu menu = new StatusBarPopupMenu();
TextFileType[] fileTypes = fileTypeCommands_.statusBarFileTypes();
for (TextFileType type : fileTypes) {
menu.addItem(createMenuItemForType(type));
if (addCurrentType && type.equals(fileType_))
addCurrentType = false;
}
// add the current type if isn't on the menu
if (addCurrentType)
menu.addItem(createMenuItemForType(fileType_));
// show the menu
menu.showRelativeToUpward((UIObject) statusBar_.getLanguage(), true);
}
});
statusBar_.getScope().addMouseDownHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
// Unlike the other status bar elements, the function outliner
// needs its menu built on demand
JsArray<Scope> tree = docDisplay_.getScopeTree();
final StatusBarPopupMenu menu = new StatusBarPopupMenu();
MenuItem defaultItem = null;
if (fileType_.isRpres()) {
String path = docUpdateSentinel_.getPath();
if (path != null) {
presentationHelper_.buildSlideMenu(docUpdateSentinel_.getPath(), dirtyState_.getValue(), TextEditingTarget.this, new CommandWithArg<StatusBarPopupRequest>() {
@Override
public void execute(StatusBarPopupRequest request) {
showStatusBarPopupMenu(request);
}
});
}
} else {
defaultItem = addFunctionsToMenu(menu, tree, "", docDisplay_.getCurrentScope(), true);
showStatusBarPopupMenu(new StatusBarPopupRequest(menu, defaultItem));
}
}
});
}
use of com.google.gwt.user.client.ui.UIObject in project gwt-test-utils by gwt-test-utils.
the class PotentialElementPatcher method resolve.
@PatchMethod
static Element resolve(Element maybePotential) {
if (isPotential(maybePotential)) {
UIObject o = JavaScriptObjects.getObject(maybePotential, POTENTIALELEMENT_UIOBJECT);
GwtReflectionUtils.callPrivateMethod(o, "resolvePotentialElement");
return JavaScriptObjects.getObject(maybePotential, POTENTIALELEMENT_WRAPPED_ELEMENT);
} else {
return maybePotential;
}
}
use of com.google.gwt.user.client.ui.UIObject in project gwt-test-utils by gwt-test-utils.
the class UiBinderBeanUtils method populateObject.
/**
* @param o
* @param properties
* @see BeanUtilsBean#populate(Object, Map)
*/
public static void populateObject(Object o, Map<String, Object> properties) {
try {
Map<String, Object> filteredProperties = new HashMap<String, Object>();
for (String key : properties.keySet()) {
if (PropertyUtils.isWriteable(o, key)) {
filteredProperties.put(key, properties.get(key));
}
}
UIBINDER_BEANUTILS.populate(o, filteredProperties);
} catch (Exception e) {
throw new ReflectionException("UiBinder error while setting properties for '" + o.getClass().getSimpleName() + "'", e);
}
// handle specifics
String[] styles = (String[]) properties.get("addStyleNames");
if (styles != null) {
for (String style : styles) {
if (o instanceof IsWidget) {
((IsWidget) o).asWidget().addStyleName(style);
} else if (o instanceof UIObject) {
((UIObject) o).addStyleName(style);
}
}
}
}
use of com.google.gwt.user.client.ui.UIObject in project gwt-test-utils by gwt-test-utils.
the class UiTagBuilder method endTag.
UiTagBuilder<T> endTag(String nameSpaceURI, String localName) {
// ignore <UiBinder> tag
if (UiBinderXmlUtils.isUiBinderTag(nameSpaceURI, localName)) {
return this;
}
Object currentObject = currentTag.endTag();
UiTag<?> parentTag = currentTag.getParentTag();
currentTag = parentTag;
if (UiBinderXmlUtils.isResourceTag(nameSpaceURI, localName) || UiBinderXmlUtils.isImportTag(nameSpaceURI, localName)) {
// ignore <ui:data>, <ui:image>, <ui:style> <ui:text> and <ui:import> tags
return this;
} else if (UiBinderXmlUtils.isMsgTag(nameSpaceURI, localName) || UiBinderXmlUtils.isTextTag(nameSpaceURI, localName)) {
// special <ui:msg> and <ui:text> case
parentTag.appendText((String) currentObject);
return this;
}
if (parentTag == null) {
// parsing is finished, this must be the root component
if (rootComponent != null) {
throw new GwtTestUiBinderException("UiBinder template '" + owner.getClass().getName() + "' should declare only one root widget in its corresponding .ui.xml file");
} else {
rootComponent = currentObject;
}
} else {
// add to its parent
if (IsWidget.class.isInstance(currentObject)) {
parentTag.addWidget((IsWidget) currentObject);
} else if (UIObject.class.isInstance(currentObject)) {
// UIObject instance that is not a Widget
parentTag.addUiObject((UIObject) currentObject);
} else {
parentTag.addElement((Element) currentObject);
}
}
return this;
}
use of com.google.gwt.user.client.ui.UIObject in project gerrit by GerritCodeReview.
the class NavigationTable method scrollIntoView.
protected void scrollIntoView(final Element tr) {
if (!computedScrollType) {
parentScrollPanel = null;
Widget w = getParent();
while (w != null) {
if (w instanceof ScrollPanel) {
parentScrollPanel = (ScrollPanel) w;
break;
}
w = w.getParent();
}
computedScrollType = true;
}
if (parentScrollPanel != null) {
parentScrollPanel.ensureVisible(new UIObject() {
{
setElement(tr);
}
});
} else {
int rt = tr.getAbsoluteTop();
int rl = tr.getAbsoluteLeft();
int rb = tr.getAbsoluteBottom();
int wt = Window.getScrollTop();
int wl = Window.getScrollLeft();
int wh = Window.getClientHeight();
int ww = Window.getClientWidth();
int wb = wt + wh;
// wb < rb: Row bottom is below bottom of window.
if (rl < wl || rt < wt || wb < rt || wb < rb) {
if (rl < wl) {
// If the row fully fits in the window, set 0.
if (tr.getAbsoluteRight() < ww) {
wl = 0;
} else {
wl = Math.max(tr.getAbsoluteLeft() - 5, 0);
}
}
// Vertically center the row in the window.
int h = (wh - (rb - rt)) / 2;
Window.scrollTo(wl, Math.max(rt - h, 0));
}
}
}
Aggregations