Java tutorial
/* Copyright (C) 2006 NTT DATA Corporation This program is free software; you can redistribute it and/or Modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program 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 General Public License for more details. */ package com.clustercontrol.accesscontrol.view.action; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.handlers.HandlerUtil; import com.clustercontrol.accesscontrol.dialog.UserDialog; import com.clustercontrol.accesscontrol.view.RoleSettingTreeView; import com.clustercontrol.accesscontrol.view.UserListView; import com.clustercontrol.util.EndpointManager; import com.clustercontrol.ws.access.UserInfo; /** * []???? * * @version 5.0.0 * @since 2.0.0 */ public class UserAddAction extends AbstractHandler { /** */ private static Log m_log = LogFactory.getLog(UserAddAction.class); /** ID */ public static final String ID = UserAddAction.class.getName(); /** */ private IWorkbenchPart viewPart; /** * Dispose */ @Override public void dispose() { this.viewPart = null; } /** * []?????????<BR> * [??]?????? * <p> * <ol> * <li>[??]???</li> * <li>[]???</li> * </ol> * * @see org.eclipse.core.commands.IHandler#execute * @see com.clustercontrol.accesscontrol.dialog.UserDialog * @see com.clustercontrol.accesscontrol.view.UserListView */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // ??? this.viewPart = HandlerUtil.getActivePart(event); String managerName = EndpointManager.getActiveManagerNameList().get(0); // ? UserDialog dialog = new UserDialog(this.viewPart.getSite().getShell(), managerName, new UserInfo(), false); // ??????????? if (dialog.open() == IDialogConstants.OK_ID) { UserListView userListView = (UserListView) this.viewPart.getAdapter(UserListView.class); if (userListView == null) { m_log.info("execute: user list view is null"); } else { userListView.update(); } //? IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); //? IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID); if (roleTreeViewPart != null) { RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart .getAdapter(RoleSettingTreeView.class); if (treeView == null) { m_log.info("execute: tree view is null"); } else { treeView.update(); } } } return null; } }