From abd82d6cbfdf4f8977dde1f3d03d56be8665f882 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 18:54:48 +0000 Subject: Add all files filter to DataSourceSelectComposite git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@34 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../src/main/java/at/asit/pdfover/gui/GUI.java | 100 +++++++++++++++++++++ .../gui/composites/DataSourceSelectComposite.java | 18 ++-- 2 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/GUI.java (limited to 'pdf-over-gui/src/main') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/GUI.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/GUI.java new file mode 100644 index 00000000..9b9f8a63 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/GUI.java @@ -0,0 +1,100 @@ +/* + * 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; + +// Imports +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +/** + * + */ +public class GUI { + /** + * Main window + */ + protected Shell shell; + + /** + * Launch the application. + * @param args + */ + public static void main(String[] args) { + try { + GUI window = new GUI(); + window.open(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Open the window. + */ + public void open() { + Display display = Display.getDefault(); + createContents(); + this.shell.open(); + this.shell.layout(); + while (!this.shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + } + + /** + * Create contents of the window. + */ + protected void createContents() { + this.shell = new Shell(); + this.shell.setSize(640, 480); + this.shell.setText("PDF-Over 4.0"); + + final Composite compOpenFile = new Composite(this.shell, SWT.NONE); + compOpenFile.setBounds(0, 0, 640, 480); + + final Composite compPosition = new Composite(this.shell, SWT.NONE); + compPosition.setBounds(0, 0, 640, 480); + + + Label lblPage1 = new Label(compOpenFile, SWT.NONE); + lblPage1.setBounds(20, 20, 70, 17); + lblPage1.setText("Open file"); + + Button btnNext = new Button(compOpenFile, SWT.NONE); + btnNext.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + compPosition.moveAbove(compOpenFile); + } + }); + btnNext.setBounds(20, 50, 91, 29); + btnNext.setText("Next"); + + Label lblPage2 = new Label(compPosition, SWT.NONE); + lblPage2.setBounds(20, 20, 140, 17); + lblPage2.setText("Position signature"); + + + } +} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java index b68ffa03..9b6539d2 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java @@ -64,16 +64,16 @@ public class DataSourceSelectComposite extends StateComposite { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(DataSourceSelectComposite.this.getShell(), SWT.OPEN); - dialog.setFilterExtensions(new String[] {"*.pdf"}); //$NON-NLS-1$ - dialog.setFilterNames(new String[] {"PDF Dateien"}); + dialog.setFilterExtensions(new String[] {"*.pdf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$ + dialog.setFilterNames(new String[] {"PDF documents", "All files"}); String fileName = dialog.open(); - File file = null; - if (fileName != null) { - file = new File(fileName); - if(file.exists()) { - DataSourceSelectComposite.this.setSelected(file); - } - } + File file = null; + if (fileName != null) { + file = new File(fileName); + if (file.exists()) { + DataSourceSelectComposite.this.setSelected(file); + } + } } @Override -- cgit v1.2.3