at.spardat.xma.event.swt.XMAFocusAdapter Maven / Gradle / Ivy
The 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: XMAFocusAdapter.java 2605 2008-06-20 13:21:29Z gub $
*
*
*
*
*
*/
package at.spardat.xma.event.swt;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import at.spardat.xma.page.IDialogPage;
import at.spardat.xma.page.PageClient;
/**
* Event save adapter for focus listeners on SWT-widgets.
* It wraps event-disabling code of XMA around your event handling code.
* (see package description>)
*/
public class XMAFocusAdapter implements FocusListener {
PageClient page;
/**
* Constructor for this event adapter.
* @param page The page containing the widget on which you want to listen for events.
*/
public XMAFocusAdapter(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 has gained the focus.
* Overload this method and place your envent handling code here.
* @param event The event send by SWT.
*/
public void focusGainedImpl(FocusEvent event) {}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #focusGainedImpl(FocusEvent)}
* instead.
* @param event The event send by SWT.
*/
public final void focusGained(FocusEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
focusGainedImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
/**
* This method is called every time the corresponding widget has lost the focus.
* Overload this method and place your envent handling code here.
* @param event The event send by SWT.
*/
public void focusLostImpl(FocusEvent event) {}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #focusLostImpl(FocusEvent)}
* instead.
* @param event The event send by SWT.
*/
public final void focusLost(FocusEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
focusLostImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
}