From f0fa48ec79fde432cf06e212aedf5d638f01cf56 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal Date: Mon, 9 May 2011 15:20:04 +0530 Subject: Story #42 - Volume logs download --- src/com.gluster.storage.management.gui/plugin.xml | 16 ++++ .../gui/actions/DownloadVolumeLogsAction.java | 86 ++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DownloadVolumeLogsAction.java (limited to 'src/com.gluster.storage.management.gui') diff --git a/src/com.gluster.storage.management.gui/plugin.xml b/src/com.gluster.storage.management.gui/plugin.xml index b208fc24..6c6983a3 100644 --- a/src/com.gluster.storage.management.gui/plugin.xml +++ b/src/com.gluster.storage.management.gui/plugin.xml @@ -524,6 +524,22 @@ toolbarPath="Normal" tooltip="Delete Volume"> + + + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console 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 Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package com.gluster.storage.management.gui.actions; + +import java.io.File; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; + +import com.gluster.storage.management.client.GlusterDataModelManager; +import com.gluster.storage.management.client.VolumesClient; +import com.gluster.storage.management.core.model.Volume; + +/** + * + */ +public class DownloadVolumeLogsAction extends AbstractActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gui.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(IAction action) { + final Volume volume = (Volume)selectedEntity; + final VolumesClient client = new VolumesClient(GlusterDataModelManager.getInstance().getSecurityToken()); + + final Runnable downloadLogsThread = new Runnable() { + + @Override + public void run() { + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + dialog.setFilterNames(new String[] {"GZipped Tar (*.tar.gz)"}); + dialog.setFilterExtensions(new String[] {"*.tar.gz"}); + dialog.open(); + + String title = "Download Volume Logs [" + volume.getName() + "]"; + String filePath = dialog.getFilterPath() + File.separator + dialog.getFileName(); + if(!filePath.endsWith(".tar.gz")) { + filePath += ".tar.gz"; + } + try { + client.downloadLogs(volume.getName(), filePath); + showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); + } catch(Exception e) { + showErrorDialog(title, e.getMessage()); + } + } + }; + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + + @Override + public void run() { + Display.getDefault().asyncExec(downloadLogsThread); + } + }); + } +} -- cgit