Search in sources :

Example 66 with Dictionary

use of java.util.Dictionary in project sling by apache.

the class XingLoginAuthenticationHandler method configure.

protected void configure(final ComponentContext context) {
    final Dictionary properties = context.getProperties();
    consumerKey = PropertiesUtil.toString(properties.get(CONSUMER_KEY_PARAMETER), "").trim();
    userCookie = PropertiesUtil.toString(properties.get(USER_COOKIE_PARAMETER), DEFAULT_USER_COOKIE).trim();
    userIdCookie = PropertiesUtil.toString(properties.get(USERID_COOKIE_PARAMETER), DEFAULT_USERID_COOKIE).trim();
    maxCookieSize = PropertiesUtil.toInteger(properties.get(MAX_COOKIE_SIZE_PARAMETER), DEFAULT_MAX_COOKIE_SIZE);
    loginPath = PropertiesUtil.toString(properties.get(LOGIN_PATH_PARAMETER), "").trim();
    logoutPath = PropertiesUtil.toString(properties.get(LOGOUT_PATH_PARAMETER), "").trim();
    if (StringUtils.isEmpty(consumerKey)) {
        logger.warn("configured consumer key is empty");
        xingCookie = "";
    } else {
        xingCookie = XingLogin.XING_COOKIE_PREFIX.concat(consumerKey);
    }
    if (loginPageRegistration != null) {
        loginPageRegistration.unregister();
    }
    if (StringUtils.isEmpty(loginPath)) {
        logger.warn("configured login path is empty");
    } else {
        final Dictionary<String, Object> loginPathProperties = new Hashtable<String, Object>();
        final String[] authRequirements = new String[] { "-".concat(loginPath) };
        loginPathProperties.put(AuthConstants.AUTH_REQUIREMENTS, authRequirements);
        loginPageRegistration = context.getBundleContext().registerService(Object.class.getName(), new Object(), loginPathProperties);
    }
    if (StringUtils.isEmpty(logoutPath)) {
        logger.warn("configured logout path is empty");
    }
    logger.info("configured with consumer key '{}', cookie name '{}', login path '{}' and logout path '{}'", consumerKey, xingCookie, loginPath, logoutPath);
}
Also used : Dictionary(java.util.Dictionary) Hashtable(java.util.Hashtable)

Example 67 with Dictionary

use of java.util.Dictionary in project jdk8u_jdk by JetBrains.

the class BasicSliderUI method paintLabels.

public void paintLabels(Graphics g) {
    Rectangle labelBounds = labelRect;
    Dictionary dictionary = slider.getLabelTable();
    if (dictionary != null) {
        Enumeration keys = dictionary.keys();
        int minValue = slider.getMinimum();
        int maxValue = slider.getMaximum();
        boolean enabled = slider.isEnabled();
        while (keys.hasMoreElements()) {
            Integer key = (Integer) keys.nextElement();
            int value = key.intValue();
            if (value >= minValue && value <= maxValue) {
                JComponent label = (JComponent) dictionary.get(key);
                label.setEnabled(enabled);
                if (label instanceof JLabel) {
                    Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();
                    if (icon instanceof ImageIcon) {
                        // Register Slider as an image observer. It allows to catch notifications about
                        // image changes (e.g. gif animation)
                        Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
                    }
                }
                if (slider.getOrientation() == JSlider.HORIZONTAL) {
                    g.translate(0, labelBounds.y);
                    paintHorizontalLabel(g, value, label);
                    g.translate(0, -labelBounds.y);
                } else {
                    int offset = 0;
                    if (!BasicGraphicsUtils.isLeftToRight(slider)) {
                        offset = labelBounds.width - label.getPreferredSize().width;
                    }
                    g.translate(labelBounds.x + offset, 0);
                    paintVerticalLabel(g, value, label);
                    g.translate(-labelBounds.x - offset, 0);
                }
            }
        }
    }
}
Also used : Dictionary(java.util.Dictionary) Enumeration(java.util.Enumeration)

Example 68 with Dictionary

use of java.util.Dictionary in project jdk8u_jdk by JetBrains.

the class BasicSliderUI method labelsHaveSameBaselines.

/**
     * Returns true if all the labels from the label table have the same
     * baseline.
     *
     * @return true if all the labels from the label table have the
     *         same baseline
     * @since 1.6
     */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width, pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    } else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                } else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        } else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
Also used : Dictionary(java.util.Dictionary) Enumeration(java.util.Enumeration)

Example 69 with Dictionary

use of java.util.Dictionary in project jdk8u_jdk by JetBrains.

the class BasicSliderUI method getHeightOfTallestLabel.

protected int getHeightOfTallestLabel() {
    Dictionary dictionary = slider.getLabelTable();
    int tallest = 0;
    if (dictionary != null) {
        Enumeration keys = dictionary.keys();
        while (keys.hasMoreElements()) {
            JComponent label = (JComponent) dictionary.get(keys.nextElement());
            tallest = Math.max(label.getPreferredSize().height, tallest);
        }
    }
    return tallest;
}
Also used : Dictionary(java.util.Dictionary) Enumeration(java.util.Enumeration)

Example 70 with Dictionary

use of java.util.Dictionary in project jdk8u_jdk by JetBrains.

the class BasicSliderUI method getWidthOfWidestLabel.

protected int getWidthOfWidestLabel() {
    Dictionary dictionary = slider.getLabelTable();
    int widest = 0;
    if (dictionary != null) {
        Enumeration keys = dictionary.keys();
        while (keys.hasMoreElements()) {
            JComponent label = (JComponent) dictionary.get(keys.nextElement());
            widest = Math.max(label.getPreferredSize().width, widest);
        }
    }
    return widest;
}
Also used : Dictionary(java.util.Dictionary) Enumeration(java.util.Enumeration)

Aggregations

Dictionary (java.util.Dictionary)198 Hashtable (java.util.Hashtable)91 Test (org.junit.Test)48 Configuration (org.osgi.service.cm.Configuration)33 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)28 State (org.eclipse.osgi.service.resolver.State)28 Enumeration (java.util.Enumeration)27 Properties (java.util.Properties)27 BundleContext (org.osgi.framework.BundleContext)24 ArrayList (java.util.ArrayList)22 ServiceReference (org.osgi.framework.ServiceReference)21 HashMap (java.util.HashMap)20 ServiceRegistration (org.osgi.framework.ServiceRegistration)20 IOException (java.io.IOException)17 Map (java.util.Map)17 Bundle (org.osgi.framework.Bundle)16 LinkedHashMap (java.util.LinkedHashMap)13 List (java.util.List)13 Matchers.anyString (org.mockito.Matchers.anyString)11 MinionIdentity (org.opennms.minion.core.api.MinionIdentity)11