/**
* This file is part of HIDB2.
*
* HIDB2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PoJamas is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with HIDB2. If not, see <http://www.gnu.org/licenses/>.
*/
package hidb2.gui.action;
import hidb2.gui.DlgSearch;
import hidb2.gui.SearchView;
import hidb2.gui.ressources.RscMan;
import hidb2.kern.HIDBConst;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
/**
* Start a database search.
* Open the search dialog.
*
*/
public class SearchAction extends Action implements HIDBConst
{
private final IWorkbenchWindow _window;
public SearchAction(String text, IWorkbenchWindow window)
{
super(text);
_window = window;
// The id is used to refer to the action in a menu or toolbar
setId("hidb2.gui.action.Search");
// Associate the action with a pre-defined command, to allow key bindings.
// setActionDefinitionId(ICommandIds.CMD_OPEN_FILECHECK);
setImageDescriptor(RscMan.getImageDescriptor(RscMan.IN_SEARCH));
}
/**
* Open the search result view and the search dialog.
*/
public void run()
{
try
{
IWorkbenchPage page = _window.getActivePage();
IViewPart searchView = page.showView(SearchView.ID);
DlgSearch dlg = new DlgSearch(_window.getShell(), searchView);
dlg.open();
}
catch (PartInitException e)
{
e.printStackTrace();
}
}
}