javauis/nokiauiapi_qt/javasrc_j2me/com/nokia/mid/ui/TactileFeedback.java
changeset 87 1627c337e51e
parent 78 71ad690e91f5
equal deleted inserted replaced
80:d6dafc5d983f 87:1627c337e51e
    98      * Constant for specifying sensitive tactile feedback style. Actual style
    98      * Constant for specifying sensitive tactile feedback style. Actual style
    99      * behaviour is set through device settings.
    99      * behaviour is set through device settings.
   100      */
   100      */
   101     public static final int FEEDBACK_STYLE_SENSITIVE = 2;
   101     public static final int FEEDBACK_STYLE_SENSITIVE = 2;
   102 
   102 
   103     private final String invalidFeedbackStyleMsg = "Invalid feedback style specified";
   103     private static final String MSG_INVALID_FEEDBACK_STYLE = "Invalid feedback style specified";
   104     private final String invalidControlTypeMsg = "Invalid object provided for tactile feedback registration";
   104     private static final String MSG_INVALID_OBJECT_TYPE = "Invalid object provided for tactile feedback registration";
   105 
   105 
   106     private static final int TYPE_INVALID = 0;
   106     private static final int TYPE_INVALID = 0;
   107     private static final int TYPE_ESWT = 1;
   107     private static final int TYPE_ESWT = 1;
   108     private static final int TYPE_LCDUI = 2;
   108     private static final int TYPE_LCDUI = 2;
   109     private static boolean feedbackEnabled;
   109     private volatile boolean feedbackEnabled;
   110 
   110 
   111     /**
   111     /**
   112      * Constructs tactile feedback engine object. The object may be used in both
   112      * Constructs tactile feedback engine object. The object may be used in both
   113      * LCDUI and eSWT java UI toolkits. TactileFeedback object must be
   113      * LCDUI and eSWT java UI toolkits. TactileFeedback object must be
   114      * constructed before using any tactile feedback methods.
   114      * constructed before using any tactile feedback methods.
   129      */
   129      */
   130     public void directFeedback(int style) throws IllegalArgumentException
   130     public void directFeedback(int style) throws IllegalArgumentException
   131     {
   131     {
   132         if ((style != FEEDBACK_STYLE_BASIC)
   132         if ((style != FEEDBACK_STYLE_BASIC)
   133                 && (style != FEEDBACK_STYLE_SENSITIVE))
   133                 && (style != FEEDBACK_STYLE_SENSITIVE))
   134             throw new IllegalArgumentException(invalidFeedbackStyleMsg);
   134             throw new IllegalArgumentException(MSG_INVALID_FEEDBACK_STYLE);
   135         if (org.eclipse.swt.widgets.Display.getCurrent() == null)
   135         if (org.eclipse.swt.widgets.Display.getCurrent() == null)
   136         {
   136         {
   137             final int fStyle = style;
   137             final int fStyle = style;
   138             com.nokia.mj.impl.nokialcdui.LCDUIInvoker
   138             com.nokia.mj.impl.nokialcdui.LCDUIInvoker
   139             .eSWTUIThreadRunnerSyncExec(new Runnable()
   139             .eSWTUIThreadRunnerSyncExec(new Runnable()
   239     public void registerFeedbackArea(Object uiObject, int id, int x, int y,
   239     public void registerFeedbackArea(Object uiObject, int id, int x, int y,
   240                                      int width, int height, int style) throws IllegalArgumentException
   240                                      int width, int height, int style) throws IllegalArgumentException
   241     {
   241     {
   242         int type = controlType(uiObject);
   242         int type = controlType(uiObject);
   243         if (type == TYPE_INVALID)
   243         if (type == TYPE_INVALID)
   244             throw new IllegalArgumentException(invalidControlTypeMsg);
   244             throw new IllegalArgumentException(MSG_INVALID_OBJECT_TYPE);
   245 
   245 
   246         if ((style != FEEDBACK_STYLE_BASIC)
   246         if ((style != FEEDBACK_STYLE_BASIC)
   247                 && (style != FEEDBACK_STYLE_SENSITIVE))
   247                 && (style != FEEDBACK_STYLE_SENSITIVE))
   248             throw new IllegalArgumentException(invalidFeedbackStyleMsg);
   248             throw new IllegalArgumentException(MSG_INVALID_FEEDBACK_STYLE);
   249 
   249 
   250         int controlHandle = getControlHandle(uiObject);
   250         int controlHandle = getControlHandle(uiObject);
   251         if (type == TYPE_LCDUI)
   251         if (type == TYPE_LCDUI)
   252         {
   252         {
   253             final int fControlHandle = controlHandle;
   253             final int fControlHandle = controlHandle;
   297     throws IllegalArgumentException
   297     throws IllegalArgumentException
   298     {
   298     {
   299 
   299 
   300         int type = controlType(uiObject);
   300         int type = controlType(uiObject);
   301         if (type == TYPE_INVALID)
   301         if (type == TYPE_INVALID)
   302             throw new IllegalArgumentException(invalidControlTypeMsg);
   302             throw new IllegalArgumentException(MSG_INVALID_OBJECT_TYPE);
   303 
   303 
   304         int controlHandle = getControlHandle(uiObject);
   304         int controlHandle = getControlHandle(uiObject);
   305         if (type == TYPE_LCDUI)
   305         if (type == TYPE_LCDUI)
   306         {
   306         {
   307             final int fControlHandle = controlHandle;
   307             final int fControlHandle = controlHandle;
   341         if (isTouchFeedbackSupported() == false)
   341         if (isTouchFeedbackSupported() == false)
   342             return;
   342             return;
   343 
   343 
   344         int type = controlType(uiObject);
   344         int type = controlType(uiObject);
   345         if (type == TYPE_INVALID)
   345         if (type == TYPE_INVALID)
   346             throw new IllegalArgumentException(invalidControlTypeMsg);
   346             throw new IllegalArgumentException(MSG_INVALID_OBJECT_TYPE);
   347 
   347 
   348         int controlHandle = getControlHandle(uiObject);
   348         int controlHandle = getControlHandle(uiObject);
   349 
   349 
   350         if (type == TYPE_LCDUI)
   350         if (type == TYPE_LCDUI)
   351         {
   351         {
   393         if (isTouchFeedbackSupported() == false)
   393         if (isTouchFeedbackSupported() == false)
   394             return;
   394             return;
   395 
   395 
   396         int type = controlType(uiObject);
   396         int type = controlType(uiObject);
   397         if (type == TYPE_INVALID)
   397         if (type == TYPE_INVALID)
   398             throw new IllegalArgumentException(invalidControlTypeMsg);
   398             throw new IllegalArgumentException(MSG_INVALID_OBJECT_TYPE);
   399 
   399 
   400         int controlHandle = getControlHandle(uiObject);
   400         int controlHandle = getControlHandle(uiObject);
   401         if (type == TYPE_LCDUI)
   401         if (type == TYPE_LCDUI)
   402         {
   402         {
   403             final int fControlHandle = controlHandle;
   403             final int fControlHandle = controlHandle;