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.widgets.FileDialog; 10 import org.eclipse.swt.widgets.MessageBox; 11 import org.eclipse.swt.widgets.Shell; 12 import org.xpcards.XPCards; 13 14 /*** 15 * @author galu02 16 */ 17 public class SaveAs extends AbstractAction { 18 19 public static final String ACTION_ID = "SaveAs"; 20 21 /*** 22 * @see org.xpcards.actions.AbstractAction#performAction() 23 */ 24 public void performAction(final Shell shell, XPCards parent, Object[] args) { 25 if (parent.projects() == null 26 || !parent.projects().hasMoreElements()) { 27 return; 28 } 29 30 FileDialog saveDialog = new FileDialog(shell, SWT.SAVE); 31 saveDialog.setFilterExtensions(new String[] { "*.xpc;", "*.*" }); 32 saveDialog.setFilterNames( 33 new String[] { "XP Cards Projects (*.xpc)", "All Files" }); 34 35 saveDialog.open(); 36 String name = saveDialog.getFileName(); 37 38 if (name.equals("")) 39 return; 40 41 if (name.indexOf(".xpc") != name.length() - 4) { 42 name += ".xpc"; 43 } 44 45 File file = new File(saveDialog.getFilterPath(), name); 46 if (file.exists()) { 47 MessageBox box = 48 new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); 49 box.setText("Save As"); 50 box.setMessage( 51 "File " + file.getName() + " already exists. Overwrite?"); 52 if (box.open() != SWT.NO) { 53 return; 54 } 55 } 56 // parent.setFile(file); 57 58 parent.getAction(Save.ACTION_ID).performAction(shell, parent, null); 59 } 60 }

This page was automatically generated by Maven