List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:com.clustercontrol.accesscontrol.view.action.RoleDeleteAction.java
License:Open Source License
/** * []????????<BR>//from w w w . ja v a 2 s.c o m * ??? * <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>//from ww w .j ava2 s . c o m * ??? * <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.dialog.CalendarDialog.java
License:Open Source License
/** * ????/* w ww . ja va2 s . c o m*/ * * @param parent * ? */ @Override protected void customizeDialog(Composite parent) { shell = this.getShell(); // shell.setText(Messages.getString("dialog.calendar.calendar.create.modify")); GridData gridData = new GridData(); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 10; layout.marginHeight = 10; parent.setLayout(layout); /* * */ calGroup = new Group(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "setting", calGroup); layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; layout.numColumns = 15; calGroup.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = 15; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calGroup.setLayoutData(gridData); calGroup.setText(Messages.getString("calendar.create")); /* * ? */ Label labelManager = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "manager", labelManager); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 4; labelManager.setLayoutData(gridData); labelManager.setText(Messages.getString("facility.manager") + " : "); if (this.mode == PropertyDefineConstant.MODE_MODIFY) { this.m_managerComposite = new ManagerListComposite(calGroup, SWT.NONE, false); } else { this.m_managerComposite = new ManagerListComposite(calGroup, SWT.NONE, true); this.m_managerComposite.getComboManagerName().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (calDetailComposite.getDetailList() != null && calDetailComposite.getDetailList().size() > 0) { if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.calendar.55"))) { m_managerComposite.setText(managerName); return; } String managerName = m_managerComposite.getText(); calRoleIdListComposite.createRoleIdList(managerName); calDetailComposite.changeManagerName(m_managerComposite.getText(), true); String roleId = calRoleIdListComposite.getText(); calDetailComposite.changeOwnerRoleId(roleId); } else { String managerName = m_managerComposite.getText(); calRoleIdListComposite.createRoleIdList(managerName); calDetailComposite.changeManagerName(m_managerComposite.getText(), false); String roleId = calRoleIdListComposite.getText(); calDetailComposite.changeOwnerRoleId(roleId); } managerName = m_managerComposite.getText(); } }); } WidgetTestUtil.setTestId(this, "managerComposite", this.m_managerComposite); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.horizontalSpan = 8; gridData.grabExcessHorizontalSpace = true; this.m_managerComposite.setLayoutData(gridData); if (this.managerName != null) { this.m_managerComposite.setText(this.managerName); } /* * ID */ // Label lblCalID = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "calid", lblCalID); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; lblCalID.setLayoutData(gridData); lblCalID.setText(Messages.getString("calendar.id") + " : "); // calIdText = new Text(calGroup, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "calid", calIdText); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calIdText.setLayoutData(gridData); calIdText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); /* * ?? */ // Label lblCalName = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "calendarname", lblCalName); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; lblCalName.setLayoutData(gridData); lblCalName.setText(Messages.getString("calendar.name") + " : "); // calNameText = new Text(calGroup, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "calName", calNameText); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calNameText.setLayoutData(gridData); calNameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); /* * */ // Label lblCalDescription = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "description", lblCalDescription); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; lblCalDescription.setLayoutData(gridData); lblCalDescription.setText(Messages.getString("description") + " : "); // calDescription = new Text(calGroup, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "caldescription", calDescription); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calDescription.setLayoutData(gridData); calDescription.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); /* * ID */ Label labelRoleId = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "ownerroleid", labelRoleId); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; labelRoleId.setLayoutData(gridData); labelRoleId.setText(Messages.getString("owner.role.id") + " : "); if (this.mode == PropertyDefineConstant.MODE_ADD || this.mode == PropertyDefineConstant.MODE_COPY) { this.calRoleIdListComposite = new RoleIdListComposite(calGroup, SWT.NONE, this.managerName, true, Mode.OWNER_ROLE); this.calRoleIdListComposite.getComboRoleId().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (calDetailComposite.getDetailList() != null && calDetailComposite.getDetailList().size() > 0) { if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.calendar.50"))) { calRoleIdListComposite.setText(ownerRoleId); return; } } calDetailComposite.changeOwnerRoleId(calRoleIdListComposite.getText()); ownerRoleId = calRoleIdListComposite.getText(); } }); } else { this.calRoleIdListComposite = new RoleIdListComposite(calGroup, SWT.NONE, this.managerName, false, Mode.OWNER_ROLE); } WidgetTestUtil.setTestId(this, "calroleidlist", calRoleIdListComposite); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calRoleIdListComposite.setLayoutData(gridData); /* * */ // Label lblCalTimeFrom = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "caltimefrom", lblCalTimeFrom); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; lblCalTimeFrom.setLayoutData(gridData); lblCalTimeFrom.setText(Messages.getString("valid.time") + "(" + Messages.getString("start") + ")" + " : "); // calTimeFromText = new Text(calGroup, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "timefrom", calTimeFromText); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calTimeFromText.setLayoutData(gridData); //????????? calTimeFromText.setEnabled(false); calTimeFromText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // calTimeFromButton = new Button(calGroup, SWT.NONE); WidgetTestUtil.setTestId(this, "timefrom", calTimeFromButton); gridData = new GridData(); gridData.horizontalSpan = 1; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calTimeFromButton.setLayoutData(gridData); calTimeFromButton.setText(Messages.getString("calendar.button")); calTimeFromButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DateTimeDialog dialog = new DateTimeDialog(shell); if (calTimeFromText.getText().length() > 0) { Date date = new Date(calTimeFrom); dialog.setDate(date); } if (dialog.open() == IDialogConstants.OK_ID) { //???Long??? calTimeFrom = dialog.getDate().getTime(); //???"yyyy/MM/dd HH:mm:ss"???? SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat(); String tmp = sdf.format(dialog.getDate()); calTimeFromText.setText(tmp); update(); } } }); /* * */ // Label lblCalTimeTo = new Label(calGroup, SWT.LEFT); WidgetTestUtil.setTestId(this, "caltimeto", lblCalTimeTo); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; lblCalTimeTo.setLayoutData(gridData); lblCalTimeTo.setText(Messages.getString("valid.time") + "(" + Messages.getString("end") + ")" + " : "); // calTimeToText = new Text(calGroup, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "timeto", calTimeToText); gridData = new GridData(); gridData.horizontalSpan = 8; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calTimeToText.setLayoutData(gridData); //????????? calTimeToText.setEnabled(false); calTimeToText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // calTimeToButton = new Button(calGroup, SWT.NONE); WidgetTestUtil.setTestId(this, "timeto", calTimeToButton); gridData = new GridData(); gridData.horizontalSpan = 1; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calTimeToButton.setLayoutData(gridData); calTimeToButton.setText(Messages.getString("calendar.button")); calTimeToButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DateTimeDialog dialog = new DateTimeDialog(shell); if (calTimeToText.getText().length() > 0) { Date date = new Date(calTimeTo); dialog.setDate(date); } if (dialog.open() == IDialogConstants.OK_ID) { //???Long??? calTimeTo = dialog.getDate().getTime(); //???"yyyy/MM/dd HH:mm:ss"???? SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat(); m_log.trace("CalendarDialog getTime" + dialog.getDate()); String tmp = sdf.format(dialog.getDate()); calTimeToText.setText(tmp); } } }); /* * * */ calDetailGroup = new Group(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "detail", calDetailGroup); layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; layout.numColumns = 1; calDetailGroup.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = 15; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; calDetailGroup.setLayoutData(gridData); calDetailGroup.setText(Messages.getString("calendar.detail")); /** * */ //? GetCalendarDetailTableDefine.get(); this.calDetailComposite = new CalendarDetailInfoComposite(calDetailGroup, SWT.NONE, this.managerName); WidgetTestUtil.setTestId(this, "detail", calDetailComposite); gridData = new GridData(); gridData.horizontalSpan = 1; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.heightHint = 220; calDetailComposite.setLayoutData(gridData); Display calDisplay = shell.getDisplay(); shell.setLocation((calDisplay.getBounds().width - shell.getSize().x) / 2, (calDisplay.getBounds().height - shell.getSize().y) / 2); // this.adjustDialog(); //??? this.reflectCalendar(); //???? //this.createCalendarInfo(); // ? this.update(); }
From source file:com.clustercontrol.calendar.view.action.CalendarDeleteAction.java
License:Open Source License
/** * Handler execution/*www. j ava 2 s .co m*/ */ @Override public Object execute(final ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; } this.viewPart = HandlerUtil.getActivePart(event); // ?????ID? CalendarListView calendarListView = null; try { calendarListView = (CalendarListView) this.viewPart.getAdapter(CalendarListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (calendarListView == null) { m_log.info("execute: view is null"); return null; } Map<String, List<String>> map = calendarListView.getSelectedItem(); String[] args = new String[1]; String msg = null; int i = 0; String calId = null; for (Map.Entry<String, List<String>> entry : map.entrySet()) { for (String id : entry.getValue()) { calId = id; i++; } } if (i > 0) { // ??????????? if (i == 1) { msg = "message.calendar.7"; args[0] = calId; } else { msg = "message.calendar.71"; args[0] = Integer.toString(i); } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); StringBuffer messageArg = new StringBuffer(); i = 0; if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args))) { for (Map.Entry<String, List<String>> entry : map.entrySet()) { String managerName = entry.getKey(); CalendarEndpointWrapper wrapper = CalendarEndpointWrapper.getWrapper(managerName); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { wrapper.deleteCalendar(entry.getValue()); } catch (Exception e) { if (e instanceof InvalidRole_Exception) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } else { errorMsgs.put(managerName, Messages.getString("message.calendar.6") + ", " + HinemosMessage.replace(e.getMessage())); } } i++; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } else { args[0] = messageArg.toString(); // ?? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.calendar.5", args)); } // calendarListView.update(); } } return null; }
From source file:com.clustercontrol.calendar.view.action.CalendarPatternDeleteAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/* ww w . j a v a 2s .c om*/ this.viewPart = HandlerUtil.getActivePart(event); // []?????ID? CalendarPatternView calendarPatternView = null; try { calendarPatternView = (CalendarPatternView) this.viewPart.getAdapter(CalendarPatternView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (calendarPatternView == null) { m_log.info("execute: view is null"); return null; } List<ObjectBean> objList = calendarPatternView.getSelectedObjectBeans(); String[] args = new String[1]; String msg = null; if (objList == null || objList.isEmpty()) { return null; } Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>(); int size = 0; String patternId = ""; for (ObjectBean obj : objList) { String managerName = obj.getManagerName(); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } map.get(managerName).add(obj.getObjectId()); patternId = obj.getObjectId(); size++; } if (size > 0) { // ??????????? if (objList.size() == 1) { msg = "message.calendar.49"; args[0] = patternId; } else { msg = "message.calendar.72"; args[0] = Integer.toString(size); } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args)) == false) { return null; } } Map<String, String> errMsg = new ConcurrentHashMap<String, String>(); StringBuffer messageArg = new StringBuffer(); int i = 0; for (Map.Entry<String, List<String>> entry : map.entrySet()) { String managerName = entry.getKey(); List<String> idList = entry.getValue(); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { CalendarEndpointWrapper wrapper = CalendarEndpointWrapper.getWrapper(managerName); wrapper.deleteCalendarPattern(idList); } catch (Exception e) { if (e instanceof InvalidRole_Exception) { errMsg.put(managerName, Messages.getString("message.accesscontrol.16")); } else { errMsg.put(managerName, HinemosMessage.replace(e.getMessage())); } } i++; } if (errMsg.isEmpty()) { Object[] arg = { messageArg.toString() }; // ?? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.calendar.38", arg)); } else { // ? UIManager.showMessageBox(errMsg, true); } // calendarPatternView.update(); return null; }
From source file:com.clustercontrol.ClusterControlWorkbenchAdvisor.java
License:Open Source License
@Override public boolean preShutdown() { if (!ClusterControlPlugin.isRAP() && ClusterControlPlugin.isExitConfirm()) { return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.getString("message"), Messages.getString("leave.richclient.confirm")); }/*from w w w.ja v a 2 s . c om*/ return true; }
From source file:com.clustercontrol.collect.composite.CollectGraphComposite.java
License:Open Source License
/** * ?????/* w w w. j a v a2s. co m*/ * * * @param collectKeyInfoList * @param summaryCode * @param treeItemList * @param returnFlg ? * @throws InvalidRole_Exception * @throws HinemosUnknown_Exception * @throws InvalidUserPass_Exception * @throws Exception */ public void drawGraphs(List<CollectKeyInfoPK> collectKeyInfoList, String selectInfoStr, int summaryType, List<FacilityTreeItem> treeItemList, boolean returnFlg, boolean returnKindFlg, boolean totalFlg, boolean stackflg, boolean appflg, boolean threflg, boolean pieflg, boolean scatterflg, boolean legendFlg, boolean barFlg) throws InvalidUserPass_Exception, HinemosUnknown_Exception, InvalidRole_Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); dateFormat.setTimeZone(TimezoneUtil.getTimeZone()); m_log.info("drawGraphs() START time:" + dateFormat.format(new Date()) + ", selectInfoStr:" + selectInfoStr + ", summaryType:" + summaryType); setSettingLabel(summaryType, collectKeyInfoList); if (!completed || !slider_completed) { m_log.info("uncompleted!!"); return; } CollectGraphUtil.init(totalFlg, stackflg, collectKeyInfoList, pieflg, scatterflg, barFlg, selectInfoStr); // ???? setGraphMessages(); // ????? boolean booleanArr[] = { returnFlg, returnKindFlg, totalFlg, stackflg, appflg, threflg, pieflg, scatterflg, legendFlg, barFlg, ClusterControlPlugin.isRAP() }; String setting = getBooleanString(booleanArr); m_log.info( "setting boolean[return, returnkind, total, stack, applox, thre, pie, scatter, legend, bar, rap]:" + setting); // ??????div? deleteGraphs(); int facilitySize = 0; int graphSize = 0; int count = 0; for (FacilityTreeItem treeItem : treeItemList) { // ????????? facilitySize = CollectGraphUtil.sortManagerNameFacilityIdMap(treeItem, count); count++; } graphSize = facilitySize * collectKeyInfoList.size(); int managercount = CollectGraphUtil.getSelectManagerCount(); m_log.info("drawGraphs() graphSize:" + graphSize + ", itemCodeList.size:" + collectKeyInfoList.size() + ", facilityLength:" + facilitySize + ", managerCount:" + managercount); if (threflg && managercount != 1 && (!stackflg && !pieflg && !scatterflg && !barFlg)) { MessageDialog.openError(null, Messages.getString("error"), // ?????????? Messages.getString( "message.collection.graph.do.not.display.upperandlowerlimits.in.multiplemanager")); return; } int preferenceCount = ClusterControlPlugin.getDefault().getPreferenceStore() .getInt(PerformancePreferencePage.P_GRAPH_MAX); if (graphSize > preferenceCount) { // Preference????????? String args[] = { String.valueOf(graphSize), String.valueOf(preferenceCount) }; if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.collection.graph.limitsize", args))) { return; } m_log.info("???????? " + preferenceCount + "/" + graphSize); } // ????????? CollectGraphUtil.addManagerDummyName(); // ?? String createGraphJson = CollectGraphUtil.drawGraphSheets(summaryType); // ???? String params = getHeadControlClassName() + ".addGraphAtOnce(" + createGraphJson + ", " + facilitySize + ", " + preferenceCount + ", '" + setting + "');"; Long start = System.currentTimeMillis(); m_log.info("start base_graph Draw"); executeScript(params, m_browserGraph); m_log.info("end base_graph Draw time:" + (System.currentTimeMillis() - start) + "ms"); // ???????100%?? // ?????????????????initZoom? String preferenceZoom = ClusterControlPlugin.getDefault().getPreferenceStore() .getString(CollectSettingComposite.P_COLLECT_GRAPH_ZOOM_LEVEL); CollectGraphUtil.setGraphZoomSize(preferenceZoom); params = "initZoom(\'" + CollectGraphUtil.getGraphZoomSize() + "\', " + returnFlg + ", " + CollectGraphUtil.getM_screenWidth() + ");"; executeScript(params, m_browserGraph); // ? -> ? int totalGraphSize = graphSize; if (graphSize > preferenceCount) { totalGraphSize = preferenceCount; } params = "ControlBrushLine.delCreateBrush(" + CollectGraphUtil.getSliderStart() + "," + CollectGraphUtil.getSliderEnd() + "," + CollectGraphUtil.getTargetConditionStartDate() + "," + CollectGraphUtil.getTargetConditionEndDate() + "," + totalGraphSize + ");"; executeScript(params, m_browserSlider); // collectId?? CollectGraphUtil.collectCollectIdInfo(summaryType); // ????? addGraphPlot(CollectGraphUtil.getTargetConditionStartDate(), CollectGraphUtil.getTargetConditionEndDate(), CollectGraphUtil.getTargetConditionStartDate(), CollectGraphUtil.getTargetConditionEndDate()); // y????? String yaxisParam = getHeadControlClassName() + ".trimBranch();"; executeScript(yaxisParam, m_browserGraph); m_log.info("drawGraphs() END time:" + dateFormat.format(new Date())); }
From source file:com.clustercontrol.hub.dialog.LogFormatDialog.java
License:Open Source License
/** * ????//from w w w . j a v a2s.c o m * * @param parent ? */ @Override protected void customizeDialog(final Composite parent) { shell = this.getShell(); parent.getShell().setText(Messages.getString("dialog.hub.log.format")); /** * * ????? */ GridLayout baseLayout = new GridLayout(1, true); baseLayout.marginWidth = 10; baseLayout.marginHeight = 10; //? parent.setLayout(baseLayout); Composite logFormatComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; logFormatComposite.setLayout(layout); GridData gridData = new GridData(); gridData.verticalAlignment = SWT.FILL; // gridData.heightHint = 664; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; logFormatComposite.setLayoutData(gridData); /** TOP Composite */ Composite topComposite = new Composite(logFormatComposite, SWT.NONE); GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd_composite.heightHint = 121; topComposite.setLayoutData(gd_composite); topComposite.setLayout(new GridLayout(2, false)); //? Label label = new Label(topComposite, SWT.LEFT); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); label.setText(Messages.getString("facility.manager")); if (mode == PropertyDefineConstant.MODE_MODIFY) { managerListComposite = new ManagerListComposite(topComposite, SWT.NONE, false); } else { managerListComposite = new ManagerListComposite(topComposite, SWT.NONE, true); managerListComposite.getComboManagerName().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Update String managerName = managerListComposite.getText(); roleIdListComposite.createRoleIdList(managerName); } }); } gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; managerListComposite.setLayoutData(gridData); if (null != managerName) { managerListComposite.setText(managerName); } //ID Label labelFormatId = new Label(topComposite, SWT.LEFT); GridData gd_labelFormatId = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_labelFormatId.widthHint = 136; labelFormatId.setLayoutData(gd_labelFormatId); labelFormatId.setText(Messages.getString("hub.log.format.id")); txtFormatId = new Text(topComposite, SWT.BORDER); txtFormatId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtFormatId.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // Label lblDescription = new Label(topComposite, SWT.LEFT); lblDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); lblDescription.setText(Messages.getString("description")); txtDescription = new Text(topComposite, SWT.BORDER); txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); // ID Label labelRoleId = new Label(topComposite, SWT.LEFT); labelRoleId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); labelRoleId.setText(Messages.getString("owner.role.id")); if (this.mode == PropertyDefineConstant.MODE_MODIFY) { roleIdListComposite = new RoleIdListComposite(topComposite, SWT.NONE, this.managerListComposite.getText(), false, Mode.OWNER_ROLE); } else { roleIdListComposite = new RoleIdListComposite(topComposite, SWT.NONE, this.managerListComposite.getText(), true, Mode.OWNER_ROLE); } gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; roleIdListComposite.setLayoutData(gridData); // Group timestampLayout = new Group(logFormatComposite, SWT.NONE); GridData gd_timestampLayout = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_timestampLayout.heightHint = 58; timestampLayout.setLayoutData(gd_timestampLayout); timestampLayout.setText(Messages.getString("dialog.hub.log.format.date.extraction")); timestampLayout.setLayout(new GridLayout(2, false)); Label lblTimestampRegex = new Label(timestampLayout, SWT.NONE); GridData gd_lblTimestampRegex = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_lblTimestampRegex.widthHint = 144; lblTimestampRegex.setLayoutData(gd_lblTimestampRegex); lblTimestampRegex.setText(Messages.getString("dialog.hub.log.format.date.extraction.pattern")); txtTimestampRegex = new Text(timestampLayout, SWT.BORDER); GridData gd_txtTimestampRegex = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_txtTimestampRegex.widthHint = 237; txtTimestampRegex.setLayoutData(gd_txtTimestampRegex); Label lblTimestampFormat = new Label(timestampLayout, SWT.NONE); GridData gd_lblTimestampFormat = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_lblTimestampFormat.widthHint = 113; lblTimestampFormat.setLayoutData(gd_lblTimestampFormat); lblTimestampFormat.setText(Messages.getString("dialog.hub.log.format.date.extraction.format")); txtTimestampFormat = new Text(timestampLayout, SWT.BORDER); GridData gd_txtTimestampFormat = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_txtTimestampFormat.widthHint = 296; txtTimestampFormat.setLayoutData(gd_txtTimestampFormat); txtTimestampFormat.setMessage("ex. yyyy-MM-dd HH:mm:ss"); // Group keypatLayout = new Group(logFormatComposite, SWT.NONE); keypatLayout.setLayout(new GridLayout(2, false)); GridData gridData_1 = new GridData(); gridData_1.grabExcessHorizontalSpace = true; gridData_1.horizontalAlignment = GridData.FILL; keypatLayout.setLayoutData(gridData_1); keypatLayout.setText(Messages.getString("hub.log.format.key.pattern")); logFormatKeyListComposite = new LogFormatKeyListComposite(keypatLayout, SWT.BORDER, managerName); GridData gd_logFormatKeyListComposite = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd_logFormatKeyListComposite.heightHint = 217; gd_logFormatKeyListComposite.widthHint = 393; logFormatKeyListComposite.setLayoutData(gd_logFormatKeyListComposite); Composite composite = new Composite(keypatLayout, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); composite.setLayout(new GridLayout(1, false)); btnAddKeyPattern = new Button(composite, SWT.NONE); GridData gd_btnAddKeyPattern = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_btnAddKeyPattern.widthHint = 75; btnAddKeyPattern.setLayoutData(gd_btnAddKeyPattern); btnAddKeyPattern.setText(Messages.getString("add")); btnAddKeyPattern.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); LogKeyPatternDialog dialog = new LogKeyPatternDialog(shell, PropertyDefineConstant.MODE_ADD, logFormatKeyListComposite.getLogFormatKeyList()); if (dialog.open() == IDialogConstants.OK_ID) { logFormatKeyListComposite.addLogFormatKeyList(dialog.getLogFormatKey()); logFormatKeyListComposite.update(); } } }); btnModifyKeyPattern = new Button(composite, SWT.NONE); btnModifyKeyPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnModifyKeyPattern.setText(Messages.getString("modify")); btnModifyKeyPattern.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //????? String order = logFormatKeyListComposite.getSelectionLogFormatKey(); // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); //???LogFormatKey???? LogFormatKey logFormatKey = logFormatKeyListComposite.getLogFormatKeyListByKey(order); if (logFormatKey != null) { LogKeyPatternDialog dialog = new LogKeyPatternDialog(shell, PropertyDefineConstant.MODE_MODIFY, logFormatKeyListComposite.getLogFormatKeyList(), logFormatKey); if (dialog.open() == IDialogConstants.OK_ID) { logFormatKeyListComposite.getLogFormatKeyList().remove(logFormatKey); logFormatKeyListComposite.addLogFormatKeyList(dialog.getLogFormatKey()); logFormatKeyListComposite.update(); } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); btnDelKeyPattern = new Button(composite, SWT.NONE); btnDelKeyPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnDelKeyPattern.setText(Messages.getString("delete")); btnDelKeyPattern.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //????? String order = logFormatKeyListComposite.getSelectionLogFormatKey(); //???LogFormatKey???? LogFormatKey logFormatKey = logFormatKeyListComposite.getLogFormatKeyListByKey(order); String[] args = new String[1]; args[0] = order; if (logFormatKey != null) { if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.hub.log.format.pattern.delete", args))) { logFormatKeyListComposite.getLogFormatKeyList().remove(logFormatKey); logFormatKeyListComposite.update(); } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); btnCopyKeyPattern = new Button(composite, SWT.NONE); btnCopyKeyPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnCopyKeyPattern.setText(Messages.getString("copy")); btnCopyKeyPattern.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //????? String order = logFormatKeyListComposite.getSelectionLogFormatKey(); if (order != null) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); //???LogFormatKey???? LogFormatKey logFormatKey = logFormatKeyListComposite.getLogFormatKeyListByKey(order); if (logFormatKey != null) { LogKeyPatternDialog dialog = new LogKeyPatternDialog(shell, PropertyDefineConstant.MODE_COPY, logFormatKeyListComposite.getLogFormatKeyList(), logFormatKey); if (dialog.open() == IDialogConstants.OK_ID) { logFormatKeyListComposite.addLogFormatKeyList(dialog.getLogFormatKey()); logFormatKeyListComposite.update(); //logFormatKeyListComposite.setSelection(); } } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); this.reflectLogFormat(); update(); }
From source file:com.clustercontrol.hub.view.action.LogFormatDeleteAction.java
License:Open Source License
/** * Handler execution//from w ww . j a va 2s . c o m */ @Override public Object execute(final ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; } this.viewPart = HandlerUtil.getActivePart(event); // []?????ID? LogFormatView view = (LogFormatView) this.viewPart.getAdapter(LogFormatView.class); if (view == null) { m_log.info("execute: view is null"); return null; } Map<String, List<String>> map = view.getSelectedItem(); String[] args = new String[1]; String msg = null; String endMsg = null; int i = 0; int deleteSize = 0; String formatId = null; for (Map.Entry<String, List<String>> entry : map.entrySet()) { for (String id : entry.getValue()) { formatId = id; deleteSize++; } } if (deleteSize > 0) { // ??????????? if (deleteSize == 1) { msg = "message.hub.log.format.delete.single"; endMsg = "message.hub.log.format.delete.single.finish"; args[0] = formatId; } else { msg = "message.hub.log.format.delete.multi"; endMsg = "message.hub.log.format.delete.multi.finish"; args[0] = String.valueOf(deleteSize); } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); StringBuffer messageArg = new StringBuffer(); i = 0; if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args))) { for (Map.Entry<String, List<String>> entry : map.entrySet()) { String managerName = entry.getKey(); HubEndpointWrapper wrapper = HubEndpointWrapper.getWrapper(managerName); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { wrapper.deleteLogFormat(entry.getValue()); } catch (Exception e) { if (e instanceof InvalidRole_Exception) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } else if (e instanceof LogFormatUsed_Exception) { errorMsgs.put(managerName, HinemosMessage.replace(e.getMessage())); } else { errorMsgs.put(managerName, Messages.getString("message.hub.log.format.delete.failed") + ", " + e.getMessage()); } } i++; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } else { // ?? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString(endMsg, args)); } // view.update(); } } return null; }
From source file:com.clustercontrol.hub.view.action.LogTransferDeleteAction.java
License:Open Source License
/** * Handler execution//from w w w. j a v a 2 s .c om */ @Override public Object execute(final ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; } this.viewPart = HandlerUtil.getActivePart(event); // ??[?]?????ID? TransferView view = (TransferView) this.viewPart.getAdapter(TransferView.class); Map<String, List<String>> map = view.getSelectedItem(); String[] args = new String[1]; String msg = null; String endMsg = null; int i = 0; int deleteSize = 0; String exportId = null; for (Map.Entry<String, List<String>> entry : map.entrySet()) { for (String id : entry.getValue()) { exportId = id; deleteSize++; } } if (deleteSize > 0) { // ??????????? if (deleteSize == 1) { msg = "message.hub.log.transfer.delete.single"; endMsg = "message.hub.log.transfer.delete.single.finish"; args[0] = exportId; } else { msg = "message.hub.log.transfer.delete.multi"; endMsg = "message.hub.log.transfer.delete.multi.finish"; args[0] = String.valueOf(deleteSize); } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); StringBuffer messageArg = new StringBuffer(); i = 0; if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args))) { for (Map.Entry<String, List<String>> entry : map.entrySet()) { String managerName = entry.getKey(); HubEndpointWrapper wrapper = HubEndpointWrapper.getWrapper(managerName); if (i > 0) { messageArg.append(", "); } messageArg.append(managerName); try { wrapper.deleteTransferInfo(entry.getValue()); } catch (Exception e) { if (e instanceof InvalidRole_Exception) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } if (e instanceof LogFormatUsed_Exception) {//TODO errorMsgs.put(managerName, HinemosMessage.replace(e.getMessage())); } else { errorMsgs.put(managerName, Messages.getString("message.hub.log.transfar.delete.failed") + ", " + e.getMessage()); } } i++; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } else { // ?? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString(endMsg, args)); } // view.update(); } } return null; }