List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:com.clustercontrol.collect.composite.CollectSettingComposite.java
License:Open Source License
/** * ???????/*from ww w. j ava 2 s . c om*/ * * @param managers ????? */ public void setCollectorItemCombo() { List<String> allItemList = new ArrayList<>(); // ?????? List<String> selectList = this.m_collectGraphView.getFacilityTreeComposite().getCheckedTreeInfo(); TreeMap<String, List<String>> managerFacilityMap = new TreeMap<>(); for (String selectStr : selectList) { String[] nodeDetail = selectStr.split(SEPARATOR_HASH_EX_HASH); if (nodeDetail.length != 0 && nodeDetail[nodeDetail.length - 1].equals(String.valueOf(FacilityConstant.TYPE_NODE))) { String facilityId = nodeDetail[nodeDetail.length - 2]; String managerName = nodeDetail[0]; List<String> facilityList = managerFacilityMap.get(managerName); if (facilityList == null) { facilityList = new ArrayList<String>(); managerFacilityMap.put(managerName, facilityList); } if (!facilityList.contains(facilityId)) { m_log.debug("????? managerName:" + managerName + ", facilityId:" + facilityId); facilityList.add(facilityId); } } } for (Map.Entry<String, List<String>> map : managerFacilityMap.entrySet()) { String managerName = map.getKey(); List<String> facilityList = map.getValue(); // ??? List<CollectKeyInfoPK> collectKeyInfoList; try { CollectEndpointWrapper wrapper = CollectEndpointWrapper.getWrapper(managerName); collectKeyInfoList = wrapper.getItemCodeList(facilityList); } catch (InvalidRole_Exception e) { m_log.warn("setCollectorItemCombo() getItemCodeList, " + e.getMessage()); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); return; } catch (InvalidUserPass_Exception | HinemosUnknown_Exception e) { // ? m_log.warn("setCollectorItemCombo() getItemCodeList, " + e.getMessage(), e); MessageDialog.openInformation(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); return; } // DB?????? for (CollectKeyInfoPK collectKeyInfo : collectKeyInfoList) { String itemName = collectKeyInfo.getItemName(); String monitorId = collectKeyInfo.getMonitorId(); String displayName = collectKeyInfo.getDisplayName(); if (!allItemList.contains(itemName + SEPARATOR_AT + displayName + SEPARATOR_AT + monitorId)) { // itemCode@itemName ???? allItemList.add(itemName + SEPARATOR_AT + displayName + SEPARATOR_AT + monitorId); } } } // ?????????? for (String itemCodeName : allItemList) { String itemName = HinemosMessage.replace(itemCodeName.split(SEPARATOR_AT)[0]); String displayName = itemCodeName.split(SEPARATOR_AT)[1]; String monitorId = itemCodeName.split(SEPARATOR_AT)[2]; // itemName?displayName??????? if (!displayName.equals("") && !itemName.endsWith("[" + displayName + "]")) { itemName += "[" + displayName + "]"; } String itemNameStr = itemName + "(" + monitorId + ")"; if (!(Arrays.asList(m_listCollectorItem.getItems())).contains(itemNameStr)) { m_listCollectorItem.add(itemNameStr); m_listCollectorItem.setData(itemNameStr, itemCodeName); } } // ?? setDefaultItemInfo(); }
From source file:com.clustercontrol.collect.composite.CollectSettingComposite.java
License:Open Source License
/** * /*from ww w . j av a 2 s. com*/ * @param itemCodeList * @param summaryType * @return */ private boolean checkTreeCombo(List<CollectKeyInfoPK> itemCodeList, int summaryType) { if (itemCodeList == null || itemCodeList.isEmpty()) { m_log.debug("checkTreeCombo() ?"); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.collection.graph.selectdisplayname")); return false; } if (getGraphTypeItem() == SUMMARY_CODE_INVALID) { m_log.debug("checkTreeCombo() ??"); MessageDialog.openInformation(null, Messages.getString("message"), // ???????? Messages.getString("message.collection.graph.select.one.graph.kind.from.the.list")); return false; } if ((getGraphTypeItem() == 6 || getGraphTypeItem() == 7) && itemCodeList.size() < 2) { m_log.debug("checkTreeCombo() ?ID????"); MessageDialog.openInformation(null, Messages.getString("message"), // ?ID??????? Messages.getString("message.collection.graph.must.specify.more.than.two.monitorid.in.scatter")); return false; } if (itemCodeList.size() > 10) { m_log.debug("checkTreeCombo() 10? size:" + itemCodeList.size()); MessageDialog.openInformation(null, Messages.getString("message"), // ????10?????? Messages.getString("message.collection.graph.morethan.selected.monitorid")); return false; } if ((getGraphTypeItem() == 3 || getGraphTypeItem() == 6 || getGraphTypeItem() == 7 || getGraphTypeItem() == 8 || getGraphTypeItem() == 9) && summaryType == SummaryTypeConstant.TYPE_RAW) { // ???????????????? m_log.debug("checkTreeCombo() ???????"); MessageDialog.openInformation(null, Messages.getString("message"), // ?????? Messages.getString("message.collection.graph.do.not.display.in.law")); return false; } m_log.debug("checkTreeCombo() OK."); return true; }
From source file:com.clustercontrol.collect.composite.CollectSettingComposite.java
License:Open Source License
/** * PerformanceGraphComposite???????// w ww .j a v a2 s . c o m * * @param collectKeyList ??? * @param summaryType ??? */ private void drawGraphs(List<CollectKeyInfoPK> collectKeyList, int summaryType, String selectItemName) { List<FacilityTreeItem> treeItemList = m_collectGraphView.getCheckedTreeItemList(); int type = getGraphTypeItem(); boolean totalflg = type == 1 ? false : true; boolean stackflg = type == 3 ? true : false; boolean pieflg = type == 4 || type == 5 ? true : false; totalflg = type == 4 ? false : totalflg; totalflg = type == 5 ? true : totalflg; boolean scatterflg = type == 6 || type == 7 ? true : false; totalflg = type == 6 ? false : totalflg; totalflg = type == 7 ? true : totalflg; boolean barflg = type == 8 || type == 9 ? true : false; totalflg = type == 8 ? false : totalflg; totalflg = type == 9 ? true : totalflg; try { // ????? apply.setEnabled(false); m_collectGraphView.getCollectGraphComposite().drawGraphs(collectKeyList, selectItemName, summaryType, treeItemList, returnButton.getSelection(), returnKindButton.getSelection(), totalflg, stackflg, approximateButton.getSelection(), thresholdButton.getSelection(), pieflg, scatterflg, legendButton.getSelection(), barflg); } catch (InvalidRole_Exception e) { m_log.error("drawGraphs InvalidRole_Exception"); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp(); } catch (InvalidUserPass_Exception e) { m_log.error("drawGraphs InvalidUserPass_Exception"); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.45")); m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp(); } catch (Exception e) { m_log.error("drawGraphs ???? message=" + e.getMessage(), e); MessageDialog.openError(null, Messages.getString("error"), Messages.getString("message.collection.graph.unexpected.error") + " : " + e.getMessage()); m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp(); } finally { // ???? apply.setEnabled(true); } }
From source file:com.clustercontrol.collect.dialog.ExportDialog.java
License:Open Source License
/** * Customize button bar//from w ww . j av a 2 s . c o m */ @Override protected void createButtonsForButtonBar(Composite parent) { // Button exportButton = this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("export"), true); WidgetTestUtil.setTestId(this, "export", exportButton); this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() { private FileDialog saveDialog; @Override public void widgetSelected(SelectionEvent e) { // ???? this.saveDialog = new FileDialog(getShell(), SWT.SAVE); boolean headerFlag = ExportDialog.this.headerCheckbox.getSelection(); //???([summaryType]_.zip?summaryType?) // ?????????????? // ?????ID()? SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); // ???????????(??????) String defaultDateStr = sdf.format(new Date(System.currentTimeMillis())); String defaultFileName = SummaryTypeMessage.typeToStringEN(m_summaryType) + '_' + defaultDateStr; this.saveDialog.setFilterExtensions(new String[] { "*.zip" }); defaultFileName += ".zip"; // ??????+????????????? defaultFileName = defaultFileName.replaceAll(" ", ""); this.saveDialog.setFileName(defaultFileName); String filePath = this.saveDialog.open(); if (filePath != null) { m_log.debug("filePath = " + filePath + ", defaultFileName = " + defaultFileName); output(m_managerFacilityIdNameMap, m_summaryType, m_collectKeyInfoPkList, m_targetManagerFacilityMap, headerFlag, filePath, defaultFileName, defaultDateStr); } } /** * Output */ protected void output(TreeMap<String, String> managerFacilityIdNameMap, Integer summaryType, List<CollectKeyInfoPK> targetCollectKeyInfoList, TreeMap<String, List<String>> targetManagerFacilityMap, boolean headerFlag, String filePath, String fileName, String defaultDateStr) { // DataWriter?? // ??? writer = new RecordDataWriter(managerFacilityIdNameMap, summaryType, targetCollectKeyInfoList, targetManagerFacilityMap, headerFlag, filePath, defaultDateStr); // Download & ??? try { IRunnableWithProgress op = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // ? ServiceContext context = ContextProvider.getContext(); writer.setContext(context); Thread exportThread = new Thread(writer); exportThread.start(); Thread.sleep(3000); monitor.beginTask(Messages.getString("export"), 100); // "?" int progress = 0; int buff = 0; while (progress < 100) { progress = writer.getProgress(); if (monitor.isCanceled()) { throw new InterruptedException(""); } if (writer.isCanceled()) { throw new InterruptedException(writer.getCancelMessage()); } Thread.sleep(50); monitor.worked(progress - buff); buff = progress; } monitor.done(); } }; // ? new ProgressMonitorDialog(getShell()).run(true, true, op); // Start download file if (ClusterControlPlugin.isRAP()) { FileDownloader.openBrowser(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), filePath, fileName); } else { MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.success")); } } catch (InterruptedException e) { // ????? MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.cancel") + " : " + e.getMessage()); } catch (Exception e) { // m_log.warn("output() : " + e.getMessage(), e); MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.cancel") + " : " + e.getMessage() + "(" + e.getClass().getName() + ")"); } finally { writer.setCanceled(true); if (ClusterControlPlugin.isRAP()) { FileDownloader.cleanup(filePath); } } } }); createButton(parent, IDialogConstants.CANCEL_ID, "close", false); }
From source file:com.clustercontrol.composite.FacilityTreeComposite.java
License:Open Source License
/** * //from ww w. ja v a 2 s . c om * @param keyword ? */ public void doSearch(String keyword) { // Check and format keyword if (null == keyword) { return; } keyword = keyword.trim(); if (keyword.isEmpty()) { return; } StructuredSelection selection = (StructuredSelection) treeViewer.getSelection(); Object targetItem = selection.getFirstElement(); FacilityTreeItem result = searchItem( (FacilityTreeItem) (null != targetItem ? targetItem : treeViewer.getInput()), keyword); if (null != result) { FacilityTreeItem trace = result; LinkedList<FacilityTreeItem> pathList = new LinkedList<>(); do { pathList.addFirst(trace); trace = trace.getParent(); } while (null != trace); TreePath path = new TreePath(pathList.toArray(new FacilityTreeItem[] {})); treeViewer.setSelection(new TreeSelection(path), true); } else { MessageDialog.openInformation(this.getShell(), Messages.getString("message"), Messages.getString("search.not.found")); treeViewer.setSelection( new StructuredSelection(((FacilityTreeItem) treeViewer.getInput()).getChildren().get(0)), true); } }
From source file:com.clustercontrol.composite.RoleIdListComposite.java
License:Open Source License
/** * ????<BR>/* w ww . ja v a 2 s. co m*/ * <p> * */ public void createRoleIdList(String managerName) { List<String> list = null; // ? try { AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); list = wrapper.getOwnerRoleIdList(); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (Exception e) { // ? m_log.warn("update(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } if (list != null) { String roleIdOld = this.comboRoleId.getText(); // this.comboRoleId.removeAll(); // ID if (m_mode.equals(Mode.ROLE)) { this.comboRoleId.add(""); } for (String roleId : list) { this.comboRoleId.add(roleId); } int defaultSelect = this.comboRoleId.indexOf(roleIdOld); if (defaultSelect == -1) { defaultSelect = this.comboRoleId.indexOf(RoleIdConstant.ALL_USERS); } this.comboRoleId.select((-1 == defaultSelect) ? 0 : defaultSelect); } }
From source file:com.clustercontrol.custom.dialog.MonitorCustomDialog.java
License:Open Source License
/** * ???<br/>/* w ww . j av a 2 s. co m*/ * * @param parent ??? */ @Override protected void customizeDialog(Composite parent) { // Local Variables Label label = null; // ???? GridData gridData = null; // ???? // MAIN // ??? item1 = Messages.getString("select.value"); item2 = Messages.getString("select.value"); super.customizeDialog(parent); // ? shell.setText(Messages.getString("dialog.monitor.custom.edit")); // ?? Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule); groupCheckRule.setText(Messages.getString("check.rule")); GridLayout layout = new GridLayout(15, true); layout.marginWidth = HALF_MARGIN; layout.marginHeight = HALF_MARGIN; groupCheckRule.setLayout(layout); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = BASIC_UNIT; groupCheckRule.setLayoutData(gridData); // checkbox?(???) this.checkSelected = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "selectedCheck", checkSelected); this.checkSelected.setText(Messages.getString("monitor.custom.type.selected")); this.checkSelected.setToolTipText(Messages.getString("monitor.custom.type.selected.tips")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 8; checkSelected.setLayoutData(gridData); checkSelected.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.getSource(); if (button.getSelection()) { textNode.setEnabled(true); buttonNode.setEnabled(true); } else { textNode.setEnabled(false); buttonNode.setEnabled(false); } update(); } }); // ??? this.textNode = new Text(groupCheckRule, SWT.BORDER | SWT.CENTER | SWT.READ_ONLY); WidgetTestUtil.setTestId(this, "nodetext", textNode); this.textNode.setText(""); this.textNode.setMessage(Messages.getString("monitor.custom.node.selected")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 5; this.textNode.setLayoutData(gridData); this.textNode.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); ; this.buttonNode = new Button(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "node", buttonNode); this.buttonNode.setText(Messages.getString("refer")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 2; this.buttonNode.setLayoutData(gridData); this.buttonNode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String managerName = getMonitorBasicScope().getManagerListComposite().getText(); ScopeTreeDialog dialog = new ScopeTreeDialog(shell, managerName, getMonitorBasicScope().getOwnerRoleId(), false, false); dialog.setSelectNodeOnly(true); if (dialog.open() == IDialogConstants.OK_ID) { FacilityTreeItem item = dialog.getSelectItem(); FacilityInfo info = item.getData(); nodeFacilityId = info.getFacilityId(); if (info.getFacilityType() == FacilityConstant.TYPE_NODE) { textNode.setText(info.getFacilityName()); } else { FacilityPath path = new FacilityPath(ClusterControlPlugin.getDefault().getSeparator()); textNode.setText(path.getPath(item)); } } } }); // ?? Group groupEffectiveUser = new Group(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "effectiveuser", groupEffectiveUser); groupEffectiveUser.setText(Messages.getString("effective.user")); layout = new GridLayout(15, true); layout.marginWidth = HALF_MARGIN; layout.marginHeight = HALF_MARGIN; groupEffectiveUser.setLayout(layout); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 15; groupEffectiveUser.setLayoutData(gridData); this.buttonAgentUser = new Button(groupEffectiveUser, SWT.RADIO); WidgetTestUtil.setTestId(this, "agentuser", buttonAgentUser); this.buttonAgentUser.setText(Messages.getString("agent.user")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = SMALL_UNIT; this.buttonAgentUser.setLayoutData(gridData); this.buttonAgentUser.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { Button check = (Button) e.getSource(); if (check.getSelection()) { buttonSpecifyUser.setSelection(false); textEffectiveUser.setEnabled(false); } update(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); this.buttonSpecifyUser = new Button(groupEffectiveUser, SWT.RADIO); WidgetTestUtil.setTestId(this, "specifyuser", buttonSpecifyUser); this.buttonSpecifyUser.setText(Messages.getString("specified.user")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = WIDTH_TEXT_SHORT; this.buttonSpecifyUser.setLayoutData(gridData); this.buttonSpecifyUser.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { Button check = (Button) e.getSource(); if (check.getSelection()) { buttonAgentUser.setSelection(false); textEffectiveUser.setEnabled(true); } update(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); this.textEffectiveUser = new Text(groupEffectiveUser, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "effectiveuser", textEffectiveUser); this.textEffectiveUser.setText(""); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = HALF_UNIT - (SMALL_UNIT + WIDTH_TEXT_SHORT); this.textEffectiveUser.setLayoutData(gridData); this.textEffectiveUser.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "customcommand", label); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); label.setText(Messages.getString("monitor.custom.command") + " : "); gridData.horizontalSpan = WIDTH_TITLE; label.setLayoutData(gridData); this.textCommand = new TextWithParameterComposite(groupCheckRule, SWT.BORDER | SWT.LEFT | SWT.SINGLE); WidgetTestUtil.setTestId(this, "commnad", textCommand); this.textCommand.setText(""); this.textCommand.setToolTipText(Messages.getString("monitor.custom.commandline.tips")); this.textCommand.setColor(new Color(parent.getDisplay(), new RGB(0, 0, 255))); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 11; this.textCommand.setLayoutData(gridData); this.textCommand.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); ; /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "timeout", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("time.out") + " : "); // this.m_textTimeout = new Text(groupCheckRule, SWT.BORDER); WidgetTestUtil.setTestId(this, "timeout", m_textTimeout); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textTimeout.setLayoutData(gridData); this.m_textTimeout.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ?? label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "millisec", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("milli.sec")); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "blank", label); gridData = new GridData(); gridData.horizontalSpan = 5; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); /* * ?? */ // label = new Label(groupCheckRule, SWT.NONE); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("convert.value") + " : "); // this.m_comboConvertValue = new Combo(groupCheckRule, SWT.DROP_DOWN | SWT.READ_ONLY); WidgetTestUtil.setTestId(this, "convertvalue", m_comboConvertValue); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_SHORT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_comboConvertValue.setLayoutData(gridData); this.m_comboConvertValue.add(ConvertValueMessage.STRING_NO); this.m_comboConvertValue.add(ConvertValueMessage.STRING_DELTA); // ??? this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ???? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ?? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); info = wrapper.getMonitor(this.monitorId); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); return; } catch (Exception e) { // ? m_log.warn("customizeDialog() getMonitor, " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); return; } } this.setInputData(info); update(); }
From source file:com.clustercontrol.custom.dialog.MonitorCustomDialog.java
License:Open Source License
/** * ?????/*www . ja v a 2 s . c o m*/ * * @param monitor * ???? */ @Override protected void setInputData(MonitorInfo monitor) { super.setInputData(monitor); this.inputData = monitor; // ? CustomCheckInfo customInfo = monitor.getCustomCheckInfo(); if (customInfo == null) { customInfo = new CustomCheckInfo(); customInfo.setTimeout(TIMEOUT_SEC_COMMAND); this.checkSelected.setSelection(false); this.textNode.setEnabled(false); this.buttonNode.setEnabled(false); this.buttonAgentUser.setSelection(true); this.buttonSpecifyUser.setSelection(false); this.textEffectiveUser.setEnabled(false); this.m_comboConvertValue.setText(ConvertValueMessage.typeToString(ConvertValueConstant.TYPE_NO)); } else { if (customInfo.getCommandExecType() == CommandExecType.INDIVIDUAL) { this.checkSelected.setSelection(false); } else { this.checkSelected.setSelection(true); this.nodeFacilityId = customInfo.getSelectedFacilityId(); String facilityPath = null; String managerName = this.getManagerName(); try { RepositoryEndpointWrapper wrapper = RepositoryEndpointWrapper.getWrapper(managerName); facilityPath = wrapper.getFacilityPath(this.nodeFacilityId, null); } catch (com.clustercontrol.ws.repository.InvalidRole_Exception e) { // ????????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (Exception e) { // ? m_log.warn("setInputData() getFacilityPath, " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } this.textNode.setText(facilityPath); } if (customInfo.isSpecifyUser().booleanValue()) { this.buttonAgentUser.setSelection(false); this.buttonSpecifyUser.setSelection(true); this.textEffectiveUser.setEnabled(true); } else { this.buttonAgentUser.setSelection(true); this.buttonSpecifyUser.setSelection(false); this.textEffectiveUser.setEnabled(false); } this.textEffectiveUser.setText(customInfo.getEffectiveUser()); this.textCommand.setText(customInfo.getCommand()); this.m_comboConvertValue.setText(ConvertValueMessage.typeToString(customInfo.getConvertFlg())); } this.m_textTimeout.setText(Integer.toString(customInfo.getTimeout())); m_numericValueInfo.setInputData(monitor); }
From source file:com.clustercontrol.custom.dialog.MonitorCustomDialog.java
License:Open Source License
/** * ?????<br/>// w w w . j a v a2 s. c o m * * @return ????????true, ????false */ @Override protected boolean action() { boolean result = false; MonitorInfo info = this.inputData; String managerName = this.getManagerName(); if (info != null) { String[] args = { info.getMonitorId(), managerName }; MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); if (!this.updateFlg) { // ???? try { result = wrapper.addMonitor(info); if (result) { // ??????? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.monitor.33", args)); } else { // ?????? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.34", args)); } } catch (MonitorDuplicate_Exception e) { // ??ID????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.monitor.53", args)); } catch (Exception e) { String errMessage = ""; if (e instanceof InvalidRole_Exception) { // ????????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } else { errMessage = ", " + HinemosMessage.replace(e.getMessage()); } // ?????? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.34", args) + errMessage); } } else { // ?? String errMessage = ""; try { result = wrapper.modifyMonitor(info); } catch (InvalidRole_Exception e) { // ????????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (Exception e) { errMessage = ", " + HinemosMessage.replace(e.getMessage()); } if (result) { // ??????? MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.monitor.35", args)); } else { // ?????? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.36", args) + errMessage); } } } return result; }
From source file:com.clustercontrol.custom.dialog.MonitorStringCustomDialog.java
License:Open Source License
/** * ???<br/>/*from ww w. ja v a 2 s . c o m*/ * * @param parent ??? */ @Override protected void customizeDialog(Composite parent) { // Local Variables Label label = null; // ???? GridData gridData = null; // ???? // MAIN super.customizeDialog(parent); // ? shell.setText(Messages.getString("dialog.monitor.custom.edit")); // ?? Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule); groupCheckRule.setText(Messages.getString("check.rule")); GridLayout layout = new GridLayout(15, true); layout.marginWidth = HALF_MARGIN; layout.marginHeight = HALF_MARGIN; groupCheckRule.setLayout(layout); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = BASIC_UNIT; groupCheckRule.setLayoutData(gridData); // checkbox?(???) this.checkSelected = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "selectedCheck", checkSelected); this.checkSelected.setText(Messages.getString("monitor.custom.type.selected")); this.checkSelected.setToolTipText(Messages.getString("monitor.custom.type.selected.tips")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 8; checkSelected.setLayoutData(gridData); checkSelected.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.getSource(); if (button.getSelection()) { textNode.setEnabled(true); buttonNode.setEnabled(true); } else { textNode.setEnabled(false); buttonNode.setEnabled(false); } update(); } }); // ??? this.textNode = new Text(groupCheckRule, SWT.BORDER | SWT.CENTER | SWT.READ_ONLY); WidgetTestUtil.setTestId(this, "nodetext", textNode); this.textNode.setText(""); this.textNode.setMessage(Messages.getString("monitor.custom.node.selected")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 5; this.textNode.setLayoutData(gridData); this.textNode.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); ; this.buttonNode = new Button(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "node", buttonNode); this.buttonNode.setText(Messages.getString("refer")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 2; this.buttonNode.setLayoutData(gridData); this.buttonNode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String managerName = getMonitorBasicScope().getManagerListComposite().getText(); ScopeTreeDialog dialog = new ScopeTreeDialog(shell, managerName, getMonitorBasicScope().getOwnerRoleId(), false, false); dialog.setSelectNodeOnly(true); if (dialog.open() == IDialogConstants.OK_ID) { FacilityTreeItem item = dialog.getSelectItem(); FacilityInfo info = item.getData(); nodeFacilityId = info.getFacilityId(); if (info.getFacilityType() == FacilityConstant.TYPE_NODE) { textNode.setText(info.getFacilityName()); } else { FacilityPath path = new FacilityPath(ClusterControlPlugin.getDefault().getSeparator()); textNode.setText(path.getPath(item)); } } } }); // ?? Group groupEffectiveUser = new Group(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "effectiveuser", groupEffectiveUser); groupEffectiveUser.setText(Messages.getString("effective.user")); layout = new GridLayout(15, true); layout.marginWidth = HALF_MARGIN; layout.marginHeight = HALF_MARGIN; groupEffectiveUser.setLayout(layout); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 15; groupEffectiveUser.setLayoutData(gridData); this.buttonAgentUser = new Button(groupEffectiveUser, SWT.RADIO); WidgetTestUtil.setTestId(this, "agentuser", buttonAgentUser); this.buttonAgentUser.setText(Messages.getString("agent.user")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = SMALL_UNIT; this.buttonAgentUser.setLayoutData(gridData); this.buttonAgentUser.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { Button check = (Button) e.getSource(); if (check.getSelection()) { buttonSpecifyUser.setSelection(false); textEffectiveUser.setEnabled(false); } update(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); this.buttonSpecifyUser = new Button(groupEffectiveUser, SWT.RADIO); WidgetTestUtil.setTestId(this, "specifyuser", buttonSpecifyUser); this.buttonSpecifyUser.setText(Messages.getString("specified.user")); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = WIDTH_TEXT_SHORT; this.buttonSpecifyUser.setLayoutData(gridData); this.buttonSpecifyUser.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { Button check = (Button) e.getSource(); if (check.getSelection()) { buttonAgentUser.setSelection(false); textEffectiveUser.setEnabled(true); } update(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); this.textEffectiveUser = new Text(groupEffectiveUser, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "effectiveuser", textEffectiveUser); this.textEffectiveUser.setText(""); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = HALF_UNIT - (SMALL_UNIT + WIDTH_TEXT_SHORT); this.textEffectiveUser.setLayoutData(gridData); this.textEffectiveUser.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "customcommand", label); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); label.setText(Messages.getString("monitor.custom.command") + " : "); gridData.horizontalSpan = WIDTH_TITLE; label.setLayoutData(gridData); this.textCommand = new TextWithParameterComposite(groupCheckRule, SWT.BORDER | SWT.LEFT | SWT.SINGLE); WidgetTestUtil.setTestId(this, "commnad", textCommand); this.textCommand.setText(""); this.textCommand.setToolTipText(Messages.getString("monitor.custom.commandline.tips")); this.textCommand.setColor(new Color(parent.getDisplay(), new RGB(0, 0, 255))); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 11; this.textCommand.setLayoutData(gridData); this.textCommand.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); ; /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "timeout", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("time.out") + " : "); // this.m_textTimeout = new Text(groupCheckRule, SWT.BORDER); WidgetTestUtil.setTestId(this, "timeout", m_textTimeout); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textTimeout.setLayoutData(gridData); this.m_textTimeout.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ?? label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "millisec", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("milli.sec")); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "blank", label); gridData = new GridData(); gridData.horizontalSpan = 5; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); // ??? this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ???? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ?? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); info = wrapper.getMonitor(this.monitorId); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); return; } catch (Exception e) { // ? m_log.warn("customizeDialog() getMonitor, " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); return; } } this.setInputData(info); update(); }