/******************************************************************************* * Copyright (c) 2014 hangum. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * hangum - initial API and implementation ******************************************************************************/ package com.hangum.tadpole.rdb.core.actions.connections.ext; import org.apache.log4j.Logger; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; import com.hangum.tadpole.commons.libs.core.message.CommonMessages; import com.hangum.tadpole.engine.query.dao.system.UserDBDAO; import com.hangum.tadpole.rdb.core.Messages; import com.hangum.tadpole.rdb.core.viewers.connections.ManagerViewer; /** * download sqlite database action. * * @author hangum * */ public class DownloadSQLiteDBAction implements IViewActionDelegate { /** * Logger for this class */ private static final Logger logger = Logger.getLogger(DownloadSQLiteDBAction.class); private IStructuredSelection sel; public DownloadSQLiteDBAction() { super(); } @Override public void run(IAction action) { final UserDBDAO userDB = (UserDBDAO)sel.getFirstElement(); if(!MessageDialog.openConfirm(null, CommonMessages.get().Confirm, String.format(Messages.get().DoYouWnatDownload, userDB.getDisplay_name()))) return; ManagerViewer view = (ManagerViewer)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ManagerViewer.ID); view.download(userDB); } @Override public void selectionChanged(IAction action, ISelection selection) { sel = (IStructuredSelection)selection; } @Override public void init(IViewPart view) { } }