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

import org.eclipse.jface.action.IAction;
import org.postgresforest.tool.action.DbInstanceAction;
import org.postgresforest.tool.db.GSCdata;
import org.postgresforest.tool.util.ErrorLog;
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 DelInstanceAction extends ActionBase {
    public static final String ID = "org.postgresforest.tool.view.action.DelInstanceAction";
	/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
	public void run(IAction action) {
	    ServerStatusView view = (ServerStatusView)m_view;
		String id = view.getSelectId();
		//インスタンス削除
		if(id != ""){
			//セッション･プロパティからグローバルシステムカタログを取得
			GSCdata gsc = (GSCdata)SessionProperty.get("gsc");
			DbInstanceAction instance = new DbInstanceAction(gsc);
			try {
				instance.delInstance(id);
			} catch (Exception e1) {
				e1.printStackTrace();
				ErrorLog.log("", e1);
			}
		}
		
		view.update();
	}


}
