当前位置: 首页>>代码示例>>Java>>正文


Java Command.putClientProperty方法代码示例

本文整理汇总了Java中com.codename1.ui.Command.putClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Command.putClientProperty方法的具体用法?Java Command.putClientProperty怎么用?Java Command.putClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.codename1.ui.Command的用法示例。


在下文中一共展示了Command.putClientProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFormCommand

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void addFormCommand(Form f)
{
    Image icon = StateMachine.getResourceFile().getImage("player_player_icon.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("player_player_icon_active.png");
    iconPressed.lock();
    Command titleCmd = new Command(null, icon) {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createFade(200));
            ui.back();
        }
    };

    titleCmd.setPressedIcon(iconPressed);
    titleCmd.putClientProperty("TitleCommand", Boolean.TRUE);

    f.addCommand(titleCmd);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:20,代码来源:QueueView.java

示例2: buildCommand

import com.codename1.ui.Command; //导入方法依赖的package包/类
private Command buildCommand(String text, String iconKey, final String formName, final Runnable runnable)
{
    Command cmd = new Command(text, StateMachine.getResourceFile().getImage(iconKey)) {
        @Override
        public void actionPerformed(ActionEvent evt) {
            SideMenuBar.closeCurrentMenu(new Runnable() {
                @Override
                public void run() {
                    if(formName == null || (Display.getInstance().getCurrent() != null && !formName.equals(Display.getInstance().getCurrent().getName())))
                    {
                        Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createEmpty());
                        runnable.run();
                    }
                }
            });
        }
    };

    cmd.putClientProperty("uiid", "NavigationButton");
    cmd.putClientProperty("iconGap", 20);

    return cmd;
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:24,代码来源:SideMenu.java

示例3: addPlaylistEdit

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void addPlaylistEdit(final Form f)
{
    //TODO: Enabled this again when Shai has fixed deleting titlecommands
    //if(titleCommand != null)
    //    f.removeCommand(titleCommand);
    
    ui.removeTitleCommand(f);
    
    // Add command to change playlist-name
    Image icon = StateMachine.getResourceFile().getImage("playlist_edit_static.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_edit_active.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            
            addPlaylistCancel(f);
            
            onEditPlaylistTitle(f);
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:27,代码来源:PlaylistView.java

示例4: addPlaylistCancel

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void addPlaylistCancel(final Form f)
{
    //f.removeCommand(titleCommand);
    ui.removeTitleCommand(f);
    
    
    // Add command to change playlist-name
    Image icon = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistEdit(f);
            hideTopbarEditing(f);
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:23,代码来源:PlaylistView.java

示例5: addPlaylistAdd

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void addPlaylistAdd(final Form f)
{
    //TODO: Enabled this again when Shai has fixed deleting titlecommands
    //if(titleCommand != null)
    //   f.removeCommand(titleCommand);
    
    ui.removeTitleCommand(f);
    
    Image icon = StateMachine.getResourceFile().getImage("playlist_plus_static.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_plus_active.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistCancel(f);
            ui.resetComponentHeight(ui.findCtnAddPlaylistForm(f));
            ui.findTfdAddPlaylistFormTitle(f).requestFocus();
            Display.getInstance().editString(ui.findTfdAddPlaylistFormTitle(f), 200, TextField.ANY, "");
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:26,代码来源:PlaylistOverviewView.java

示例6: addPlaylistCancel

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void addPlaylistCancel(final Form f)
{
    ui.removeTitleCommand(f);
    
    Image icon = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_cancel.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistAdd(f);
            ui.hideComponent(ui.findCtnAddPlaylistForm(f));
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:20,代码来源:PlaylistOverviewView.java

示例7: initBackForm

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void initBackForm(Form f) {
    Vector formNavigationStack = baseFormNavigationStack;
    if(formNavigationStack != null && formNavigationStack.size() > 0) {
        setFormState(f, (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1));
        formNavigationStack.removeElementAt(formNavigationStack.size() - 1);
        if(formNavigationStack.size() > 0) {
            Hashtable previous = (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1);
            String commandAction = (String)previous.get(FORM_STATE_KEY_NAME);
            Command backCommand = createCommandImpl(getBackCommandText((String)previous.get(FORM_STATE_KEY_TITLE)), null,
                    BACK_COMMAND_ID, commandAction, true, "");
            setBackCommand(f, backCommand);
            
            // trigger listener creation if this is the only command in the form
            getFormListenerInstance(f, null);

            backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
            backCommand.putClientProperty(COMMAND_ACTION, commandAction);
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:UIBuilder.java

示例8: createBackLazyValue

import com.codename1.ui.Command; //导入方法依赖的package包/类
/**
 * This is useful for swipe back navigation behavior
 * @param f the form from which we should go back
 * @return a lazy value that will return the back form
 */
public LazyValue<Form> createBackLazyValue(final Form f) {
    Vector formNavigationStack = baseFormNavigationStack;
    Hashtable p = null;
    Command cmd = null;
    if(formNavigationStack.size() > 1) {
        p = (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 2);
        String backTitle = getBackCommandText((String)p.get(FORM_STATE_KEY_TITLE));
        String commandAction = (String)p.get(FORM_STATE_KEY_NAME);
        cmd = createCommandImpl(backTitle, null,
                BACK_COMMAND_ID, commandAction, true, "");
        cmd.putClientProperty(COMMAND_ARGUMENTS, "");
        cmd.putClientProperty(COMMAND_ACTION, commandAction);
    }

    return new LazyValueC(f, p, cmd, this);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:UIBuilder.java

示例9: buildMenuCommand

import com.codename1.ui.Command; //导入方法依赖的package包/类
private Command buildMenuCommand(String title, String icon, ActionListener listener)
{
    Button l = new Button(title);

    //Image iconImage = StateMachine.getResourceFile().getImage(icon);
    //iconImage.lock();
    //l.setIcon(iconImage);
    l.setGap(20);
    //l.setUIID("NavigationButton");
    l.addActionListener(listener);

    Command c = new Command(title);
    c.putClientProperty("SideComponent", l);

    return c;
}
 
开发者ID:martijn00,项目名称:Zipato,代码行数:17,代码来源:SideMenuView.java

示例10: readObjectArrayForListModel

import com.codename1.ui.Command; //导入方法依赖的package包/类
private Object[] readObjectArrayForListModel(DataInputStream in, Resources res) throws IOException {
    Object[] elements = new Object[in.readInt()];
    int elen = elements.length;
    for(int iter = 0 ; iter < elen ; iter++) {
        switch(in.readByte()) {
            case 1: // String
                elements[iter] = in.readUTF();
                break;
            case 2: // hashtable of Strings
                int hashSize = in.readInt();
                Hashtable val = new Hashtable();
                elements[iter] = val;
                for(int i = 0 ; i < hashSize ; i++) {
                    int type = in.readInt();
                    if(type == 1) { // String
                        String key = in.readUTF();
                        Object value = in.readUTF();
                        if(key.equals("$navigation")) {
                            Command cmd = createCommandImpl((String)value, null, -1, (String)value, false, "");
                            cmd.putClientProperty(COMMAND_ACTION, (String)value);
                            value = cmd;
                        }
                        val.put(key, value);
                    } else {
                        val.put(in.readUTF(), res.getImage(in.readUTF()));
                    }
                }
                break;
        }
    }
    return elements;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:33,代码来源:UIBuilder.java

示例11: initBackContainer

import com.codename1.ui.Command; //导入方法依赖的package包/类
private void initBackContainer(Container cnt, Form destForm, Vector formNavigationStack) {
    setContainerState(cnt, (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1));
    formNavigationStack.removeElementAt(formNavigationStack.size() - 1);
    if(formNavigationStack.size() > 0) {
        Hashtable previous = (Hashtable)formNavigationStack.elementAt(formNavigationStack.size() - 1);
        String commandAction = (String)previous.get(FORM_STATE_KEY_NAME);
        Command backCommand = createCommandImpl(getBackCommandText((String)previous.get(FORM_STATE_KEY_TITLE)), null,
                BACK_COMMAND_ID, commandAction, true, "");
        setBackCommand(destForm, backCommand);
        backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
        backCommand.putClientProperty(COMMAND_ACTION, commandAction);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:14,代码来源:UIBuilder.java

示例12: readObjectArrayForListModel

import com.codename1.ui.Command; //导入方法依赖的package包/类
private Object[] readObjectArrayForListModel(DataInputStream in, Resources res) throws IOException {
    Object[] elements = new Object[in.readInt()];
    for(int iter = 0 ; iter < elements.length ; iter++) {
        switch(in.readByte()) {
            case 1: // String
                elements[iter] = in.readUTF();
                break;
            case 2: // hashtable of Strings
                int hashSize = in.readInt();
                Hashtable val = new Hashtable();
                elements[iter] = val;
                for(int i = 0 ; i < hashSize ; i++) {
                    int type = in.readInt();
                    if(type == 1) { // String
                        String key = in.readUTF();
                        Object value = in.readUTF();
                        if(key.equals("$navigation")) {
                            Command cmd = createCommandImpl((String)value, null, -1, (String)value, false, "");
                            cmd.putClientProperty(COMMAND_ACTION, (String)value);
                            value = cmd;
                        }
                        val.put(key, value);
                    } else {
                        val.put(in.readUTF(), res.getImage(in.readUTF()));
                    }
                }
                break;
        }
    }
    return elements;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:UIBuilder.java

示例13: onOptionsItemSelected

import com.codename1.ui.Command; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    final Form currentForm = Display.getInstance().getCurrent();
    if (currentForm == null) {
        return false;
    }
    Command cmd = null;
    final boolean[] tmpProp = new boolean[1];
    if (item.getItemId() == android.R.id.home) {
        cmd = currentForm.getBackCommand();
        if (cmd == null) {
            return false;
        }
        cmd.putClientProperty("source", "ActionBar");
        tmpProp[0] = true;
    }

    int commandIndex = item.getItemId();
    if (cmd == null) {
        cmd = currentForm.getCommand(commandIndex);
    }
    final Command command = cmd;
    final ActionEvent actionEvent = new ActionEvent(command);

    //stop edit if the keybaord is open
    AndroidImplementation.stopEditing();
    // Protect ourselves from commands that misbehave. A crash here will crash the entire application
    Display.getInstance().callSerially(new Runnable() {
        @Override
        public void run() {
            try {
                currentForm.dispatchCommand(command, actionEvent);
                //remove the temp source property
                if (tmpProp[0]) {
                    command.putClientProperty("source", null);
                }
            } catch (Throwable e) {
                Log.e("CodenameOneActivity.onOptionsItemSelected", e.toString() + Log.getStackTraceString(e));
            }
        }
    });

    return true;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:47,代码来源:CodenameOneActivity.java

示例14: createForm

import com.codename1.ui.Command; //导入方法依赖的package包/类
Form createForm(Form f) {
    Form currentForm = Display.getInstance().getCurrent();
    if(currentForm != null && currentForm instanceof Dialog) {
        ((Dialog)Display.getInstance().getCurrent()).dispose();
        currentForm = Display.getInstance().getCurrent();
    }
    Vector formNavigationStack = baseFormNavigationStack;
    if(formNavigationStack != null && !(f instanceof Dialog) && !f.getName().equals(homeForm)) {
        if(currentForm != null) {
            String nextForm = (String)f.getClientProperty("%next_form%");

            // we are in the sidemenu view we should really be using the parent form
            SideMenuBar b = (SideMenuBar)currentForm.getClientProperty("cn1$sideMenuParent");
            if(b != null) {
                currentForm = b.getParentForm();
            }

            // don't add back commands to transitional forms
            if(nextForm == null) {
                String commandAction = currentForm.getName();
                if(allowBackTo(commandAction) && f.getBackCommand() == null) {
                    Command backCommand;
                    if(isSameBackDestination(currentForm, f)) {
                        backCommand = currentForm.getBackCommand();
                    } else {
                        backCommand = createCommandImpl(getBackCommandText(currentForm.getTitle()), null,
                            BACK_COMMAND_ID, commandAction, true, "");
                        backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
                        backCommand.putClientProperty(COMMAND_ACTION, commandAction);
                    }
                    if(backCommand != null) {
                        setBackCommand(f, backCommand);
                    }

                    // trigger listener creation if this is the only command in the form
                    getFormListenerInstance(f, null);
                    formNavigationStack.addElement(getFormState(currentForm));
                }
            }
        }
    }
    return f;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:44,代码来源:UIBuilder.java

示例15: onOptionsItemSelected

import com.codename1.ui.Command; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    final Form currentForm = Display.getInstance().getCurrent();
    if (currentForm == null) {
        return false;
    }
    Command cmd = null;
    final boolean [] tmpProp = new boolean[1];
    if(item.getItemId() == android.R.id.home){
        cmd = currentForm.getBackCommand();
        if(cmd == null){
            return false;
        }
        cmd.putClientProperty("source", "ActionBar");
        tmpProp[0] = true;
    }
    
    int commandIndex = item.getItemId();
    if(cmd == null){
        cmd = currentForm.getCommand(commandIndex);
    }
    final Command command = cmd;
    final ActionEvent actionEvent = new ActionEvent(command);

    //stop edit if the keybaord is open
    AndroidImplementation.stopEditing();
    // Protect ourselves from commands that misbehave. A crash here will crash the entire application
    Display.getInstance().callSerially(new Runnable() {
        @Override
        public void run() {
            try {
                currentForm.dispatchCommand(command, actionEvent);
                //remove the temp source property
                if(tmpProp[0]){
                    command.putClientProperty("source", null);
                }
            } catch (Throwable e) {
                Log.e("CodenameOneActivity.onOptionsItemSelected", e.toString() + Log.getStackTraceString(e));
            }
        }
    });

    return true;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:CodenameOneActivity.java


注:本文中的com.codename1.ui.Command.putClientProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。