예제 #1
0
 @Override
 protected void doProcessMetaDataChange(MenuButtonModel widget, MetaData metaData) {
   if (metaData != null) {
     switch (metaData.getAccessType()) {
       case NONE:
         widget.setPropertyValue(
             AbstractWidgetModel.PROP_CURSOR,
             CursorService.getInstance().availableCursors().get(7));
         break;
       case READ:
         widget.setPropertyValue(
             AbstractWidgetModel.PROP_CURSOR,
             CursorService.getInstance().availableCursors().get(7));
         break;
       case READ_WRITE:
         widget.setPropertyValue(
             AbstractWidgetModel.PROP_CURSOR,
             CursorService.getInstance().availableCursors().get(0));
         break;
       case WRITE:
         widget.setPropertyValue(
             AbstractWidgetModel.PROP_CURSOR,
             CursorService.getInstance().availableCursors().get(0));
         break;
       default:
         widget.setPropertyValue(
             AbstractWidgetModel.PROP_CURSOR,
             CursorService.getInstance().availableCursors().get(0));
     }
   }
 }
예제 #2
0
  /**
   * Tries to find a cursor for the specified id.
   *
   * @param cursorId the cursor id
   * @return a cursor or null if none was found
   */
  public static Cursor getCursor(String cursorId) {
    // find the descriptor for the specified cursor id
    AbstractCursor d = CursorService.getInstance().findCursor(cursorId);

    Cursor cursor = null;

    if (d != null) {
      if (d == ICursorService.SYSTEM_DEFAULT_CURSOR) {
        cursor = null;
      } else if (d instanceof SWTCursor) {
        cursor = new Cursor(Display.getCurrent(), ((SWTCursor) d).getSWTCursor());
      } else if (d instanceof ContributedCursor) {
        ContributedCursor cc = (ContributedCursor) d;
        ImageData imageData =
            ImageUtil.getInstance().getImage(cc.getBundle(), cc.getImage()).getImageData();
        cursor = new Cursor(Display.getCurrent(), imageData, 1, 1);
      } else if (d instanceof WorkspaceCursor) {
        WorkspaceCursor wc = (WorkspaceCursor) d;
        ImageData imageData =
            ImageUtil.getInstance().getImageDescriptorFromFile(wc.getGraphicsFile()).getImageData();
        cursor = new Cursor(Display.getCurrent(), imageData, 1, 1);
      } else {
        LOG.warn("Unknown cursor type: " + d.getClass());
        cursor = null;
      }
    }

    return cursor;
  }