at.spardat.xma.event.swt.XMASelectionAdapter Maven / Gradle / Ivy
/*******************************************************************************
* 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: XMASelectionAdapter.java 2605 2008-06-20 13:21:29Z gub $
*
*
*
*
*
*/
package at.spardat.xma.event.swt;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import at.spardat.xma.page.IDialogPage;
import at.spardat.xma.page.PageClient;
/**
* Event save adapter for selection listeners on SWT-widgets not supported by GuiDesigner,
* like SWT-Menues, Toolbar-Items, etc. It wraps event-disabling code of XMA around your
* event handling code. (see package description>)
*/
public class XMASelectionAdapter implements SelectionListener {
PageClient page;
/**
* Constructor for this event adapter.
* @param page The page containing the widget on which you want to listen for events.
*/
public XMASelectionAdapter(PageClient page) {
this.page=page;
}
/**
* Returns the page passed to the contructor
*/
public PageClient getPage() {
return page;
}
/**
* This method is called every time the corresponding widget is selected.
* Overload this method and place your envent handling code here.
* @param event The event send by SWT.
*/
public void widgetSelectedImpl(SelectionEvent event) {}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #widgetSelectedImpl(SelectionEvent)}
* instead.
* @param event The event send by SWT.
*/
public final void widgetSelected(SelectionEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
widgetSelectedImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
/**
* This method is called every time the corresponding widget is doubleclicked.
* Overload this method and place your envent handling code here.
* @param event The event send by SWT.
*/
public void widgetDefaultSelectedImpl(SelectionEvent event) {}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #widgetDefaultSelectedImpl(SelectionEvent)}
* instead.
* @param event The event send by SWT.
*/
public final void widgetDefaultSelected(SelectionEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
widgetDefaultSelectedImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
}