zoukankan      html  css  js  c++  java
  • Spark研究笔记5:重要的工厂类NativeManager(原创) CVT

    NativeManager目前主要是为了闪屏插件(org.jivesoftware.spark.plugin.flashing)服务的,主要是操作NativeHandler列表,而NativeHandler接口的主要实现类是FlashingHandler,FlashingHandler的定义:

    public class FlashingHandler implements NativeHandler {
        private FlashWindow flasher;
    
        public FlashingHandler() {
            flasher = new FlashWindow();
        }
    
        @Override
        public void flashWindow(Window window) {
            FlashingPreference preference = (FlashingPreference) SparkManager.getPreferenceManager().getPreference(FlashingPreference.NAMESPACE);
            if (preference.getPreferences().isFlashingEnabled()) {
                if (preference.getPreferences().getFlashingType().equals(FlashingPreferences.TYPE_CONTINOUS)) {
                    flasher.startFlashing(window);
                }
                else if (preference.getPreferences().getFlashingType().equals(FlashingPreferences.TYPE_TEMPORARY)) {
                    flasher.flash(window, 1500, 5);
                }
            }
        }

    实际上在整个工程NativeManager从未被实例化过,这真是件奇怪的事情,不过这个类不是特别关键。

    /**
     * $RCSfile: ,v $
     * $Revision: $
     * $Date: $
     * 
     * Copyright (C) 2004-2011 Jive Software. All rights reserved.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    package org.jivesoftware.spark;
    
    import java.awt.Window;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    import org.jivesoftware.spark.util.ModelUtil;
    
    /**
     * The AlertManager handles the delegation of Alerting based.
     *
     * @author Derek DeMoro
     */
    public class NativeManager {
    
        private List<NativeHandler> nativeHandlers = new ArrayList<NativeHandler>();
    
        public NativeManager() {
    
        }
    
        /**
         * Adds an alert.
         *
         * @param nativeHandler the Alerter to add.
         */
        public void addNativeHandler(NativeHandler nativeHandler) {
            nativeHandlers.add(nativeHandler);
        }
    
        /**
         * Removes an alerter.
         *
         * @param nativeHandler the alerter to remove.
         */
        public void removeNativeHandler(NativeHandler nativeHandler) {
            nativeHandlers.remove(nativeHandler);
        }
    
    
        /**
         * Flash the given window.
         *
         * @param window the window to flash.
         */
        public void flashWindow(Window window) {
            final Iterator<NativeHandler> alertNotifier = ModelUtil.reverseListIterator(nativeHandlers.listIterator());
            while (alertNotifier.hasNext()) {
                final NativeHandler alert = alertNotifier.next();
                boolean handle = alert.handleNotification();
                if (handle) {
                    alert.flashWindow(window);
                }
            }
        }
    
        /**
         * Flash the given window, but stop flashing when the window takes focus.
         *
         * @param window the window to start flashing.
         */
        public void flashWindowStopOnFocus(Window window) {
            final Iterator<NativeHandler> alertNotifiers = ModelUtil.reverseListIterator(nativeHandlers.listIterator());
            while (alertNotifiers.hasNext()) {
                final NativeHandler alert = alertNotifiers.next();
                boolean handle = alert.handleNotification();
                if (handle) {
                    alert.flashWindowStopWhenFocused(window);
                }
            }
        }
    
        /**
         * Stop the flashing of the window.
         *
         * @param window the window to stop flashing.
         */
        public void stopFlashing(Window window) {
            final Iterator<NativeHandler> alertNotifiers = ModelUtil.reverseListIterator(nativeHandlers.listIterator());
            while (alertNotifiers.hasNext()) {
                final NativeHandler alert = alertNotifiers.next();
                boolean handle = alert.handleNotification();
                if (handle) {
                    alert.stopFlashing(window);
                }
            }
        }
    
    }
  • 相关阅读:
    The parent project must have a packaging type of POM
    oracle中PLSQL存储过程中如何使用逗号分隔的集合(逗号分隔字符串转换为一个集合)
    此实现不是 Windows 平台 FIPS 验证的加密算法的一部分的解决办法方案
    @Modules( ... ) 多个包路径问题
    phpstorm常用操作---1、phpstorm安装插件
    phpstorm中如何配置phpunit(单元测试)
    前端性能优化---3、静态资源使用cdn加速
    前端性能优化---2、图片响应式加载
    前端性能优化---1、懒加载和复杂资源点击时再请求
    Javascript进阶课程---1、使用工厂模式创建对象
  • 原文地址:https://www.cnblogs.com/openfire/p/3047610.html
Copyright © 2011-2022 走看看