List of usage examples for org.eclipse.jface.viewers StructuredSelection toList
@Override
public List toList()
From source file:com.bluexml.side.Class.modeler.diagram.actions.DeleteLinkClassAspectAction.java
License:Open Source License
public void run() { Modeler modeler = (Modeler) getWorkbenchPart(); ConfirmationDialog dialog = new ConfirmationDialog(ClazzPlugin.getActiveWorkbenchShell(), "Delete From Model", "Are you sure you want to delete these model elements ?", modeler.getPreferenceStore(), "deleteModelActionConfirm"); int result = dialog.open(); if (result != 0) { return;//from w w w.j a v a 2 s.co m } StructuredSelection ss = (StructuredSelection) this.selection; for (Object o : ss.toList()) { if (o instanceof hasAspectEditPart) { //Get edit part and graph element hasAspectEditPart editPart = (hasAspectEditPart) o; GraphEdge eo = (GraphEdge) editPart.getModel(); //Get source and target edit part ClazzEditPart cep = (ClazzEditPart) editPart.getSource(); AspectEditPart aep = (AspectEditPart) editPart.getTarget(); //Get source and target model element Clazz c = (Clazz) Utils.getElement((GraphElement) cep.getModel()); Aspect a = (Aspect) Utils.getElement((GraphElement) aep.getModel()); DeleteLinkClassAspectCommand dlcac = new DeleteLinkClassAspectCommand(editPart, c, a, eo); editPart.getViewer().getEditDomain().getCommandStack().execute(dlcac); } } }
From source file:com.bluexml.side.Class.modeler.diagram.actions.DeleteLinkClassGeneralizationAction.java
License:Open Source License
public void run() { Modeler modeler = (Modeler) getWorkbenchPart(); ConfirmationDialog dialog = new ConfirmationDialog(ClazzPlugin.getActiveWorkbenchShell(), "Delete From Model", "Are you sure you want to delete these model elements ?", modeler.getPreferenceStore(), "deleteModelActionConfirm"); int result = dialog.open(); if (result != 0) { return;/* w w w .j a va 2 s . c om*/ } StructuredSelection ss = (StructuredSelection) this.selection; for (Object o : ss.toList()) { if (o instanceof GeneralizationEditPart) { //Get edit part and graph element GeneralizationEditPart editPart = (GeneralizationEditPart) o; GraphEdge eo = (GraphEdge) editPart.getModel(); //Get source and target edit part ClazzEditPart sp = (ClazzEditPart) editPart.getSource(); ClazzEditPart tp = (ClazzEditPart) editPart.getTarget(); //Get source and target model element Clazz cs = (Clazz) Utils.getElement((GraphElement) sp.getModel()); Clazz ct = (Clazz) Utils.getElement((GraphElement) tp.getModel()); DeleteLinkClassGeneralizationCommand dcgc = new DeleteLinkClassGeneralizationCommand(eo, cs, ct); editPart.getViewer().getEditDomain().getCommandStack().execute(dcgc); } } }
From source file:com.bluexml.side.Class.modeler.diagram.actions.DeleteLinkEnumerationDependsAction.java
License:Open Source License
public void run() { Modeler modeler = (Modeler) getWorkbenchPart(); ConfirmationDialog dialog = new ConfirmationDialog(ClazzPlugin.getActiveWorkbenchShell(), "Delete From Model", "Are you sure you want to delete these model elements ?", modeler.getPreferenceStore(), "deleteModelActionConfirm"); int result = dialog.open(); if (result != 0) { return;/*from w w w . j a v a 2 s . co m*/ } StructuredSelection ss = (StructuredSelection) this.selection; for (Object o : ss.toList()) { if (o instanceof dependsEditPart) { //Get edit part and graph element dependsEditPart editPart = (dependsEditPart) o; GraphEdge eo = (GraphEdge) editPart.getModel(); //Get source and target edit part EnumerationEditPart e1ep = (EnumerationEditPart) editPart.getSource(); //EnumerationEditPart e2p = (EnumerationEditPart) editPart.getTarget(); //Get source and target model element Enumeration e1 = (Enumeration) Utils.getElement((GraphElement) e1ep.getModel()); //Enumeration e2 = (Enumeration) Utils.getElement((GraphElement) e2p.getModel()); DeleteLinkEnumerationDependsCommand dledc = new DeleteLinkEnumerationDependsCommand(e1, eo); editPart.getViewer().getEditDomain().getCommandStack().execute(dledc); } } }
From source file:com.bluexml.side.Class.modeler.editor.ModelerContextMenuProvider.java
License:Open Source License
private boolean checkAllElements(ISelection selection, Class className) { if (selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; for (Object o : ss.toList()) { if (!o.getClass().equals(className)) { return false; }//from www . j av a 2 s . c o m } } return true; }
From source file:com.bluexml.side.Portal.modeler.diagram.actions.DeleteLinkGeneratedPortel.java
License:Open Source License
public void run() { Modeler modeler = (Modeler) getWorkbenchPart(); ConfirmationDialog dialog = new ConfirmationDialog(PortalPlugin.getActiveWorkbenchShell(), "Delete From Model", "Are you sure you want to delete these model elements ?", modeler.getPreferenceStore(), ModelerPreferenceConstants.DELETE_MODEL_ACTION_CONFIRM); int result = dialog.open(); if (result != 0) { return;/* w w w . j ava 2 s. co m*/ } StructuredSelection ss = (StructuredSelection) this.selection; for (Object o : ss.toList()) { if (o instanceof isInternalPortletEditPart) { //Get edit part and graph element isInternalPortletEditPart link = (isInternalPortletEditPart) o; GraphEdge eo = (GraphEdge) link.getModel(); //Get source edit part PortletEditPart pep = (PortletEditPart) link.getSource(); //Get source model element Portlet portlet = (Portlet) Utils.getElement((GraphElement) pep.getModel()); // call command to delete link DeleteLinkGeneratedPortletCommand dlgpc = new DeleteLinkGeneratedPortletCommand(portlet, eo); link.getViewer().getEditDomain().getCommandStack().execute(dlgpc); } } }
From source file:com.bluexml.side.Portal.modeler.diagram.actions.DeleteLinkPageLayoutAction.java
License:Open Source License
public void run() { Modeler modeler = (Modeler) getWorkbenchPart(); ConfirmationDialog dialog = new ConfirmationDialog(PortalPlugin.getActiveWorkbenchShell(), "Delete From Model", "Are you sure you want to delete these model elements ?", modeler.getPreferenceStore(), "deleteModelActionConfirm"); int result = dialog.open(); if (result != 0) { return;//from w w w. j av a 2 s . c o m } StructuredSelection ss = (StructuredSelection) this.selection; for (Object o : ss.toList()) { if (o instanceof UseLayoutEditPart) { //Get edit part and graph element UseLayoutEditPart useLayout = (UseLayoutEditPart) o; GraphEdge eo = (GraphEdge) useLayout.getModel(); //Get source edit part PageEditPart pep = (PageEditPart) useLayout.getSource(); //Get source model element Page p = (Page) Utils.getElement((GraphElement) pep.getModel()); DeleteLinkPageLayoutActionCommand dlpac = new DeleteLinkPageLayoutActionCommand(p, eo); useLayout.getViewer().getEditDomain().getCommandStack().execute(dlpac); } } }
From source file:com.bluexml.side.Portal.modeler.editor.ModelerContextMenuProvider.java
License:Open Source License
public static boolean checkAllElements(ISelection selection, Class<?> className) { System.out.println("ModelerContextMenuProvider.checkAllElements() Selection :" + selection + " class :" + className.getName());/*from w ww. j a va 2s . c o m*/ if (selection == null) { System.out.println("ModelerContextMenuProvider.checkAllElements() selection is null"); return false; } if (selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; for (Object o : ss.toList()) { if (!o.getClass().equals(className)) { System.out .println("ModelerContextMenuProvider.checkAllElements() selection is not right class"); System.err.println("selected object :" + o.getClass().getName()); System.err.println("Expected class :" + className.getName()); return false; } } } return true; }
From source file:com.clustercontrol.accesscontrol.view.action.RoleDeleteAction.java
License:Open Source License
/** * []????????<BR>//from w w w . j ava 2 s.c om * ??? * <p> * <ol> * <li>[]??????ID????</li> * <li>ID?????</li> * <li>[]???</li> * </ol> * * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) * @see com.clustercontrol.accesscontrol.view.UserListView * @see com.clustercontrol.accesscontrol.action.DeleteUserProperty#delete(String) */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // ??????UID? this.viewPart = HandlerUtil.getActivePart(event); RoleListView roleListView = null; try { roleListView = (RoleListView) this.viewPart.getAdapter(RoleListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (roleListView == null) { m_log.info("execute: role list view is null"); } else { StructuredSelection selection = (StructuredSelection) roleListView.getComposite().getTableViewer() .getSelection(); List<?> list = (List<?>) selection.toList(); Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>(); for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetRoleListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } int size = 0; String id = null; for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetRoleListTableDefine.MANAGER_NAME); String roleId = (String) objList.get(GetRoleListTableDefine.ROLE_ID); map.get(managerName).add(roleId); id = roleId; size++; } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); String[] args = new String[1]; String msg = null; // ??????????? if (size == 1) { msg = "message.accesscontrol.32"; args[0] = id; } else { msg = "message.accesscontrol.61"; args[0] = Integer.toString(size); } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args)) == false) { return null; } StringBuffer messageArg = new StringBuffer(); int i = 0; for (Map.Entry<String, List<String>> entry : map.entrySet()) { List<String> roleIdList = entry.getValue(); if (roleIdList.isEmpty()) { continue; } String managerName = entry.getKey(); AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { // ? wrapper.deleteRoleInfo(roleIdList); } catch (UsedFacility_Exception e) { // FIXME // FIXME // UsedFacility???facilityId??? String roleId = roleIdList.get(0); // ID???????? Object[] errorArgs = { roleId, PluginMessage.typeToString(e.getFaultInfo().getPlugin()) }; errorMsgs.put(managerName, Messages.getString("message.repository.27", errorArgs)); } catch (UsedOwnerRole_Exception e) { String roleId = e.getFaultInfo().getRoleId(); // ????????? Object[] errorArgs = { roleId, PluginMessage.typeToString(((UsedOwnerRole_Exception) e).getFaultInfo().getPlugin()) }; errorMsgs.put(managerName, Messages.getString("message.accesscontrol.52", errorArgs)); } catch (Exception e) { String errMessage = ""; if (e instanceof InvalidRole_Exception) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } else if (e instanceof UsedRole_Exception) { // ?????? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.42")); } else if (e instanceof UnEditableRole_Exception) { // ??????? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.41")); } else { errMessage = ", " + HinemosMessage.replace(e.getMessage()); } // ? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.31") + errMessage); } i++; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } else { Object[] arg = { messageArg.toString() }; // MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.accesscontrol.30", arg)); } // roleListView.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; }
From source file:com.clustercontrol.accesscontrol.view.action.UserDeleteAction.java
License:Open Source License
/** * []????????<BR>/* ww w . ja va2 s. com*/ * ??? * <p> * <ol> * <li>[]??????ID????</li> * <li>ID?????</li> * <li>[]???</li> * </ol> * * @see org.eclipse.core.commands.IHandler#execute * @see com.clustercontrol.accesscontrol.view.UserListView * @see com.clustercontrol.accesscontrol.action.DeleteUserProperty#delete(String) */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // ??? this.viewPart = HandlerUtil.getActivePart(event); // ??????UID? UserListView userListView = null; try { userListView = (UserListView) this.viewPart.getAdapter(UserListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (userListView == null) { m_log.info("execute: user list view is null"); } else { StructuredSelection selection = (StructuredSelection) userListView.getComposite().getTableViewer() .getSelection(); List<?> list = (List<?>) selection.toList(); Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>(); for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetUserListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } int size = 0; String id = null; for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetUserListTableDefine.MANAGER_NAME); String uid = (String) objList.get(GetUserListTableDefine.UID); map.get(managerName).add(uid); id = uid; size++; } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); String[] args = new String[1]; String msg = null; // ??????????? if (size == 1) { msg = "message.accesscontrol.13"; args[0] = id; } else { msg = "message.accesscontrol.62"; args[0] = Integer.toString(size); } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args)) == false) { return null; } StringBuffer messageArg = new StringBuffer(); int i = 0; for (Map.Entry<String, List<String>> entry : map.entrySet()) { List<String> uidList = entry.getValue(); if (uidList.isEmpty()) { continue; } String managerName = entry.getKey(); AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { // ? wrapper.deleteUserInfo(uidList); } catch (Exception e) { String errMessage = ""; if (e instanceof InvalidRole_Exception) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } else if (e instanceof UsedUser_Exception) { // ?????????? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.37")); } else if (e instanceof UnEditableUser_Exception) { // ???????????? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.39")); } else { // ? errMessage = ", " + HinemosMessage.replace(e.getMessage()); errorMsgs.put(managerName, Messages.getString("message.accesscontrol.12") + errMessage); } } i++; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } else { Object[] arg = { messageArg.toString() }; // MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.accesscontrol.11", arg)); } // 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; }
From source file:com.clustercontrol.calendar.view.CalendarListView.java
License:Open Source License
public List<String> getSelectedIdList() { StructuredSelection selection = (StructuredSelection) this.calListComposite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.toList(); String id = null;//w w w .jav a2 s .c om List<String> idList = new ArrayList<String>(); if (list != null) { for (Object obj : list) { @SuppressWarnings("unchecked") List<String> objList = (List<String>) obj; id = objList.get(GetCalendarListTableDefine.CALENDAR_ID); idList.add(id); } } return idList; }