⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uicontroller.java

📁 moblie syncml mail javame
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    display.setCurrent(new PhoneNumberList(body));
    }
     */
    /**
     * Methods to show settings screens
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     *
     */
    public static void showSettings(Displayable displayable) {
        backStack.push(displayable);

        display.setCurrent(new SettingsList());
    }

    /**
     *show account settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     *
     */
    public static void showAccountSettings(Displayable displayable) {
        display.setCurrentItem(getAccountSettingsForm(displayable).getFocusedItem());

    }

    /**
     * @return the account settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static AccountSettingsForm getAccountSettingsForm(Displayable displayable) {
        backStack.push(displayable);
        if (accountSettingsForm == null) {
            accountSettingsForm = new AccountSettingsForm();
        }
        return accountSettingsForm;
    }

    /**
     * show the mail sync settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showMailSyncSettings(Displayable displayable) {
        backStack.push(displayable);
        if (getMailSettingsScreen == null) {
            getMailSettingsScreen = new GeneralSettingsForm();
        }
        display.setCurrent(getMailSettingsScreen);
    }

    /**
     * show the log view form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showLogViewer(Displayable displayable) {
        backStack.push(displayable);
        logViewerScreen = new LogViewerForm();
        display.setCurrent(logViewerScreen);
    }

    /**
     * show the recipient list form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showRecipientsList(Displayable displayable, Message message) {
        backStack.push(displayable);
        display.setCurrent(new RecipientList(message));
    }

    /**
     * show the contact list
     * @param backscreen the screen to be put in the stack for future back commands
     */
    public static void showContactList(Displayable backScreen) {
        if (!contactsLoader.isLocked()) {
            backStack.push(backScreen);
            getContactList().rewindList();
            getContactList().resetSubtitle();
            display.setCurrent(getContactList());
        } else {
            //show alert to inform the user that the contact list is needed 
            //to perform this operation and he must wait the full contacts 
            //cache loading
            showErrorAlert(
                    Localization.getMessages().CONTACTSLOADER_LOCKED_ERROR,
                    backScreen);

        }

    }

    public static void showAddContactScreen(Displayable displayable,
            ContactList addressList) {
        backStack.push(displayable);
        display.setCurrent(new AddContactForm(addressList));
    }

    public static void showAddContactScreen(Displayable displayable) {
        showAddContactScreen(displayable, (ContactList) null);
    }

    public static void showAddContactScreen(Displayable displayable, Contact contact) {
        backStack.push(displayable);
        UIController.display.setCurrent(new AddContactForm(contact, getContactList(), true));
    }

    /**
     * displays a edit contact screen and update the given FunAddressList after
     * the edit.
     *
     *
     * @param displayable: the displayable to be pushed in the stack
     * contact: the contact to be edited
     * contactList: the adddresslist to be updated (can be null if not needed)
     */
    public static Displayable showEditContactScreen(Displayable displayable,
            Contact contact, ContactList contactList, boolean isNew) {
        backStack.push(displayable);
        Displayable contactForm = new AddContactForm(contact, contactList, isNew);
        UIController.display.setCurrent(contactForm);
        return contactForm;
    }

    /**
     * Show an info alert with autodismiss
     */
    public static void showAlert(String message) {
        showAlert(message, AlertType.INFO, true);
    }

    /**
     * Show an info alert with autodismiss and a displayable
     * to open after it's been dismissed.
     */
    public static void showAlert(String message, Displayable displayable) {
        showAlert(message, AlertType.INFO, true, displayable);

    }

    /**
     * Show an error alert without autodismiss
     */
    public static void showErrorAlert(String message) {
        showAlert(message, AlertType.ERROR, false);
    }

    /**
     * Show an error alert with details command for longer message
     */
    public static void showErrorDetailedAlert(String message, String longMessage) {
        FunambolAlert messageAlert = getFunambolDetailedAlert(message, longMessage, AlertType.ERROR, false);
        if (!messageAlert.isShown) {
            messageAlert.isShown = true;
            display.setCurrent(messageAlert);
        }
    }

    /**
     * Show an info alert without autodismiss
     */
    public static void showInfoAlert(String message) {
        showAlert(message, AlertType.INFO, false);
    }

    /**
     * Show an error alert without autodismiss and a displayable
     * to open after it's been dismissed.
     */
    public static void showErrorAlert(String message, Displayable displayable) {
        showAlert(message, AlertType.ERROR, false, displayable);
    }

    /**
     * Show an alert with given message, alert type and autodismiss.
     * This is the generic method called by the others.
     */
    private static void showAlert(String message, AlertType alertType, boolean autoDismiss) {
        FunambolAlert messageAlert = getFunambolAlert(message, alertType, autoDismiss);
        if (!messageAlert.isShown) {
            messageAlert.isShown = true;
            display.setCurrent(messageAlert);
        }
    }

    /**
     * Show an alert with given message, alert type, autodismiss and next displayable
     */
    public static void showAlert(String message, AlertType alertType,
            boolean autoDismiss, Displayable displayable) {
        // needs final Alert for different managing  of alert
        // for issue in some Nokia devices like 6600
        final FunambolAlert messageAlert = getFunambolAlert(message, alertType, autoDismiss);
        messageAlert.setNextScreen(displayable);
        if (!messageAlert.isShown) {
            messageAlert.isShown = true;
            //#ifndef JVMAlertDismiss
            display.setCurrent(messageAlert);
        //#else
        //#  //Solution manage alert for known issue in Nokia 6600
        //#  display.setCurrent(displayable);
        //#  display.callSerially(new Runnable() { public void run() {display.setCurrent(messageAlert);} });
        //#endif
        }
    }

    /**
     * Show a modal alert. The method does not return until the user closes the
     * alert.
     *
     * @param message the message to display
     */
    public static void showModalAlert(String message) {
        FunambolAlert messageAlert = getFunambolAlert(message, AlertType.INFO, false);
        messageAlert.showModal(display);
    }

    public static void showAbout(Displayable displayable) {
        backStack.push(displayable);
        //display.setCurrent(new AboutForm());
        display.setCurrent(new AboutScreen());
    }

    public static void showHelp(Displayable displayable) {
        backStack.push(displayable);
        HelpScreen helpScreen = new HelpScreen(midlet);
        display.setCurrent(helpScreen);
    }

    public static void showHelpSection(Displayable displayable,
            Displayable sectionView) {
        backStack.push(displayable);
        display.setCurrent(sectionView);
    }

    /**
     * Utilites methods managing the Model
     */
    public static void replyMessage(Message message) {
        Message replyMessage = new Message();
        //TODO: exception handling
        try {
            replyMessage.setTo(message.getReplyTo());
            replyMessage.setSubject(RE + message.getSubject());
        } catch (MailException ex) {
            ex.printStackTrace();
            Log.error("unable to set content into reply " +
                    "message, error getting 'from' field from message");
        }
        setDelayedFlag(message, MessageFlags.ANSWERED);
        updateComposeMessageScreen(replyMessage, getReplyText(message));
        // getContactList().emptySearchString();
        showComposeMessageScreen(display.getCurrent(), getComposeMessageScreen().body);
    }

    /**
     * Put the application in background. This method does not work for any
     * device.
     */
    public static void background() {
        // This works only on some devices. Shall we use ifdefs?
        backStack.clear();
        display.setCurrent(null);
    }

    /**
     * set the message as the original message in composemessagescreen, the next
     * time the send / sendlater commandaction is performed the given flag will
     * be set to true
     *
     * @param message the message to be set as the original message in
     * composemessageform
     *
     * @param flag the flag (one of MessageFlags constants) to be set to true
     */
    private static void setDelayedFlag(final Message message, final int flag) {
        //Log.debug("UIController: trying to set read message flag");
        //setRepliedFlag(message);
        MessageFlags flags = new MessageFlags();
        flags.setFlags(message.getFlags().getFlags());
        if (!flags.isSet(flag)) {
            Log.debug("[UIController.setDelayedFlag] Delayed flag added");
            //>>>>FIXME: Transfer on ComposeMessageForm
            getComposeMessageScreen().setMessageFlag(flag);
            //messageManager.getInstance().updateMessageFlag(message, flag, true);
            try {
                Log.debug("message: " + message);
                getComposeMessageScreen().setOriginalMessage(message);
            } catch (MailException ex) {
                Log.error("error forwarding message while creating messageinfo " +
                        "from original message");
                ex.printStackTrace();
            }
        }
    }

    /*private static void delayedFlag(final Message message, final int flag) {
    //Log.debug("UIController: trying to set read message flag");
    //setRepliedFlag(message);
    MessageFlags flags = new MessageFlags();
    flags.setFlags(message.getFlags().getFlags());
    if (!flags.isSet(flag)) {
    flags.setFlag(flag, true);
    getComposeMessageScreen().setFlagsToSet(flags);
    try {
    getComposeMessageScreen().setOriginalMessage(message);
    } catch (MailException ex) {
    Log.error("error forwarding message while creating messageinfo " +
    "from original message");
    ex.printStackTrace();
    }
    }
    }*/
    /**
     * create a new forward message and show the compose message screen
     *
     * @param message the message to be forwarded (body content will be appended
     * at the bottom of the email)
     */
    public static void forwardMessage(Message message) {

        Message forwardMessage = new Message();

        forwardMessage.setSubject(FW + message.getSubject());
        setDelayedFlag(message, MessageFlags.FORWARDED);
        UIController.updateComposeMessageScreen(forwardMessage, getForwardText(message));
        // getContactList().emptySearchString();
        showComposeMessageScreen(display.getCurrent(), getComposeMessageScreen().recipientStringItem);
    /*  getContactList().setMessage(forwardMessage);
    getContactList().emptySearchString();
    getContactList().SortAlphabetically();
    showContactList(display.getCurrent()); */

    }
    /*
    public static void forwardMessage(Message message) {
    Message forwardMessage = new Message();
    forwardMessage.setSubject(FW + message.getSubject());
    delayedFlag(message, MessageFlags.FORWARDED);
    updateComposeMessageScreen(forwardMessage, getForwardText(message));
    // getContactList().emptySearchString();
    showComposeMessageScreen(display.getCurrent(), getComposeMessageScreen().recipientStringItem);
    }*/

    /**
     * update the message list that contain the given message
     *
     * @param message the message
     */
    private static void updateMessageList(Message message) {
        if (message.getParent() == null) {
            //updateAllMessageLists(message);
            Log.error("Message without parent");
            return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -