List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle openInformation
public static MessageDialogWithToggle openInformation(Shell parent, String title, String message, String toggleMessage, boolean toggleState, IPreferenceStore store, String key)
From source file:com.aptana.ide.core.ui.DialogUtils.java
License:Open Source License
/** * openIgnoreMessageDialogInformation/*from www . j a v a2 s .c om*/ * * @param shell * @param title * @param message * @param store * @param key * @return int */ public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, IPreferenceStore store, String key) { if (!store.getString(key).equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle d = MessageDialogWithToggle.openInformation(shell, title, message, Messages.DialogUtils_HideThisMessageInFuture, false, store, key); if (d.getReturnCode() == 3) { return MessageDialog.CANCEL; } else { return MessageDialog.OK; } } else { return MessageDialog.OK; } }
From source file:com.aptana.ui.DialogUtils.java
License:Open Source License
/** * openIgnoreMessageDialogInformation// w w w. j av a2s. co m * * @param shell * @param title * @param message * @param store * @param key * @return int */ public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, IPreferenceStore store, String key) { if (!store.getString(key).equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle d = MessageDialogWithToggle.openInformation(shell, title, message, Messages.DialogUtils_HideMessage, false, store, key); if (d.getReturnCode() == 3) { return MessageDialog.CANCEL; } } return MessageDialog.OK; }
From source file:com.aptana.ui.DialogUtils.java
License:Open Source License
/** * Conditionally open an information message dialog. In case this is the first time this dialog is opened (defined * by its key), the dialog will be displayed, and a "Do not show this message again" checkbox will be available. The * message dialog will not be opened again when the checkbox is selected.<br> * Once checked, the only way to display this dialog again is by resetting the messaged through the Studio's main * preference page./* w ww . j a va2 s . c o m*/ * * @param shell * @param title * @param message * @param dialogKey * A dialog key that will be checked to confirm if the dialog should be diaplayed. * @return The dialog's return code. */ public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, String dialogKey) { final IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(UIEplPlugin.PLUGIN_ID); String[] keys = prefs.get(IEplPreferenceConstants.HIDDEN_MESSAGES, StringUtil.EMPTY).split(","); //$NON-NLS-1$ Set<String> keysSet = CollectionsUtil.newSet(keys); if (keysSet.contains(dialogKey)) { return MessageDialog.CANCEL; } MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(shell, title, message, Messages.DialogUtils_doNotShowMessageAgain, false, null, null); if (dialog.getReturnCode() == Dialog.OK) { // check the toggle state to see if we need to add the dialog key to the list of hidden dialogs. if (dialog.getToggleState()) { keysSet.add(dialogKey); prefs.put(IEplPreferenceConstants.HIDDEN_MESSAGES, StringUtil.join(",", keysSet)); //$NON-NLS-1$ try { prefs.flush(); } catch (Exception e) { IdeLog.logError(UIPlugin.getDefault(), e); } } } return dialog.getReturnCode(); }
From source file:com.centurylink.mdw.plugin.server.JavaSourceHyperlink.java
License:Apache License
/** * find the source element in the project * * @param type// www .j a v a2 s .c o m * @return the source element * @throws JavaModelException * @throws CoreException */ protected Object getJavaElement(String type) throws JavaModelException, CoreException { Object element = null; if (project == null) { cantFindSourceWarning(); return null; } if (element == null) { QualifiedName qName = new QualifiedName(MdwPlugin.getPluginId(), "MdwSourceLookupAllJavaProjects"); String setting = project.getProject().getPersistentProperty(qName); boolean check = (setting != null && Boolean.valueOf(setting)); if (!check) { String msg = "Can't locate source code for:\n" + getTypeName() + (project == null ? "" : " in project " + project.getProject().getName()); String toggleMessage = "Look in all workspace Java projects for this deployment."; MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(MdwPlugin.getShell(), "Java Source Lookup", msg, toggleMessage, false, null, null); check = dialog.getToggleState(); project.getProject().setPersistentProperty(qName, String.valueOf(check)); } if (check) { IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); for (IJavaProject javaProj : javaModel.getJavaProjects()) { Object javaElem = getJavaElement(javaProj, type); if (javaElem != null) { element = javaElem; break; } } } } return element; }
From source file:com.centurylink.mdw.plugin.workspace.ArtifactResourceListener.java
License:Apache License
public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) { IResourceDelta rootDelta = event.getDelta(); IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath()); if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) { // the file has been changed final Display display = Display.getCurrent(); if (display != null) { display.syncExec(new Runnable() { public void run() { byte[] newValue = PluginUtil.readFile(tempFile); String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue); if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) { WorkflowProcess processVersion = null; if (getElement() instanceof Activity) { Activity activity = (Activity) getElement(); activity.setAttribute(valueProvider.getAttributeName(), attrVal); processVersion = activity.getProcess(); } else { processVersion = (WorkflowProcess) getElement(); processVersion.setAttribute(valueProvider.getAttributeName(), attrVal); }/* w w w.j ava 2 s. com*/ processVersion.fireDirtyStateChanged(true); ProcessEditor processEditor = findProcessEditor(processVersion); if (processEditor == null) { try { processEditor = openProcessEditor(processVersion); IEditorPart tempFileEditor = findTempFileEditor(tempFile); if (tempFileEditor != null) processEditor.addActiveScriptEditor(tempFileEditor); } catch (PartInitException ex) { PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject()); return; } } processVersion = processEditor.getProcess(); if (processVersion.isReadOnly()) { WorkflowProject workflowProject = getElement().getProject(); PluginMessages.uiMessage( "Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE); return; } if (getElement() instanceof Activity) { Activity activity = (Activity) getElement(); // the activity the attribute was set on // above may be a holdover from a // previously-opened process version for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage() .getProcess().nodes) { if (activity.getLogicalId() != null && activity.getLogicalId() .equals(node.getAttribute("LOGICAL_ID"))) { node.setAttribute(valueProvider.getAttributeName(), attrVal); ActivityImpl actImpl = processVersion.getProject() .getActivityImpl(node.nodet.getImplementorClassName()); element = new Activity(node, processVersion, actImpl); } } activity.fireDirtyStateChanged(true); } processEditor.dirtyStateChanged(true); valueProvider.afterTempFileSaved(); // process editor is open String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted."; String toggleMessage = "Don't show me this message again."; IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore(); String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag"; if (!prefsStore.getBoolean(prefsKey)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation( display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null); prefsStore.setValue(prefsKey, dialog.getToggleState()); } } } }); } } } }
From source file:com.clustercontrol.approval.composite.ApprovalComposite.java
License:Open Source License
public void update(Property property) { condition = property;/*from w w w .j av a2 s . c o m*/ List<JobApprovalInfo> infoList = null; Map<String, List<JobApprovalInfo>> dispDataMap = new ConcurrentHashMap<String, List<JobApprovalInfo>>(); Map<String, String> errorMsgs = new ConcurrentHashMap<>(); String conditionManager = null; JobApprovalFilter filter = null; int total = 0; int limit = ClusterControlPlugin.getDefault().getPreferenceStore() .getInt(ApprovalPreferencePage.P_APPROVAL_MAX_LIST); if (condition != null) { conditionManager = getManagerName(condition); filter = property2jobApprovalFilter(condition); } else { // ?????????????? filter = new JobApprovalFilter(); filter.getStatusList().add(JobApprovalStatusConstant.TYPE_PENDING); } // ?? for (String managerName : EndpointManager.getActiveManagerSet()) { try { if (conditionManager != null && !conditionManager.equals(managerName)) { continue; } JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName); infoList = wrapper.getApprovalJobList(filter, limit); } catch (InvalidRole_Exception e) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } catch (Exception e) { // ? m_log.warn("update(), " + e.getMessage(), e); errorMsgs.put(managerName, Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } if (infoList != null) { dispDataMap.put(managerName, infoList); total += infoList.size(); } } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } if (ClusterControlPlugin.getDefault().getPreferenceStore() .getBoolean(ApprovalPreferencePage.P_APPROVAL_MESSAGE_FLG)) { if (total > limit) { if (ClientSession.isDialogFree()) { ClientSession.occupyDialog(); // ???? MessageDialogWithToggle.openInformation(null, Messages.getString("message"), Messages.getString("message.approval.7"), Messages.getString("message.will.not.be.displayed"), false, ClusterControlPlugin.getDefault().getPreferenceStore(), ApprovalPreferencePage.P_APPROVAL_MESSAGE_FLG); ClientSession.freeDialog(); } } } //??? List<JobApprovalInfo> infolist = dispDataMap2SortedList(dispDataMap, limit); // JobApprovalInfo tableViewer ??????? ArrayList<Object> listInput = new ArrayList<Object>(); for (JobApprovalInfo info : infolist) { ArrayList<Object> obj = new ArrayList<Object>(); obj.add(info.getMangerName()); obj.add(info.getStatus()); obj.add(info.getResult()); obj.add(info.getSessionId()); obj.add(info.getJobunitId()); obj.add(info.getJobId()); obj.add(info.getJobName()); obj.add(info.getRequestUser()); obj.add(info.getApprovalUser()); obj.add(info.getStartDate() == null ? "" : new Date(info.getStartDate())); obj.add(info.getEndDate() == null ? "" : new Date(info.getEndDate())); obj.add(info.getRequestSentence()); obj.add(info.getComment()); obj.add(null); listInput.add(obj); } tableViewer.setInput(listInput); selectList(listInput); Integer count = listInput.size(); Object[] args = null; args = new Object[] { count.toString() }; if (condition != null) { labelType.setText(Messages.getString("filtered.list")); labelCount.setText(Messages.getString("filtered.records", args)); } else { labelType.setText(""); labelCount.setText(Messages.getString("records", args)); } }
From source file:com.clustercontrol.jobmanagement.composite.HistoryComposite.java
License:Open Source License
/** * ???<BR>//from w w w . j a v a 2 s . co m * ????????????? * <p> * <ol> * <li>???[]?????</li> * <li>???????????</li> * <li>??????</li> * <li>????</li> * </ol> * * @param condition ? * * @see com.clustercontrol.jobmanagement.action.GetHistory#getHistory(Property, int) * @see #selectHistory(ArrayList) */ public void update(Property condition) { Map<String, JobHistoryList> dispDataMap = new ConcurrentHashMap<String, JobHistoryList>(); //? Map<String, String> errorMsgs = new ConcurrentHashMap<>(); int total = 0; int size = 0; String conditionManager = null; if (condition != null) { conditionManager = JobPropertyUtil.getManagerName(condition); } if (conditionManager == null || conditionManager.equals("")) { for (String managerName : EndpointManager.getActiveManagerSet()) { int[] ret = getHistoryList(managerName, condition, dispDataMap, errorMsgs); total += ret[0]; size += ret[1]; } } else { int[] ret = getHistoryList(conditionManager, condition, dispDataMap, errorMsgs); total = ret[0]; size = ret[1]; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } if (ClusterControlPlugin.getDefault().getPreferenceStore() .getBoolean(JobManagementPreferencePage.P_HISTORY_MESSAGE_FLG)) { if (total > size) { if (ClientSession.isDialogFree()) { ClientSession.occupyDialog(); // ???? MessageDialogWithToggle.openInformation(null, Messages.getString("message"), Messages.getString("message.job.33"), Messages.getString("message.will.not.be.displayed"), false, ClusterControlPlugin.getDefault().getPreferenceStore(), JobManagementPreferencePage.P_HISTORY_MESSAGE_FLG); ClientSession.freeDialog(); } } } List<JobHistory> historyList = jobHistoryDataMap2SortedList(dispDataMap); size = historyList.size(); ArrayList<Object> listInput = new ArrayList<Object>(); for (JobHistory history : historyList) { ArrayList<Object> a = new ArrayList<Object>(); a.add(history.getManagerName()); a.add(history.getStatus()); a.add(history.getEndStatus()); a.add(history.getEndValue()); a.add(history.getSessionId()); m_log.trace("sessionId=" + history.getSessionId()); a.add(history.getJobId()); a.add(history.getJobName()); a.add(history.getJobunitId()); a.add(history.getJobType()); a.add(history.getFacilityId()); a.add(HinemosMessage.replace(history.getScope())); a.add(history.getOwnerRoleId()); a.add(history.getScheduleDate() == null ? "" : new Date(history.getScheduleDate())); a.add(history.getStartDate() == null ? "" : new Date(history.getStartDate())); a.add(history.getEndDate() == null ? "" : new Date(history.getEndDate())); a.add(TimeToANYhourConverter.toDiffTime(history.getStartDate(), history.getEndDate())); a.add(JobTriggerTypeMessage.typeToString(history.getJobTriggerType())); a.add(history.getTriggerInfo()); a.add(null); listInput.add(a); } m_viewer.setInput(listInput); selectHistory(listInput); if (condition != null) { m_labelType.setText(Messages.getString("filtered.list")); Object[] args = null; if (total > size) { args = new Object[] { size }; } else { args = new Object[] { total }; } m_labelCount.setText(Messages.getString("filtered.records", args)); } else { // (??????????) m_labelType.setText(""); Object[] args = null; if (total > size) { args = new Object[] { size }; } else { args = new Object[] { total }; } m_labelCount.setText(Messages.getString("records", args)); } }
From source file:com.clustercontrol.monitor.composite.EventListComposite.java
License:Open Source License
public void updateDisp(boolean refreshFlag) { super.update(); Map<String, String> errorMsgs = new ConcurrentHashMap<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); sdf.setTimeZone(TimezoneUtil.getTimeZone()); label = Messages.getString("search.from") + ":"; boolean flag = false; for (Entry<String, ViewListInfo> entry : dispDataMap.entrySet()) { if (flag) { label += ", "; }//from w w w . j av a2s.c o m ViewListInfo info = entry.getValue(); if (info.getFromOutputDate() == null) { label += "ALL"; } else { Date fromDate = new Date(info.getFromOutputDate()); label += sdf.format(fromDate); } label += "(" + entry.getKey() + ")"; flag = true; } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } List<EventDataInfo> eventListRaw = ConvertListUtil.eventLogDataMap2SortedList(dispDataMap); ArrayList<ArrayList<Object>> eventList = ConvertListUtil.eventLogList2Input(eventListRaw); int total = 0; for (Map.Entry<String, ViewListInfo> entrySet : dispDataMap.entrySet()) { total += entrySet.getValue().getTotal(); } boolean newEventFlg = false; // ??? if (refreshFlag) { Date tableOutputDate = null; Date takenOutputDate = null; if (!eventListRaw.isEmpty()) { tableOutputDate = new Date(eventListRaw.get(0).getOutputDate()); } // ???????? Table table = this.getTable(); Date tempOutputDate = null; if (table.getItems().length != 0) { TableItem[] takenOutputTableItems = table.getItems(); for (int i = 0; i < takenOutputTableItems.length; i++) { @SuppressWarnings("unchecked") List<Object> list = (ArrayList<Object>) table.getItems()[i].getData(); tempOutputDate = (Date) list.get(GetEventListTableDefine.RECEIVE_TIME); if (takenOutputDate == null || tempOutputDate.after(takenOutputDate)) { takenOutputDate = tempOutputDate; } } // ???????? if (tableOutputDate != null && takenOutputDate != null && tableOutputDate.after(takenOutputDate)) { newEventFlg = true; } } } if (ClusterControlPlugin.getDefault().getPreferenceStore() .getBoolean(MonitorPreferencePage.P_EVENT_MESSAGE_FLG) && total > eventList.size() && ClientSession.isDialogFree()) { ClientSession.occupyDialog(); // ???? MessageDialogWithToggle.openInformation(null, Messages.getString("message"), Messages.getString("message.monitor.12"), Messages.getString("message.will.not.be.displayed"), false, ClusterControlPlugin.getDefault().getPreferenceStore(), MonitorPreferencePage.P_EVENT_MESSAGE_FLG); ClientSession.freeDialog(); } if (ClusterControlPlugin.getDefault().getPreferenceStore() .getBoolean(MonitorPreferencePage.P_EVENT_NEW_EVENT_FLG) && refreshFlag && newEventFlg && ClientSession.isDialogFree()) { ClientSession.occupyDialog(); // ???????? IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Shell shell = null; if (window != null) { shell = window.getShell(); shell.forceActive(); } // ???????????? MessageDialogWithToggle.openInformation(shell, Messages.getString("message"), Messages.getString("message.monitor.84"), Messages.getString("message.will.not.be.displayed"), false, ClusterControlPlugin.getDefault().getPreferenceStore(), MonitorPreferencePage.P_EVENT_NEW_EVENT_FLG); ClientSession.freeDialog(); } this.updateStatus(eventListRaw); tableViewer.setInput(eventList); }
From source file:com.clustercontrol.monitor.composite.StatusListComposite.java
License:Open Source License
public void updateDisp(boolean refreshFlg) { super.update(); ArrayList<ArrayList<Object>> statusList = ConvertListUtil.statusInfoData2List(dispDataMap); boolean statusChengedFlg = false; if (refreshFlg) { // ???//from ww w. j a v a 2s . c om Map<StatusKey, Integer> newStatusMap = new HashMap<>(); for (ArrayList<Object> newStatus : statusList) { StatusKey key = new StatusKey(newStatus.get(GetStatusListTableDefine.FACILITY_ID).toString(), newStatus.get(GetStatusListTableDefine.MONITOR_ID).toString(), newStatus.get(GetStatusListTableDefine.MONITOR_DETAIL_ID).toString(), (newStatus.get(GetStatusListTableDefine.PLUGIN_ID).toString())); newStatusMap.put(key, (Integer) newStatus.get(GetStatusListTableDefine.PRIORITY)); } // ??????? Object obj = this.getTableViewer().getInput(); Map<StatusKey, Integer> oldStatusMap = new HashMap<>(); if (obj != null) { @SuppressWarnings("unchecked") List<ArrayList<?>> oldStatusList = (ArrayList<ArrayList<?>>) obj; for (ArrayList<?> oldStatus : oldStatusList) { StatusKey oldKey = new StatusKey(oldStatus.get(GetStatusListTableDefine.FACILITY_ID).toString(), oldStatus.get(GetStatusListTableDefine.MONITOR_ID).toString(), oldStatus.get(GetStatusListTableDefine.MONITOR_DETAIL_ID).toString(), oldStatus.get(GetStatusListTableDefine.PLUGIN_ID).toString()); oldStatusMap.put(oldKey, (Integer) oldStatus.get(GetStatusListTableDefine.PRIORITY)); } } // ????????? for (Map.Entry<StatusKey, Integer> newStatusKey : newStatusMap.entrySet()) { Integer tableStatus = oldStatusMap.get(newStatusKey.getKey()); if (!newStatusKey.getValue().equals(tableStatus)) { statusChengedFlg = true; break; } } } if (ClusterControlPlugin.getDefault().getPreferenceStore() .getBoolean(MonitorPreferencePage.P_STATUS_NEW_STATE_FLG) && refreshFlg && statusChengedFlg) { if (ClientSession.isDialogFree()) { ClientSession.occupyDialog(); // ???????? IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Shell shell = null; if (window != null) { shell = window.getShell(); shell.forceActive(); } // ???????????? MessageDialogWithToggle.openInformation(shell, Messages.getString("message"), Messages.getString("message.monitor.85"), Messages.getString("message.will.not.be.displayed"), false, ClusterControlPlugin.getDefault().getPreferenceStore(), MonitorPreferencePage.P_STATUS_NEW_STATE_FLG); ClientSession.freeDialog(); } } this.updateStatus(statusList); tableViewer.setInput(statusList); }
From source file:com.genuitec.org.eclipse.egit.ui.internal.branch.BranchOperationUI.java
License:Open Source License
private void showDetachedHeadWarning() { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (store.getBoolean(UIPreferences.SHOW_DETACHED_HEAD_WARNING)) { String toggleMessage = UIText.BranchResultDialog_DetachedHeadWarningDontShowAgain; MessageDialogWithToggle.openInformation( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), UIText.BranchOperationUI_DetachedHeadTitle, UIText.BranchOperationUI_DetachedHeadMessage, toggleMessage, false, store, UIPreferences.SHOW_DETACHED_HEAD_WARNING); }/*from ww w.ja va 2 s . com*/ } }); }