introduced IConstant.DEBUG flag
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / ImportBookmarksAction.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 ImportBookmarksAction implements IViewActionDelegate {
24         BookmarkView view;
25         FileDialog dialog;
26         /**
27          * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
28          */
29         public void init(IViewPart view) {
30                 this.view = (BookmarkView) view;
31                 dialog = new FileDialog(view.getSite().getShell(), SWT.OPEN);
32                 dialog.setFilterExtensions(new String[]{"*.ini","*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
33                 dialog.setFilterNames(new String[]{Messages.getString("filedialog.preferences"),Messages.getString("filedialog.allfiles")}); //$NON-NLS-1$ //$NON-NLS-2$
34         }
35
36         /**
37          * @see org.eclipse.ui.IActionDelegate#run(IAction)
38          */
39         public void run(IAction action) {
40                 String filename = dialog.open();
41                 if (filename != null) {
42                         File importFile = new File(filename);
43                         BookmarkContentProvider.getInstance().importBookmarks(importFile);
44                         view.refresh();
45                 }
46         }
47
48         /**
49          * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
50          */
51         public void selectionChanged(IAction action, ISelection selection) {
52         }
53
54 }