/**
* 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.
*
* HIDB2 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.Activator;
import hidb2.gui.FileBrowseView;
import hidb2.gui.preferences.PrefConst;
import hidb2.gui.ressources.RscMan;
import hidb2.gui.util.DlgImageViewer;
import hidb2.kern.HIDBConst;
import java.io.File;
import java.util.List;
import java.util.logging.Logger;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
* Generic open file command from the iconic filebrowser.
*
*/
public class ViewIcon extends Action implements HIDBConst
{
final static Logger log = Logger.getLogger("hidb2.gui.action");
private FileBrowseView _viewer;
public ViewIcon(FileBrowseView viewer)
{
_viewer = viewer;
setText("View Icon File");
setToolTipText("View");
// The id is used to refer to the action in a menu or toolbar
setId("hidb2.gui.action.ViewIcon");
// Associate the action with a pre-defined command, to allow key bindings.
// setActionDefinitionId("hidb2.gui.action.OpenFile");
setImageDescriptor(RscMan.getImageDescriptor("View-16x16.png"));
}
public void run()
{
if (_viewer != null)
{
List<File> lstSel = _viewer.getSelection();
if (!lstSel.isEmpty())
{
// Implement image view
IWorkbenchWindow wbwin = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IPreferenceStore pref = Activator.getDefault().getPreferenceStore();
DlgImageViewer div = new DlgImageViewer(wbwin.getShell());
div.setPref(pref.getInt(PrefConst.P_IVR_MIN_ZOOM), pref.getInt(PrefConst.P_IVR_MAX_ZOOM), pref
.getInt(PrefConst.P_IVR_DEFAULT_WIDTH), pref.getInt(PrefConst.P_IVR_DEFAULT_HEIGHT));
div.open(lstSel.get(0).getAbsolutePath());
}
}
}
}