javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/CommandUtils.java
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:10:53 +0300
changeset 79 2f468c1958d0
parent 21 2a9601315dfc
permissions -rw-r--r--
Revision: v2.2.15 Kit: 201039

package org.eclipse.swt.internal.qt;

import org.eclipse.ercp.swt.mobile.Command;

public final class CommandUtils {

	public static final void sort(Command[] array) {
	    int length = array.length;
	    if (length <= 1)
	        return;

	    for (int gap = length / 2; gap > 0; gap /= 2) {
	        for (int i = gap; i < length; i++) {
	            for (int j = i - gap; j >= 0; j -= gap) {
	                if (array[j].getPriority() < array[j + gap].getPriority()) {
	                    Command swap = array[j];
	                    array[j] = array[j + gap];
	                    array[j + gap] = swap;
	                }
	            }
	        }
	    }
	}

    public  static final int getQtSoftKeyRole( int type){
        switch (type) {
        case Command.GENERAL:
        case Command.OK:
        case Command.HELP:
            return OS.QACTION_POSITIVESOFTKEY;
        case Command.CANCEL:
        case Command.DELETE:
        case Command.BACK:
        case Command.EXIT:
        case Command.STOP:
            return OS.QACTION_NEGATIVESOFTKEY;
        case Command.SELECT:
            return OS.QACTION_SELECTSOFTKEY;
        case Command.COMMANDGROUP:
        default:
            return OS.QACTION_NOSOFTKEY;
        }
    }

	public static final boolean isNegativeType(final int type){
		return getQtSoftKeyRole(type) == OS.QACTION_NEGATIVESOFTKEY;
    }

}