All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.event.swt.XMAMouseAdapter Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * 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:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * @(#) $Id: XMAMouseAdapter.java 2605 2008-06-20 13:21:29Z gub $
 *
 *
 *
 *
 *
 */
package at.spardat.xma.event.swt;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

import at.spardat.xma.page.IDialogPage;
import at.spardat.xma.page.PageClient;

/**
 * Event save adapter for mouse listeners on SWT-widgets.
 * It wraps event-disabling code of XMA around your event handling code.
 * (see package description)
 */
public class XMAMouseAdapter implements MouseListener {
    PageClient page;

    /**
     * Constructor for this event adapter.
     * @param page The page containing the widget on which you want to listen for events.
     */
    public XMAMouseAdapter(PageClient page) {
        this.page=page;
    }

    /**
     * Returns the page passed to the contructor
     */
    public PageClient getPage() {
        return page;
    }

   /**
     * This method is called every time the mouse button is doubleclicked.
     * Overload this method and place your envent handling code here.
     * @param event The event send by SWT.
     */
    public void mouseDoubleClickImpl(MouseEvent event) {}

    /**
     * The method called by SWT whenever the corresponding event happends.
     * To not overload this method, overload {@link #mouseDoubleClickImpl(MouseEvent)}
     * instead.
     * @param event The event send by SWT.
     */
    public final void mouseDoubleClick(MouseEvent event) {
        if(!page.isEventsEnabled()) return;
        IDialogPage dialog = page.getDialogPage();
        try {
            dialog.setEventsEnabled(false);
            mouseDoubleClickImpl(event);
        } catch (Exception exc) {
            page.showException(exc);
        } finally {
            dialog.setEventsEnabled(true);
        }
    }

    /**
     * This method is called every time the mouse button is pressed down.
     * Overload this method and place your envent handling code here.
     * @param event The event send by SWT.
     */
    public void mouseDownImpl(MouseEvent event) {}

    /**
     * The method called by SWT whenever the corresponding event happends.
     * To not overload this method, overload {@link #mouseDownImpl(MouseEvent)}
     * instead.
     * @param event The event send by SWT.
     */
    public final void mouseDown(MouseEvent event) {
        if(!page.isEventsEnabled()) return;
        IDialogPage dialog = page.getDialogPage();
        try {
            dialog.setEventsEnabled(false);
            mouseDownImpl(event);
        } catch (Exception exc) {
            page.showException(exc);
        } finally {
            dialog.setEventsEnabled(true);
        }
    }

    /**
     * This method is called every time the mouse button is released.
     * Overload this method and place your envent handling code here.
     * @param event The event send by SWT.
     */
    public void mouseUpImpl(MouseEvent event) {}

    /**
     * The method called by SWT whenever the corresponding event happends.
     * To not overload this method, overload {@link #mouseUpImpl(MouseEvent)}
     * instead.
     * @param event The event send by SWT.
     */
    public final void mouseUp(MouseEvent event) {
        if(!page.isEventsEnabled()) return;
        IDialogPage dialog = page.getDialogPage();
        try {
            dialog.setEventsEnabled(false);
            mouseUpImpl(event);
        } catch (Exception exc) {
            page.showException(exc);
        } finally {
            dialog.setEventsEnabled(true);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy