Example usage for java.beans Beans isDesignTime

List of usage examples for java.beans Beans isDesignTime

Introduction

In this page you can find the example usage for java.beans Beans isDesignTime.

Prototype

public static boolean isDesignTime() 

Source Link

Document

Test if we are in design-mode.

Usage

From source file:ips1ap101.lib.core.control.Controlador.java

private static void init() {
    Bitacora.stamp(Controlador.class.getSimpleName());
    if (Beans.isDesignTime()) {
        Bitacora.trace("Beans.isDesignTime");
    } else if (FacesContext.getCurrentInstance() == null) {
        Bitacora.trace("FacesContext.getCurrentInstance is null");
    } else {//from  w  w  w  .j ava  2s  .co m
        getFunciones();
    }
    Bitacora.trace(Controlador.class, "init", "funciones=" + (_funciones == null ? "?" : _funciones.size()));
}

From source file:com.icesoft.faces.component.panelpositioned.PanelPositionedRenderer.java

public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    try {//ww  w  .  j ava  2 s  .c  om
        DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent);
        if (!domContext.isInitialized()) {
            Element root = domContext.createRootElement(HTML.DIV_ELEM);
            domContext.setRootNode(root);
            setRootElementId(facesContext, root, uiComponent);

            String style = ((PanelPositioned) uiComponent).getStyle();
            String styleClass = ((PanelPositioned) uiComponent).getStyleClass();
            if (style != null && style.length() > 0)
                root.setAttribute(HTML.STYLE_ATTR, style);
            else
                root.removeAttribute(HTML.STYLE_ATTR);
            if (styleClass != null && styleClass.length() > 0)
                root.setAttribute(HTML.CLASS_ATTR, styleClass);
            else
                root.removeAttribute(HTML.CLASS_ATTR);
            Element orderField = domContext.createElement(HTML.INPUT_ELEM);
            String orderFieldId = ClientIdPool.get(getHiddenFieldName(facesContext, uiComponent, INPUT_ID));
            orderField.setAttribute(HTML.ID_ATTR, orderFieldId);
            orderField.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN);
            orderField.setAttribute(HTML.NAME_ATTR, orderFieldId);
            orderField.setAttribute(HTML.VALUE_ATTR, "");

            if (isChanged(facesContext)) {
                // Force the re rendering of the entire component. This is due to a strange quick with positioned
                // panel. When an element is moved in the same list then it container element moves with it
                // When the update occurs the elements are replaced but because the containers have moved
                // then the result looks the same. (But a refresh shows otherwise)
                Node node = domContext.createTextNodeUnescaped("<!-- " + (new Random().nextInt(1000)) + "-->");
                root.appendChild(node);
            }
            root.appendChild(orderField);

        }

        Element root = (Element) domContext.getRootNode();
        if (!Beans.isDesignTime()) {
            DOMContext.removeChildrenByTagName(root, HTML.DIV_ELEM);
        }
    } catch (Exception e) {
        log.error("Encode Begin", e);
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

@SuppressWarnings("unused")
private spx42LogGraphPanel() {
    setBackground(Color.WHITE);/* w  w w . j a va  2  s  .c  o  m*/
    setPreferredSize(new Dimension(796, 504));
    if (Beans.isDesignTime())
        initPanel();
}

From source file:ec.util.chart.swing.JTimeSeriesChart.java

public JTimeSeriesChart() {
    super(Arrays.asList(MARKER, LINE, SPLINE, COLUMN, STACKED_COLUMN, AREA, STACKED_AREA));
    this.chartPanel = new ChartPanel(createTsChart(), false, false, false, false, false);
    this.notification = new ChartNotification(chartPanel.getChart());
    this.seriesSelectionModel = new DefaultListSelectionModel();
    this.mainPlot = (CombinedDomainXYPlot) chartPanel.getChart().getXYPlot();
    this.roSubPlots = mainPlot.getSubplots();
    this.seriesMapFactory = new SeriesMapFactory();
    this.revealObs = false;
    this.fontSupport = new SwingFontSupportImpl();

    notification.suspend();/*ww w.ja va2 s  .com*/

    // initialization
    onColorSchemeSupportChange();
    onLineThicknessChange();
    onPeriodFormatChange();
    onValueFormatChange();
    onSeriesRendererChange();
    onSeriesFormatterChange();
    onSeriesColoristChange();
    onObsFormatterChange();
    onObsColoristChange();
    onDashPredicateChange();
    onLegendVisibilityPredicateChange();
    onPlotDispatcherChange();
    onDatasetChange();
    onTitleChange();
    onNoDataMessageChange();
    onPlotWeightsChange();
    onElementVisibleChange();
    onCrosshairOrientationChange();
    onHoveredObsChange();
    onSelectedObsChange();
    onObsHighlighterChange();
    onTooltipTriggerChange();
    onCrosshairTriggerChange();
    onRevealObsChange();
    onFontSupportChange();

    Charts.avoidScaling(chartPanel);
    Charts.enableFocusOnClick(chartPanel);

    enableObsTriggering();
    enableRevealObs();
    enableSelection();
    enableProperties();

    chartPanel.setActionMap(getActionMap());
    chartPanel.setInputMap(JComponent.WHEN_FOCUSED, getInputMap());

    notification.resume();

    setLayout(new BorderLayout());
    this.add(chartPanel, BorderLayout.CENTER);

    if (Beans.isDesignTime()) {
        setTitle("Preview");
        setElementVisible(Element.TITLE, true);
        setPreferredSize(new Dimension(400, 300));
    }
}

From source file:com.google.gdt.eclipse.designer.uibinder.parser.UiBinderContext.java

/**
 * Ensures that UiBinder is configured for design time.
 *///  w ww  . j  a  va 2  s  .  c om
public void runDesignTime(RunnableEx runnable) throws Exception {
    String isKey = "gwt.UiBinder.isDesignTime " + m_binderClassName.replace('$', '.');
    String resKey = "gwt.UiBinder.designTime " + m_binderResourceName;
    boolean old_designTime = Beans.isDesignTime();
    try {
        Beans.setDesignTime(true);
        // mark "Binder" as design time
        System.setProperty(isKey, "true");
        // put current document content into System, to make it available to UiBinderGenerator
        {
            String content = getContent();
            content = removeWbpNameAttributes(content);
            System.setProperty(resKey, content);
        }
        // do run
        runnable.run();
    } finally {
        m_state.getDevModeBridge().invalidateRebind(m_binderClassName);
        Beans.setDesignTime(old_designTime);
        System.clearProperty(isKey);
        System.clearProperty(resKey);
        getBroadcastSupport().getListener(AfterRunDesignTime.class).invoke();
    }
}

From source file:com.icesoft.faces.component.style.OutputStyleRenderer.java

private int _browserType(String user) {
    int result = DEFAULT_TYPE;
    if (Beans.isDesignTime()) {
        result = DT;//  w w  w .  j av a2 s . com
    } else {
        if (user.indexOf("opera") < 0 && user.indexOf("msie") != -1) {
            result = IE;
            if (user.indexOf("msie 7") != -1) {
                result = IE_7;
            }
            if (user.indexOf("msie 8") != -1) {
                result = IE_8;
            }
        } else if (user.indexOf("safari") != -1) {
            result = SAFARI;
            if (user.indexOf("mobile") != -1) {
                result = SAFARI_MOBILE;
            }
        } else if (user.indexOf("opera") != -1) {
            result = OPERA;
            if (user.indexOf("240x320") != -1) {
                result = OPERA_MOBILE;
            }
        }
    }
    return result;
}

From source file:com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.java

/**
 * Validates that the facesContext is not null, the uiComponent is not null,
 * and that uiComponent is assignment-compatible with the
 * validComponentType. Pass a null parameter for validComponentType to avoid
 * any type checking.//from   www . j av  a  2  s.  c  o  m
 *
 * @param facesContext
 * @param uiComponent
 * @param validComponentType
 * @throws NullPointerException if either of the facesContext or the
 *                              uiComponent parameters are null or
 *                              if a parent form is not
 *                              found when the given UIComponent
 *                              is a UIInput or UICommand,
 *                              IllegalArgumentException if the
 *                              validComponentType is not null and the
 *                              uiComponent is not assignable to the given
 *                              type.
 */
public static void validateParameters(FacesContext facesContext, UIComponent uiComponent,
        Class validComponentType) {

    if (facesContext == null) {
        throw new NullPointerException("Invalid Parameter - FacesContext instance must not be null");
    }
    if (uiComponent == null) {
        throw new NullPointerException("Invalid Parameter - UIComponent instance must not be null");
    }
    if (!Beans.isDesignTime() && validComponentType != null && !(validComponentType.isInstance(uiComponent))) {
        throw new IllegalArgumentException("Invalid Parameter - UIComponent class should be ["
                + validComponentType + "] but it is an instance of [" + uiComponent.getClass() + "]");
    }

    if (log.isDebugEnabled()) {
        if ((uiComponent instanceof UIInput) || (uiComponent instanceof UICommand)) {
            if (findForm(uiComponent) == null) {
                log.debug("Missing Form - the UIComponent of type [" + uiComponent.getClass()
                        + "] requires a containing form.");
            }
        }
    }

}

From source file:com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.java

/**
 * <p/>//from ww  w.j  av a2 s.c  om
 * Given a UIComponent instance, recursively examine the heirarchy of parent
 * NamingContainers until a Form is found. </p>
 *
 * @param uiComponent the UIComponent instance
 * @return form as the UIComponent instance
 */
public static UIComponent findForm(UIComponent uiComponent) {
    UIComponent parent = uiComponent.getParent();
    while (parent != null && !(parent instanceof UIForm)) {
        parent = findNamingContainer(parent);
    }
    UIComponent form = null;
    // check family 
    if (parent != null
            && (parent.getFamily().equalsIgnoreCase(WEB_UIFORM) || parent.getFamily().equalsIgnoreCase(UIFORM)
                    || parent.getFamily().equalsIgnoreCase(WEB_UIJSFFORM))) {
        form = (UIComponent) parent;
    }

    if (form == null && Beans.isDesignTime()) {
        form = uiComponent.getParent();
    }
    return form;
}

From source file:com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.java

protected static String deriveCommonHiddenFieldName(FacesContext facesContext, UIComponent uiComponent) {
    if (Beans.isDesignTime()) {
        return "";
    }/*from   w w  w  .  jav a2 s . c  o m*/
    try {
        UIComponent parentNamingContainer = findNamingContainer(uiComponent);
        String parentClientId = parentNamingContainer.getClientId(facesContext);
        return parentClientId + UINamingContainer.getSeparatorChar(facesContext) + UIViewRoot.UNIQUE_ID_PREFIX
                + HIDDEN_FIELD_NAME;
    } catch (NullPointerException e) {
        throw new RuntimeException("Panel Tab Set must be in a <ice:form>", e);
    }
}

From source file:com.google.gwt.dev.shell.CompilingClassLoader.java

/**
 * Remove some of the excess locking that we'd normally inherit from loadClass.
 *///w  w w  .j a v a 2  s . c  o m
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
    // at design time we want to provide parent ClassLoader, so keep default implementation
    if (Beans.isDesignTime()) {
        return super.loadClass(name, resolve);
    }

    Class c = findLoadedClass(name);
    if (c != null) {
        if (resolve) {
            resolveClass(c);
        }
        return c;
    }

    assert getParent() == null;

    try {
        c = bootstrapClassLoader.loadClass(name);
    } catch (ClassNotFoundException e) {
        c = findClass(name);
    }

    if (resolve) {
        resolveClass(c);
    }

    return c;
}