Java Code Examples for org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#toShowExtraWidgets()

The following examples show how to use org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#toShowExtraWidgets() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LockBorderWidget.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Checks whether the specified component should show a lock icon. Is used in the
 * {@link LockBorderWidget} widget.
 * 
 * @param comp
 *            Component.
 * @return <code>true</code> if the specified component should show a lock icon,
 *         <code>false</code> otherwise.
 */
private static boolean hasLockIcon(Component comp) {
    if (!SubstanceCoreUtilities.toShowExtraWidgets(comp))
        return false;
    // Skip password fields
    if (comp instanceof JPasswordField) {
        return false;
    }
    // check the HAS_LOCK_ICON property
    boolean isEditableTextComponent = (comp instanceof JTextComponent)
            ? ((JTextComponent) comp).isEditable()
            : false;
    if (comp instanceof JComponent) {
        if (!isEditableTextComponent && Boolean.TRUE
                .equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_LOCK_ICON)))
            return true;
        if (Boolean.FALSE
                .equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_LOCK_ICON)))
            return false;
    }
    if (!isEditableTextComponent
            && Boolean.TRUE.equals(UIManager.get(SubstanceSynapse.HAS_LOCK_ICON)))
        return true;

    return false;
}
 
Example 2
Source File: CapsLockPasswordBorderWidget.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Checks whether the specified component should show a lock icon. Is used in the
 * {@link CapsLockPasswordBorderWidget} widget.
 *
 * @param comp Component.
 * @return <code>true</code> if the specified component should show a lock icon,
 * <code>false</code> otherwise.
 */
private static boolean hasCapsLockIcon(Component comp) {
    if (!SubstanceCoreUtilities.toShowExtraWidgets(comp))
        return false;
    // check the HAS_LOCK_ICON property
    if (comp instanceof JComponent) {
        if (Boolean.TRUE.equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_CAPS_LOCK_ICON)))
            return true;
        if (Boolean.FALSE.equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_CAPS_LOCK_ICON)))
            return false;
    }
    if (Boolean.TRUE.equals(UIManager.get(SubstanceSynapse.HAS_CAPS_LOCK_ICON))) {
        return true;
    }

    return false;
}
 
Example 3
Source File: ScrollPaneSelectorWidget.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void installUI() {
    if (SubstanceCoreUtilities.toShowExtraWidgets(this.jcomp)) {

        PreviewPainter pPainter = WidgetUtilities.getComponentPreviewPainter(this.jcomp);
        if (pPainter == null)
            return;
        this.scrollPaneSelector = new ScrollPaneSelector();
        this.scrollPaneSelector.installOnScrollPane(this.jcomp);
    }
}
 
Example 4
Source File: ScrollPaneSelectorWidget.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void installListeners() {
    this.hierarchyListener = (HierarchyEvent e) -> {
        if (jcomp.getParent() instanceof ComboPopup) {
            if (scrollPaneSelector != null) {
                scrollPaneSelector.uninstallFromScrollPane();
                scrollPaneSelector = null;
            }
        }
    };
    this.jcomp.addHierarchyListener(this.hierarchyListener);

    this.propertyChangeListener = (PropertyChangeEvent evt) -> {
        if (SubstanceSynapse.COMPONENT_PREVIEW_PAINTER.equals(evt.getPropertyName())) {
            PreviewPainter pPainter = WidgetUtilities.getComponentPreviewPainter(jcomp);
            // Uninstall old scroll pane selector
            if (scrollPaneSelector != null) {
                scrollPaneSelector.uninstallFromScrollPane();
                scrollPaneSelector = null;
            }
            // Install new scroll pane selector
            if (pPainter != null && SubstanceCoreUtilities.toShowExtraWidgets(jcomp)) {
                scrollPaneSelector = new ScrollPaneSelector();
                scrollPaneSelector.installOnScrollPane(jcomp);
            }
        }
    };
    this.jcomp.addPropertyChangeListener(this.propertyChangeListener);
}