`
xsuo
  • 浏览: 126800 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

MemoMainScreen

阅读更多

/*
 * MemoMainScreen.java
 *
 * Copyright �1998-2010 Research In Motion Ltd.
 * 
 * Note: For the sake of simplicity, this sample application may not leverage
 * resource bundles and resource strings.  However, it is STRONGLY recommended
 * that application developers make use of the localization features available
 * within the BlackBerry development platform to ensure a seamless application
 * experience across a variety of languages and geographies.  For more information
 * on localizing your application, please refer to the BlackBerry Java Development
 * Environment Development Guide associated with this release.
 */

package com.rim.samples.device.memoapidemo;

import java.util.*;
import javax.microedition.pim.*;
import net.rim.blackberry.api.pdap.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;

/**
 * The main screen for the Memo API demo application.
 */
public final class MemoMainScreen extends MainScreen implements ListFieldCallback
{
    private Vector _memos;
    private BlackBerryMemoList _memoList;
    private ListField _memoListField;
    
    private MenuItem _addItem = new AddItem();

    /**
     * Constructor.  Opens the Memo PIM List and displays a list of memos on the 
     * screen in list format.
     */
    public MemoMainScreen() 
    {
        super();
        
        try 
        {
            _memoList = (BlackBerryMemoList) PIM.getInstance().openPIMList( BlackBerryPIM.MEMO_LIST, BlackBerryPIM.READ_WRITE );
        } 
        catch ( PIMException pe ) 
        {
            // Can't open the Memo PIM List.  Nothing we can do...exiting the application.
            MemoApiDemo.errorDialog("PIM#openPIMList() threw " + pe.toString());
            System.exit( 1 );
        }
        
        _memoListField = new ListField();
        _memoListField.setCallback( this );
        loadMemos();        
        add( _memoListField );
    }    
    
    /**
     * Loads the current list of memos into a vector for easy retrieval.
     */
    private void loadMemos() 
    {
        loadMemos( null );
    }
    
    
    /**
     * Loads the current list of memos into a vector for easy retrieval, and sets
     * the focus of ListField to the provided memo (if it's not null).
     */
    private void loadMemos( BlackBerryMemo memo ) 
    {
        try 
        {
            _memos = new Vector();
            
            Enumeration memoEnum = _memoList.items();
            
            while ( memoEnum.hasMoreElements() ) 
            {
                _memos.addElement( memoEnum.nextElement() );
            }
            
            _memoListField.setSize( _memos.size() );  // Causes the list to be updated and painted.
            
            if ( memo != null ) 
            {
                int index = _memos.indexOf( memo );
                
                if ( index != -1 ) 
                {
                    _memoListField.setSelectedIndex( index );
                }
            }
        } 
        catch ( PIMException pe ) 
        {
            // Had a problem retrieving the memos...
            MemoApiDemo.errorDialog("BlackBerryMemoList#items() threw " + pe.toString());
        }
    }    
    
    /**
     * Returns the memo that is highlighted in the list, or null if no memo is highlighted.
     *  
     * @return The currently selected memo, or null if there is no currently selected memo.
     */
    private BlackBerryMemo getSelectedMemo() 
    {
        int selectedIndex = _memoListField.getSelectedIndex();
        
        if ( selectedIndex == -1 ) 
        {
            return null;
        }
        
        return (BlackBerryMemo) _memos.elementAt( selectedIndex );
    }    
    
    /**
     * @see net.rim.device.api.ui.container.MainScreen#makeMenu(Menu,int)
     */
    protected void makeMenu( Menu menu, int instance ) 
    {
        super.makeMenu( menu, instance );
                
        BlackBerryMemo memo = getSelectedMemo();
        
        if ( memo != null ) 
        {
            // There is a currently selected memo; add menu items to manipulate it.
            menu.add( new ViewItem( memo ) );
            menu.add( new EditItem( memo ) );
            menu.add( new CopyItem( memo ) );
            menu.add( new DeleteItem( memo ) );
        }     
           
        menu.add( _addItem );  // "Add" item is always available.
    }   
    
    /**
     * Override Screen.keyChar() to handle the user pressing ENTER.  Opens the
     * "add memo" screen if no memo is selected; otherwise, the currently selected
     * memo is shown in the "view memo" screen.
     * 
     * @see net.rim.device.api.ui.Screen#keyChar(char,int,int)
     */
    protected boolean keyChar( char key, int status, int time ) 
    {
        if ( key == Characters.ENTER ) 
        {
            BlackBerryMemo memo = getSelectedMemo();
            
            if ( memo == null ) 
            {
                _addItem.run();
            } 
            else 
            {
                new ViewItem( memo ).run();
            }
            
            return true;
        }
        
        return super.keyChar( key, status, time );
    }
    
    /**
     * Overrides Screen.invokeAction().  Handles a trackball click and provides 
     * identical behavior to an ENTER keypress event.
     * 
     * @see net.rim.device.api.ui.Screen#invokeAction(int)
     */
    public boolean invokeAction(int action)
    {        
        switch(action)
        {
            case ACTION_INVOKE: // Trackball click.
                BlackBerryMemo memo = getSelectedMemo();
                
                if ( memo == null ) 
                {
                    _addItem.run();
                } 
                else 
                {
                    new ViewItem( memo ).run();
                }
                
                return true; // We've consumed the event.
        }   
         
        return  super.invokeAction(action);
    }
    
    //////////////////////////////////////
    // ListFieldCallback methods
    //////////////////////////////////////    
    
    /**
     * Draws a row in the list of memos.
     * 
     * @param listField The ListField whose row is being drawn.
     * @param graphics The graphics context to use for drawing.
     * @param index The index of the row being drawn.
     * @param y The distance from the top of the screen where the row is being drawn.
     * @param width The width of the row being drawn.
     * 
     * @see net.rim.device.api.ui.component.ListFieldCallback#drawListRow(ListField,Graphics,int,int,int)
     */
    public void drawListRow( ListField listField, Graphics graphics, int index, int y, int width ) 
    {
        BlackBerryMemo memo = (BlackBerryMemo) get( listField, index );
        
        graphics.drawText( memo.getString( BlackBerryMemo.TITLE, 0 ), 0, y, 0, width );
    }    
    
    /**
     * Retrieves the element from the specified ListField at the specified index. 
     * @param listField The ListField from which to retrieve the element.
     * @param index The index into the ListField from which to retrieve the element.
     * @return The requested element.
     * 
     * @see net.rim.device.api.ui.component.ListFieldCallback#get(ListField , int)
     */
    public Object get( ListField listField, int index ) 
    {
        return _memos.elementAt( index );
    }    
    
    /**
     * Returns the preferred width of the provided ListField. 
     * @param listField The ListField whose preferred width is being retrieved.
     * @return The ListField's preferred width.
     * 
     * @see net.rim.device.api.ui.component.ListFieldCallback#getPreferredWidth(ListField)
     */
    public int getPreferredWidth( ListField listField ) 
    {
        return Display.getWidth();
    }    
    
    /**
     * Retrieves the first occurrence of the provided prefix in the list (not implemented). 
     * @param listField The ListField being searched.
     * @param prefix The prefix to search for.
     * @param start List item at which to start the search.
     * @return -1 (not implemented).
     * 
     * @see net.rim.device.api.ui.component.ListFieldCallback#indexOfList(ListField,String,int)
     */
    public int indexOfList( ListField listField, String prefix, int start ) 
    {
        return -1;
    }
    
    
    ////////////////////// INNER CLASSES //////////////////////    
    
    /**
     * A menu item for adding a new memo.
     */
    private final class AddItem extends MenuItem
    {
        /**
         * Constructor.
         */
        private AddItem() 
        {
            super("Add Memo" , 100, 100 );
        }        
        
        /**
         * Pushes a modal edit screen to the display stack, passing it a new memo to edit. 
         * Upon popping the edit screen from the stack, the memo list is re-loaded.
         */
        public void run() 
        {
            BlackBerryMemo newMemo = _memoList.createMemo();
            UiApplication.getUiApplication().pushModalScreen( new EditMemoScreen( newMemo, true ) );
            MemoMainScreen.this.loadMemos( newMemo );
        }
    }    
    
    /**
     * Menu item for making a copy of a memo.
     */
    private final class CopyItem extends MenuItem
    {
        private BlackBerryMemo _memo;        
        
        /**
         * Constructor. 
         * @param memo The memo to copy.
         */
        private CopyItem( BlackBerryMemo memo ) 
        {
            super( "Add Copy of Memo" , 200, 200 );
            _memo = memo;
        }        
        
        /**
         * Makes a copy of the memo and re-loads the memo list.
         */
        public void run() 
        {
            BlackBerryMemo copy = MemoMainScreen.this._memoList.importMemo( _memo );
            
            try 
            {
                copy.commit();
                MemoMainScreen.this.loadMemos( copy );
            } 
            catch ( PIMException e ) 
            {
                // Oh well...
                MemoApiDemo.errorDialog("BlackBerryMemo#commit() threw " + e.toString());
            }
        }
    }    
    
    /**
     * Menu item for viewing a memo.
     */
    private final class ViewItem extends MenuItem
    {
        private BlackBerryMemo _memo;
        
        
        /**
         * Constructor. 
         * @param memo The memo to view.
         */
        private ViewItem( BlackBerryMemo memo ) 
        {
            super("View Memo" , 300, 50 );
            _memo = memo;
        }        
        
        /**
         * Pushes a view screen to the display stack, passing it the memo to view.
         */
        public void run() 
        {
            // Push a modal screen, because user may go on to edit the memo and therefore
            // we need to know when they return.
            UiApplication.getUiApplication().pushModalScreen( new ViewMemoScreen( _memo ) );
            
            loadMemos( _memo );  // User may have edited the memo; re-load the memo list.
        }
    }    
    
    /**
     * Menu item for editing a memo.
     */
    private final class EditItem extends MenuItem
    {
        private BlackBerryMemo _memo;        
        
        /**
         * Constructor. 
         * @param memo The memo to edit.
         */
        private EditItem( BlackBerryMemo memo ) 
        {
            super("Edit Memo" , 400, 400 );
            _memo = memo;
        }        
        
        /**
         * Pushes a modal edit screen to the display stack, passing it the memo to edit.  
         * Upon popping the edit screen off the display stack, the memo list is re-loaded.
         */
        public void run() 
        {
            UiApplication.getUiApplication().pushModalScreen( new EditMemoScreen( _memo, false ) );
            MemoMainScreen.this.loadMemos( _memo );
        }
    }    
    
    /**
     * Menu item to delete a memo.
     */
    private final class DeleteItem extends MenuItem
    {
        private BlackBerryMemo _memo;        
        
        /**
         * Constructor. 
         * @param memo The memo to delete.
         */
        private DeleteItem( BlackBerryMemo memo ) 
        {
            super("Delete Memo" , 500, 500 );
            _memo = memo;
        }        
        
        /**
         * Displays a dialog asking the user to confirm the delete.  If confirmed,
         * the memo is deleted and the memo list re-loaded.
         */
        public void run() 
        {
            try 
            {
                if ( Dialog.ask( Dialog.D_DELETE, "Delete memo?", Dialog.CANCEL ) == Dialog.DELETE ) 
                {
                    _memoList.removeMemo( _memo );
                    MemoMainScreen.this.loadMemos();
                }
            } 
            catch ( PIMException e ) 
            {
                // Shouldn't happen...
                MemoApiDemo.errorDialog("BlackBerryMemoList#removeMemo() threw " + e.toString());
            }
        }
    }
}
 
分享到:
评论

相关推荐

    [附源码+数据库+毕业论文+部署教程+配套软件]基于SpringBoot+MyBatis+MySQL+Maven+Vue的停车场管理系统,推荐!

    一、项目简介 包含:项目源码、数据库脚本等,该项目附带全部源码可作为毕设使用。 项目都经过严格调试,eclipse或者idea 确保可以运行! 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷 二、技术实现 jdk版本:1.8 及以上 ide工具:IDEA或者eclipse 数据库: mysql5.5及以上 后端:spring+springboot+mybatis+maven+mysql 前端: vue , css,js , elementui 三、系统功能 1、系统角色主要包括:管理员、用户 2、系统功能 前台功能包括: 用户登录 车位展示 系统推荐车位 立即预约 公告展示 个人中心 车位预定 违规 余额充值 后台功能: 首页,个人中心,修改密码,个人信息 用户管理 管理员管理 车辆管理 车位管理 车位预定管理,统计报表 公告管理 违规管理 公告类型管理 车位类型管理 车辆类型管理 违规类型管理 轮播图管理 详见 https://flypeppa.blog.csdn.net/article/details/146122666

    springboot656基于java-springboot的农机电招平台毕业设计(代码+数据库+论文+PPT+演示录像+运行教学+软件下载).zip

    项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 技术组成 语言:java 开发环境:idea 数据库:MySql 部署环境:maven 数据库工具:navica 更多毕业设计https://cv2022.blog.csdn.net/article/details/124463185

    Python程序设计学习思维导图-仅供参考

    内容为Python程序设计的思维导图,适用于新手小白进行浏览,理清思路

    2024-Stable Diffusion全套资料(软件+关键词+模型).rar

    2024-Stable Diffusion全套资料(软件+关键词+模型).rar

    mmexport1741417035005.png

    mmexport1741417035005.png

    COMSOL三维锂离子电池全耦合电化学热应力模型:模拟充放电过程中的多物理场耦合效应及电芯内应力应变情况,COMSOL锂离子电池热应力全耦合模型,comsol三维锂离子电池电化学热应力全耦合模型锂离子

    COMSOL三维锂离子电池全耦合电化学热应力模型:模拟充放电过程中的多物理场耦合效应及电芯内应力应变情况,COMSOL锂离子电池热应力全耦合模型,comsol三维锂离子电池电化学热应力全耦合模型锂离子电池耦合COMSOL固体力学模块和固体传热模块,模型仿真模拟电池在充放电过程中由于锂插层,热膨胀以及外部约束所导致的电极的应力应变情况结果有电芯中集流体,电极,隔膜的应力应变以及压力情况等,电化学-力单向耦合和双向耦合 ,关键词: 1. COMSOL三维锂离子电池模型; 2. 电化学热应力全耦合模型; 3. 锂离子电池; 4. 固体力学模块; 5. 固体传热模块; 6. 应力应变情况; 7. 电芯中集流体; 8. 电极; 9. 隔膜; 10. 电化学-力单向/双向耦合。,COMSOL锂离子电池全耦合热应力仿真模型

    基于传递矩阵法的一维层状声子晶体振动传输特性及其优化设计与应用,声子晶体传递矩阵法解析及应用,Matlab 一维层状声子晶体振动传输特性 传递矩阵法在声子晶体的设计和应用中具有重要作用 通过调整声子

    基于传递矩阵法的一维层状声子晶体振动传输特性及其优化设计与应用,声子晶体传递矩阵法解析及应用,Matlab 一维层状声子晶体振动传输特性 传递矩阵法在声子晶体的设计和应用中具有重要作用。 通过调整声子晶体的材料、周期和晶格常数等参数,可以设计出具有特定带隙结构的声子晶体,用于滤波、减震、降噪等应用。 例如,通过调整声子晶体的周期数和晶格常数,可以改变带隙的位置和宽度,从而实现特定的频率范围内的噪声控制。 此外,传递矩阵法还可以用于分析和优化声子晶体的透射谱,为声学器件的设计提供理论依据。 ,Matlab; 一维层状声子晶体; 振动传输特性; 传递矩阵法; 材料调整; 周期和晶格常数; 带隙结构; 滤波; 减震; 降噪; 透射谱分析; 声学器件设计,Matlab模拟声子晶体振动传输特性及优化设计研究

    头部姿态估计(HeadPose Estimation)-Android源码

    头部姿态估计(HeadPose Estimation)-Android源码

    永磁同步电机FOC、MPC与高频注入Simulink模型及基于MBD的代码生成工具,适用于Ti f28335与dspace/ccs平台开发,含电机控制开发文档,永磁同步电机控制技术:FOC、MPC与高

    永磁同步电机FOC、MPC与高频注入Simulink模型及基于MBD的代码生成工具,适用于Ti f28335与dspace/ccs平台开发,含电机控制开发文档,永磁同步电机控制技术:FOC、MPC与高频注入Simulink模型开发及应用指南,提供永磁同步电机FOC,MPC,高频注入simulink模型。 提供基于模型开发(MBD)代码生成模型,可结合Ti f28335进行电机模型快速开发,可适用dspace平台或者ccs平台。 提供电机控制开发编码器,转子位置定向,pid调试相关文档。 ,永磁同步电机; FOC控制; MPC控制; 高频注入; Simulink模型; 模型开发(MBD); Ti f28335; 电机模型开发; dspace平台; ccs平台; 编码器; 转子位置定向; pid调试。,永磁同步电机MPC-FOC控制与代码生成模型

    light of warehouse.zip

    light of warehouse.zip

    考虑温度和气体排放等因素的工业乙醇发酵过程及其Matlab源码-乙醇发酵-气体排放-Matlab建模和仿真-代谢路径

    内容概要:文章深入讨论了工业乙醇发酵的基本原理及工艺流程,特别是在温度和气体排放(如CO2及其他有害气体)影响下的发酵效果分析。文章介绍了乙醇发酵的重要环节,如糖分解、代谢路径、代谢调控以及各阶段的操作流程,重点展示了如何通过Matlab建模和仿真实验来探索这两个关键环境因素对发酵过程的具体影响。通过动态模型仿真分析,得出合适的温度范围以及适时排除CO2能显著提升发酵产乙醇的效果与效率,从而提出了基于仿真的优化发酵生产工艺的新方法。 适用人群:从事生物工程相关领域研究的科学家、工程师及相关专业师生。 使用场景及目标:适用于实验室环境、学术交流会议及实际生产指导中,以提升研究人员对该领域内复杂现象的理解能力和技术水平为目标。 其他说明:附录中有详细的数学公式表达和程序代码可供下载执行,便于有兴趣的研究团队重复实验或者继续扩展研究工作。

    Tomcat资源包《Tomcat启动报错:CATALINA-HOME环境变量未正确配置的完整解决方案》

    本资源包专为解决 Tomcat 启动时提示「CATALINA_HOME 环境变量未正确配置」问题而整理,包含以下内容: 1. **Apache Tomcat 9.0.69 官方安装包**:已验证兼容性,解压即用。 2. **环境变量配置指南**: - Windows 系统下 `CATALINA_HOME` 和 `JAVA_HOME` 的详细配置步骤。 - 常见错误排查方法(如路径含空格、未生效问题)。 3. **辅助工具脚本**:一键检测环境变量是否生效的批处理文件。 4. **解决方案文档**:图文并茂的 PDF 文档,涵盖从报错分析到成功启动的全流程。 适用场景: - Tomcat 9.x 版本环境配置 - Java Web 开发环境搭建 - 运维部署调试 注意事项: - 资源包路径需为纯英文,避免特殊字符。 - 建议使用 JDK 8 或更高版本。

    java毕业设计源码 仿360buy京东商城源码 京东JavaWeb项目源代码

    这是一款仿照京东商城的Java Web项目源码,完美复现了360buy的用户界面和购物流程,非常适合Java初学者和开发者进行学习与实践。通过这份源码,你将深入了解电商平台的架构设计和实现方法。欢迎大家下载体验,提升自己的编程能力!

    java-springboot+vue的乒乓球馆预约管理系统源码.zip

    系统选用B/S模式,后端应用springboot框架,前端应用vue框架, MySQL为后台数据库。 本系统基于java设计的各项功能,数据库服务器端采用了Mysql作为后台数据库,使Web与数据库紧密联系起来。 在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。

    【javaweb毕业设计源码】大学生求职就业网

    这是一款专为大学生打造的求职就业网JavaWeb毕业设计源码,功能齐全,界面友好。它提供简历投递、职位搜索、在线交流等多种实用功能,能够帮助你顺利进入职场。无论你是想提升技术水平还是寻找灵感,这个源码都是不可多得的资源。快来下载,让你的求职之路更加顺畅吧!

    useTable(1).ts

    useTable(1).ts

    DSP实验报告汇总.pdf

    实验一: 1、进行CCS6.1软件的安装,仿真器的设置,程序的编译和调试; 2、熟悉CCS软件中的C语言编程; 3、使用按键控制LED跑马灯的开始与停止、闪烁频率; 4、调试Convolution、FFT、FIR、FFT-FIR实验,编制IIR算法并调试,并在CCS软件上给出实验结果。 实验二: 1、利用定时器周期中断或下溢中断和比较器比较值的修改来实现占空比可调的PWM波形; 2、改变PWM占空比控制LED灯的亮暗,按键实现10级LED灯亮暗调整; 3、模拟数字转换,转换过程中LED指示,并在变量窗口显示转换结果; 4、数字模拟转换,产生一个正弦波,转换过程中LED指示,转换完成后在CCS调试窗口显示波形。 实验三: 1、SCI异步串行通信实验; 2、SPI及IIC同步串行通信实验; 3、CAN现场总线串行通信实验; 4、传输过程中LED指示。 实验四: 1、电机转速控制实验。

    LINUX系统管理与配置.docx

    LINUX系统管理与配置.docx

    chromedriver-mac-x64-136.0.7055.0.zip

    chromedriver-mac-x64-136.0.7055.0.zip

    中国标准地图-审图号GS(2020)4619号-shp格式

    地级城市驻地,dbf 地级城市驻地,prj 地级城市驻地.sbn 9 地级城市驻地.sbx 地级城市驻地.shp 地级城市驻地.shx 9 国界线.dbf 国界线.prj 国界线.sbne 国界线.sbx 国界线.shp 国界线.shx )经纬网.dbf ]经纬网.prj 经纬网.sbn 经纬网.sbx 经纬网.shp 经纬网.shx 全国县级统计数据.dbf 全国县级统计数据,prj 全国县级统计数据.sbr 全国县级统计数据.sbx 全国县级统计数据.shp 全国县级统计数据.shx )省会城市.dbf 省会城市,prj 省会城市.sbn 省会城市.sbx 省会城市.shp 省会城市.shx 省级行政区.dbf 省级行政区,pn 省级行政区.sbn 省级行政区,sbx 9 省级行政区.shp 9 6 省级行政区,shx 县城驻地.dbf 县城驻地,prj 擷垃岑械鰣媛城驻地.sbr 藶勇瑁鴎隐城驻地.sbx 县蓿玨蒴城驻地.shp 苽6城驻地,shx 线状省界.dbf 线状省界,prj 1线状首界,sbn 线状省界.sbx 线状首界.shp 线状省界,shx 线状县界,dbf □]

Global site tag (gtag.js) - Google Analytics