View Javadoc
1 /* 2 * Created on 05.03.2004 3 */ 4 package org.xpcards.actions; 5 6 import java.io.File; 7 8 import org.eclipse.swt.SWT; 9 import org.eclipse.swt.graphics.Cursor; 10 import org.eclipse.swt.widgets.FileDialog; 11 import org.eclipse.swt.widgets.MessageBox; 12 import org.eclipse.swt.widgets.Shell; 13 import org.xpcards.XPCards; 14 15 /*** 16 * @author galu02 17 */ 18 public class Open extends AbstractAction { 19 20 public static final String ACTION_ID = "Open"; 21 22 /*** 23 * @see org.xpcards.actions.AbstractAction#performAction() 24 */ 25 public void performAction(final Shell shell, XPCards parent, Object[] args) { 26 if ( parent.isModified() && parent.projects() != null && parent.projects().hasMoreElements()) { 27 MessageBox box = 28 new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); 29 box.setText("Save data"); 30 box.setMessage( 31 "Unsaved data exists. Save?"); 32 if (box.open() == SWT.YES) { 33 new Save().performAction(shell, parent, null); 34 } 35 } 36 37 FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); 38 39 fileDialog.setFilterExtensions(new String[] { "*.xpc;", "*.*" }); 40 fileDialog.setFilterNames( 41 new String[] { "XP Cards Project (*.xpc)", "All Files (*.*)" }); 42 String name = fileDialog.open(); 43 44 if (name == null) 45 return; 46 File file = new File(name); 47 if (!file.exists()) { 48 displayError( 49 "File " + file.getName() + " " + " does not exists.", 50 shell); 51 return; 52 } 53 54 Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT); 55 shell.setCursor(waitCursor); 56 57 try { 58 // parent.deserializeProjectsCollection(file); 59 // parent.setFile(file); 60 // parent.setModified(false); 61 } catch (Exception e) { 62 displayError( 63 "File read error: " + "\n" + file.getName(), 64 shell); 65 } finally { 66 shell.setCursor(null); 67 waitCursor.dispose(); 68 } 69 70 } 71 72 }

This page was automatically generated by Maven