package net.sourceforge.phpdt.sql.actions; import java.io.File; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import net.sourceforge.phpdt.sql.view.BookmarkView; import net.sourceforge.phpdt.sql.view.bookmark.BookmarkContentProvider; /** * @author root * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class ImportBookmarksAction implements IViewActionDelegate { BookmarkView view; FileDialog dialog; /** * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) */ public void init(IViewPart view) { this.view = (BookmarkView) view; dialog = new FileDialog(view.getSite().getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[]{"*.ini","*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ dialog.setFilterNames(new String[]{Messages.getString("filedialog.preferences"),Messages.getString("filedialog.allfiles")}); //$NON-NLS-1$ //$NON-NLS-2$ } /** * @see org.eclipse.ui.IActionDelegate#run(IAction) */ public void run(IAction action) { String filename = dialog.open(); if (filename != null) { File importFile = new File(filename); BookmarkContentProvider.getInstance().importBookmarks(importFile); view.refresh(); } } /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) */ public void selectionChanged(IAction action, ISelection selection) { } }