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

import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.postgresforest.tool.action.UserMngAction;
import org.postgresforest.tool.db.GSCdata;
import org.postgresforest.tool.util.ErrorLog;
import org.postgresforest.tool.util.SessionProperty;
import org.postgresforest.tool.view.user.UserView;

/**
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class DelUserAction extends ActionBase {
    public static final String ID = "org.postgresforest.tool.view.action.DelUserAction";
	/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
	public void run(IAction action) {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		
		UserView view = (UserView)m_view;
		
		String user = view.getSelectUser();
		//ユーザー削除
		if(user != ""){
			//セッション･プロパティからグローバルシステムカタログを取得
			GSCdata gsc = (GSCdata)SessionProperty.get("gsc");
			UserMngAction userMng = new UserMngAction(gsc);
			try {
				userMng.delUser(user);
			} catch (Exception e1) {
				e1.printStackTrace();
				ErrorLog.log("", e1);
			}
		}
		
		view.update();
	}


}
