com.architexa.org.eclipse.gef.SharedCursors.java Source code

Java tutorial

Introduction

Here is the source code for com.architexa.org.eclipse.gef.SharedCursors.java

Source

/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.architexa.org.eclipse.gef;

import com.architexa.org.eclipse.draw2d.Cursors;
import com.architexa.org.eclipse.gef.internal.Internal;

import org.eclipse.swt.graphics.Cursor;

import org.eclipse.jface.resource.ImageDescriptor;

/**
 * A shared collection of Cursors.
 * @since 2.0
 */
public class SharedCursors extends Cursors {

    /**
     * Cursor for valid connection
     */
    public static final Cursor CURSOR_PLUG;
    /**
     * Cursor for invalid connection
     */
    public static final Cursor CURSOR_PLUG_NOT;
    /**
     * Cursor for adding to a tree
     */
    public static final Cursor CURSOR_TREE_ADD;
    /**
     * Cursor for dragging in a tree
     */
    public static final Cursor CURSOR_TREE_MOVE;

    static {
        CURSOR_PLUG = createCursor("icons/plugmask.gif", //$NON-NLS-1$
                "icons/plug.bmp"); //$NON-NLS-1$
        CURSOR_PLUG_NOT = createCursor("icons/plugmasknot.gif", //$NON-NLS-1$
                "icons/plugnot.bmp"); //$NON-NLS-1$
        CURSOR_TREE_ADD = createCursor("icons/Tree_Add_Mask.gif", //$NON-NLS-1$
                "icons/Tree_Add.gif"); //$NON-NLS-1$
        CURSOR_TREE_MOVE = createCursor("icons/Tree_Move_Mask.gif", //$NON-NLS-1$
                "icons/Tree_Move.gif"); //$NON-NLS-1$
    }

    private static Cursor createCursor(String sourceName, String maskName) {
        ImageDescriptor src = ImageDescriptor.createFromFile(Internal.class, sourceName);
        ImageDescriptor mask = ImageDescriptor.createFromFile(Internal.class, maskName);
        return new Cursor(null, src.getImageData(), mask.getImageData(), 0, 0);
    }

}