/*
 * Copyright (C) 2005 NTT DATA Corporation
 * 
 */
package org.postgresforest.tool.view.action;

import java.util.ArrayList;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.postgresforest.tool.action.ServerAction;
import org.postgresforest.tool.db.GSCdata;
import org.postgresforest.tool.util.Messages;
import org.postgresforest.tool.util.SessionProperty;
import org.postgresforest.tool.view.serverstatus.ServerStatusView;

/**
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SetServerStatusAction extends ActionBase {
    public static final String ID = "org.postgresforest.tool.view.action.SetServerStatusAction";

    /* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
	public void run(IAction action) {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		if(MessageDialog.openQuestion(shell, 
				Messages.getString("form.db.update"), 
				Messages.getString("message.status.confirm"))){

			// サーバステータスを設定

			ServerStatusView view = (ServerStatusView)m_view;

			//TableViewerからサーバ情報を取得
			ArrayList statusList = view.getChgServerList();

			//サーバ情報設定
			ServerAction serverAction = new ServerAction((GSCdata)SessionProperty.get("gsc"));
			serverAction.setStatus(statusList);

			//viewの表示更新
			view.update();
			
		}
	}


}
