diff options
Diffstat (limited to 'trunk/pdf-over-gui/src/main')
3 files changed, 184 insertions, 37 deletions
| diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java index 77bddf54..e1ec4990 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java @@ -17,6 +17,7 @@ package at.asit.pdfover.gui.composites;  // Imports  import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseListener;  import org.eclipse.swt.events.SelectionAdapter;  import org.eclipse.swt.events.SelectionEvent;  import org.eclipse.swt.graphics.Font; @@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory;  import at.asit.pdfover.gui.Constants;  import at.asit.pdfover.gui.Messages; +import at.asit.pdfover.gui.controls.ClickableCanvas;  import at.asit.pdfover.gui.workflow.states.State;  import at.asit.pdfover.signator.BKUs; @@ -121,61 +123,81 @@ public class BKUSelectionComposite extends StateComposite {  		this.setLayout(new FormLayout()); +		ClickableCanvas cc_mobile = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE); +		FormData fd_cc_mobile = new FormData(); +		fd_cc_mobile.right = new FormAttachment(50, -5); +		fd_cc_mobile.top = new FormAttachment(40, -20); +		cc_mobile.addMouseListener(new MouseListener() { +			 +			@Override +			public void mouseUp(org.eclipse.swt.events.MouseEvent e) { +				// Nothing to do here +			} +			 +			@Override +			public void mouseDown(org.eclipse.swt.events.MouseEvent e) { +				setSelected(BKUs.MOBILE); +			} +			 +			@Override +			public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { +				// Nothing to do here +			} +		}); +		cc_mobile.setLayoutData(fd_cc_mobile); -		Button btn_mobile = new Button(this, SWT.NATIVE | SWT.RESIZE); -		//btn_mobile.setText(Messages.getString("bku_selection.mobile")); //$NON-NLS-1$ -		//Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT); -		FormData fd_btn_mobile = new FormData(); -		//fd_btn_mobile.left = new FormAttachment(40, 0); -		fd_btn_mobile.right = new FormAttachment(50, -5); -		fd_btn_mobile.top = new FormAttachment(40, -20); -		//fd_btn_mobile.bottom = new FormAttachment(55, 0); -		btn_mobile.setLayoutData(fd_btn_mobile); -		btn_mobile.addSelectionListener(new MobileSelectionListener()); -  		Image mobile = new Image(getDisplay(), new ImageData(this.getClass().getResourceAsStream("/img/handy.gif"))); //$NON-NLS-1$ +		cc_mobile.setImage(mobile); +		FontData[] fD_cc_mobile = cc_mobile.getFont().getFontData(); +		fD_cc_mobile[0].setHeight(Constants.TEXT_SIZE_BUTTON); +		cc_mobile.setFont(new Font(Display.getCurrent(), fD_cc_mobile[0])); -		btn_mobile.setImage(mobile); -		 -		FontData[] fD_btn_mobile = btn_mobile.getFont().getFontData(); -		fD_btn_mobile[0].setHeight(Constants.TEXT_SIZE_BUTTON); -		btn_mobile.setFont(new Font(Display.getCurrent(), fD_btn_mobile[0])); -		 -		Button btn_card = new Button(this, SWT.NATIVE | SWT.RESIZE); -		//btn_card.setText(Messages.getString("bku_selection.card")); //$NON-NLS-1$ -		//Point card_size = btn_card.computeSize(SWT.DEFAULT, SWT.DEFAULT); -		FormData fd_btn_card = new FormData(); -		fd_btn_card.left = new FormAttachment(50, 5); -		//fd_btn_card.right = new FormAttachment(60, 0); -		fd_btn_card.top = new FormAttachment(40, -20); -		//fd_btn_card.bottom = new FormAttachment(55, 0); -		btn_card.setLayoutData(fd_btn_card); -		btn_card.addSelectionListener(new LocalSelectionListener()); -		 -		FontData[] fD_btn_card = btn_card.getFont().getFontData(); -		fD_btn_card[0].setHeight(Constants.TEXT_SIZE_BUTTON); -		btn_card.setFont(new Font(Display.getCurrent(), fD_btn_card[0])); +		ClickableCanvas cc_karte = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE); +		FormData fd_cc_karte = new FormData(); +		fd_cc_karte.left = new FormAttachment(50, 5); +		fd_cc_karte.top = new FormAttachment(40, -20); +		cc_karte.addMouseListener(new MouseListener() { +			 +			@Override +			public void mouseUp(org.eclipse.swt.events.MouseEvent e) { +				// Nothing to do here +			} +			 +			@Override +			public void mouseDown(org.eclipse.swt.events.MouseEvent e) { +				setSelected(BKUs.LOCAL); +			} +			 +			@Override +			public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { +				// Nothing to do here +			} +		}); +		cc_karte.setLayoutData(fd_cc_karte);  		Image karte = new Image(getDisplay(), new ImageData(this.getClass().getResourceAsStream("/img/karte.gif"))); //$NON-NLS-1$ -		btn_card.setImage(karte); +		cc_karte.setImage(karte); +		FontData[] fD_cc_karte = cc_mobile.getFont().getFontData(); +		fD_cc_karte[0].setHeight(Constants.TEXT_SIZE_BUTTON); +		cc_mobile.setFont(new Font(Display.getCurrent(), fD_cc_karte[0]));  		this.btnMobile = new Button(this, SWT.NONE);  		FormData fd_btnMobile = new FormData(); -		fd_btnMobile.top = new FormAttachment(btn_mobile, 10); +		fd_btnMobile.top = new FormAttachment(cc_mobile, 10);  		//fd_btnMobile.left = new FormAttachment(btn_mobile, 0);  		fd_btnMobile.right = new FormAttachment(50, -5); -		fd_btnMobile.width = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; +		fd_btnMobile.width = cc_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;  		this.btnMobile.setLayoutData(fd_btnMobile);  		this.btnMobile.setText(Messages.getString("bku_selection.mobile")); //$NON-NLS-1$  		this.btnMobile.addSelectionListener(new MobileSelectionListener());  		this.btnCard = new Button(this, SWT.NONE);  		FormData fd_btnCard = new FormData(); -		fd_btnCard.top = new FormAttachment(btn_card, 10); +		fd_btnCard.top = new FormAttachment(cc_karte, 10);  		//fd_btnMobile.left = new FormAttachment(btn_mobile, 0);  		fd_btnCard.left = new FormAttachment(50, 5); -		fd_btnCard.width = btn_card.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; +		fd_btnCard.width = cc_karte.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;  		this.btnCard.setLayoutData(fd_btnCard);  		this.btnCard.setText(Messages.getString("bku_selection.card")); //$NON-NLS-1$  		this.btnCard.addSelectionListener(new LocalSelectionListener()); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java new file mode 100644 index 00000000..2ab5c82e --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java @@ -0,0 +1,126 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.controls; + +// Imports +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *  + */ +public class ClickableCanvas extends Canvas { +	 +	private Image image = null; +	 +	/** +	 * @param parent +	 * @param style +	 */ +	public ClickableCanvas(Composite parent, int style) { +		super(parent, style); +		 +		this.addPaintListener(new PaintListener() { + +			@Override +			public void paintControl(PaintEvent e) { +				ClickableCanvas.this.paintControl(e); +			} +		}); + +		final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND); + +		this.addListener(SWT.Resize, new Listener() { + +			@Override +			public void handleEvent(Event event) { +				ClickableCanvas.this.redraw(); +			} +		}); + +		this.setCursor(hand); + +	} + +	/** +	 * Gets the image +	 *  +	 * @return the image +	 */ +	public Image getImage() { +		return this.image; +	} + +	/** +	 * Sets the Image +	 *  +	 * @param image +	 *            the imgage to set +	 */ +	public void setImage(Image image) { +		this.image = image; +	} + +	/** +	 * Main painting method +	 *  +	 * @param e +	 */ +	void paintControl(PaintEvent e) { +		this.paintText(e); +	} + +	/** +	 * Paint the text or image on the button +	 *  +	 * @param e +	 */ +	protected void paintText(PaintEvent e) { +		Point size = this.getSize(); +		int width = size.x; + +		// e.gc.fillGradientRectangle(0, 1, width, height / 4, true); + +		if (this.image != null) { +			 +			//log.debug("Width: " + width + " Height: " + height); +			 +			int w = 0; +			Image tmp = null; +			if(this.image.getImageData().width < width) { +				tmp = new Image(getDisplay(), this.image.getImageData()); +				w = (width - this.image.getImageData().width) / 2; +			} else if(this.image.getImageData().width > width) { +				tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(width, width)); +			} else { +				tmp = new Image(getDisplay(), this.image.getImageData()); +			} +			 +			e.gc.drawImage(tmp, w, w); +		} + +	} +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java index 2575fd91..3478ecc8 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java @@ -135,7 +135,6 @@ public class StateMachineImpl implements StateMachine, GUIProvider {  	public void invokeUpdate() {  		if (this.display != null) {  			this.display.asyncExec(new Runnable() { -  				@Override  				public void run() {  					StateMachineImpl.this.update(); | 
