Example usage for com.google.gwt.user.client.ui FocusWidget setEnabled

List of usage examples for com.google.gwt.user.client.ui FocusWidget setEnabled

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FocusWidget setEnabled.

Prototype

public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether this widget is enabled.

Usage

From source file:com.google.gerrit.client.ui.ActionDialog.java

License:Apache License

public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect, String dialogTitle,
        String dialogHeading) {//from  www .ja v  a2 s  . c o m
    super(dialogTitle, dialogHeading, new ChangeDetailCache.IgnoreErrorCallback() {
        @Override
        public void onSuccess(ChangeDetail result) {
            if (redirect) {
                Gerrit.display(PageLinks.toChange(result.getChange().getId()));
            } else {
                super.onSuccess(result);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            enableOnFailure.setEnabled(true);
        }
    });
}

From source file:com.threerings.gwt.ui.Bindings.java

License:Open Source License

/**
 * Binds the enabledness state of the target widget to the supplied boolean value.
 *//*from w w w  . j  a  v a2s.  c o m*/
public static void bindEnabled(Value<Boolean> value, final FocusWidget... targets) {
    value.addListenerAndTrigger(new Value.Listener<Boolean>() {
        public void valueChanged(Boolean enabled) {
            for (FocusWidget target : targets) {
                target.setEnabled(enabled);
            }
        }
    });
}

From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java

License:Open Source License

/**
 * Update generic component features./*from  w  ww.  ja v  a2  s .  com*/
 * 
 * <h2>Selecting correct implementation</h2>
 * 
 * <p>
 * The implementation of a component depends on many properties, including
 * styles, component features, etc. Sometimes the user changes those
 * properties after the component has been created. Calling this method in
 * the beginning of your updateFromUIDL -method automatically replaces your
 * component with more appropriate if the requested implementation changes.
 * </p>
 * 
 * <h2>Caption, icon, error messages and description</h2>
 * 
 * <p>
 * Component can delegate management of caption, icon, error messages and
 * description to parent layout. This is optional an should be decided by
 * component author
 * </p>
 * 
 * <h2>Component visibility and disabling</h2>
 * 
 * This method will manage component visibility automatically and if
 * component is an instanceof FocusWidget, also handle component disabling
 * when needed.
 * 
 * @param component
 *            Widget to be updated, expected to implement an instance of
 *            Paintable
 * @param uidl
 *            UIDL to be painted
 * @param manageCaption
 *            True if you want to delegate caption, icon, description and
 *            error message management to parent.
 * 
 * @return Returns true iff no further painting is needed by caller
 */
public boolean updateComponent(Widget component, UIDL uidl, boolean manageCaption) {
    String pid = getPid(component.getElement());
    if (pid == null) {
        VConsole.error("Trying to update an unregistered component: " + Util.getSimpleName(component));
        return true;
    }

    ComponentDetail componentDetail = idToPaintableDetail.get(pid);

    if (componentDetail == null) {
        VConsole.error("ComponentDetail not found for " + Util.getSimpleName(component) + " with PID " + pid
                + ". This should not happen.");
        return true;
    }

    // If the server request that a cached instance should be used, do
    // nothing
    if (uidl.getBooleanAttribute("cached")) {
        return true;
    }

    // register the listened events by the server-side to the event-handler
    // of the component
    componentDetail.registerEventListenersFromUIDL(uidl);

    // Visibility
    boolean visible = !uidl.getBooleanAttribute("invisible");
    boolean wasVisible = component.isVisible();
    component.setVisible(visible);
    if (wasVisible != visible) {
        // Changed invisibile <-> visible
        if (wasVisible && manageCaption) {
            // Must hide caption when component is hidden
            final Container parent = Util.getLayout(component);
            if (parent != null) {
                parent.updateCaption((Paintable) component, uidl);
            }

        }
    }

    if (configuration.useDebugIdInDOM() && uidl.getId().startsWith("PID_S")) {
        DOM.setElementProperty(component.getElement(), "id", uidl.getId().substring(5));
    }

    if (!visible) {
        // component is invisible, delete old size to notify parent, if
        // later make visible
        componentDetail.setOffsetSize(null);
        return true;
    }

    // Switch to correct implementation if needed
    if (!widgetSet.isCorrectImplementation(component, uidl, configuration)) {
        final Widget w = (Widget) widgetSet.createWidget(uidl, configuration);
        // deferred binding check TODO change isCorrectImplementation to use
        // stored detected class, making this innecessary
        if (w.getClass() != component.getClass()) {
            final Container parent = Util.getLayout(component);
            if (parent != null) {
                parent.replaceChildComponent(component, w);
                unregisterPaintable((Paintable) component);
                registerPaintable(uidl.getId(), (Paintable) w);
                ((Paintable) w).updateFromUIDL(uidl, this);
                return true;
            }
        }
    }

    boolean enabled = !uidl.getBooleanAttribute("disabled");
    if (uidl.hasAttribute("tabindex") && component instanceof Focusable) {
        ((Focusable) component).setTabIndex(uidl.getIntAttribute("tabindex"));
    }
    /*
     * Disabled state may affect (override) tabindex so the order must be
     * first setting tabindex, then enabled state.
     */
    if (component instanceof FocusWidget) {
        FocusWidget fw = (FocusWidget) component;
        fw.setEnabled(enabled);
    }

    StringBuffer styleBuf = new StringBuffer();
    final String primaryName = component.getStylePrimaryName();
    styleBuf.append(primaryName);

    // first disabling and read-only status
    if (!enabled) {
        styleBuf.append(" ");
        styleBuf.append(DISABLED_CLASSNAME);
    }
    if (uidl.getBooleanAttribute("readonly")) {
        styleBuf.append(" ");
        styleBuf.append("v-readonly");
    }

    // add additional styles as css classes, prefixed with component default
    // stylename
    if (uidl.hasAttribute("style")) {
        final String[] styles = uidl.getStringAttribute("style").split(" ");
        for (int i = 0; i < styles.length; i++) {
            styleBuf.append(" ");
            styleBuf.append(primaryName);
            styleBuf.append("-");
            styleBuf.append(styles[i]);
            styleBuf.append(" ");
            styleBuf.append(styles[i]);
        }
    }

    // add modified classname to Fields
    if (uidl.hasAttribute("modified") && component instanceof Field) {
        styleBuf.append(" ");
        styleBuf.append(MODIFIED_CLASSNAME);
    }

    TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
    // Update tooltip
    if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
        tooltipInfo.setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION));
    } else {
        tooltipInfo.setTitle(null);
    }

    // add error classname to components w/ error
    if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
        tooltipInfo.setErrorUidl(uidl.getErrors());
        styleBuf.append(" ");
        styleBuf.append(primaryName);
        styleBuf.append(ERROR_CLASSNAME_EXT);
    } else {
        tooltipInfo.setErrorUidl(null);
    }

    // add required style to required components
    if (uidl.hasAttribute("required")) {
        styleBuf.append(" ");
        styleBuf.append(primaryName);
        styleBuf.append(REQUIRED_CLASSNAME_EXT);
    }

    // Styles + disabled & readonly
    component.setStyleName(styleBuf.toString());

    // Set captions
    if (manageCaption) {
        final Container parent = Util.getLayout(component);
        if (parent != null) {
            parent.updateCaption((Paintable) component, uidl);
        }
    }
    /*
     * updateComponentSize need to be after caption update so caption can be
     * taken into account
     */

    updateComponentSize(componentDetail, uidl);

    return false;
}

From source file:eml.studio.client.ui.panel.Grid.ETLGrid.java

License:Open Source License

public void lock() {
    for (FocusWidget wgt : paramBoxs) {
        wgt.setEnabled(false);
    }
}

From source file:eml.studio.client.ui.panel.Grid.ETLGrid.java

License:Open Source License

public void unlock() {
    for (FocusWidget wgt : paramBoxs) {
        wgt.setEnabled(true);
    }
}

From source file:tv.dyndns.kishibe.qmaclone.client.creation.CreationUi.java

License:Open Source License

private void setEnable(boolean enabled) {
    FocusWidget[] widgets = { buttonNewProblem, buttonMoveToVerification, buttonSendProblem, textBoxGetProblem,
            buttonGetProblem, buttonCopyProblem, buttonNextProblem };
    for (FocusWidget widget : widgets) {
        widget.setEnabled(enabled);
    }/*from   w  w w  .j a va2  s .  c o  m*/
    widgetProblemForm.setEnable(enabled);
}

From source file:tv.dyndns.kishibe.qmaclone.client.creation.WidgetProblemForm.java

License:Open Source License

public void setEnable(boolean enabled) {
    List<FocusWidget> focusWidgets = Lists.newArrayList(listBoxGenre, listBoxType, listBoxRandomFlag,
            textAreaSentence, textBoxAnswer[0], textBoxAnswer[1], textBoxAnswer[2], textBoxAnswer[3],
            textBoxChoice[0], textBoxChoice[1], textBoxChoice[2], textBoxChoice[3], radioButtonNone,
            radioButtonImage, radioButtonYouTube, textBoxExternalUrl, textBoxCreator, textAreaNote,
            checkBoxResetAnswerCount, checkBoxImageChoice, checkBoxImageAnswer, checkBoxRemovePlayerAnswers,
            buttonClearProblemFeedback, checkBoxResetVote);
    focusWidgets.addAll(buttonPolygonCreation);

    for (FocusWidget focusWidget : focusWidgets) {
        focusWidget.setEnabled(enabled);
    }/*from  w w  w  . j ava2s .  c  o  m*/
}