dfaf5509b67d74a0b8586feb5e3da6ab7f8e9ac3
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / ExportBookmarksAction.java
1 package net.sourceforge.phpdt.sql.actions;
2
3 import java.io.File;
4
5 import org.eclipse.jface.action.IAction;
6 import org.eclipse.jface.viewers.ISelection;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.widgets.FileDialog;
9 import org.eclipse.ui.IViewActionDelegate;
10 import org.eclipse.ui.IViewPart;
11
12 import net.sourceforge.phpdt.sql.view.BookmarkView;
13 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkContentProvider;
14
15 /**
16  * @author root
17  *
18  * To change this generated comment edit the template variable "typecomment":
19  * Window>Preferences>Java>Templates.
20  * To enable and disable the creation of type comments go to
21  * Window>Preferences>Java>Code Generation.
22  */
23 public class ExportBookmarksAction
24         implements IViewActionDelegate {
25                 
26         BookmarkView view;
27         FileDialog dialog;
28
29         /**
30          * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
31          */
32         public void init(IViewPart view) {
33                 this.view = (BookmarkView) view;
34                 dialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);
35                 dialog.setFilterExtensions(new String[]{"*.ini","*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
36                 dialog.setFilterNames(new String[]{Messages.getString("filedialog.preferences"),Messages.getString("filedialog.allfiles")}); //$NON-NLS-1$ //$NON-NLS-2$
37         }
38
39         /**
40          * @see org.eclipse.ui.IActionDelegate#run(IAction)
41          */
42         public void run(IAction action) {
43                 String filename = dialog.open();
44                 if (filename != null) {
45                         File exportFile = new File(filename);
46                         BookmarkContentProvider.getInstance().save(exportFile);
47                 }
48         }
49         
50         /**
51          * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
52          */
53         public void selectionChanged(IAction action, ISelection selection) {
54         }
55
56 }