List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:net.rim.ejde.internal.signing.ImportSignKeysAction.java
License:Open Source License
@Override public void run(IAction action) { // Open file dialog to allow user select the parent folder of *.csk and *.db files SigningSearchDialog oldKeyDialog = new SigningSearchDialog(ContextManager.getActiveWorkbenchShell()); try {/*w w w . j a va2 s . c o m*/ ArrayList<File> oldKeyFiles = oldKeyDialog.search(); if (oldKeyFiles != null) { oldKeyDialog.copyFileIntoSignToolDir(oldKeyFiles); MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, Messages.CodeSigningPrefsPage_MessageDialogMsg1, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg9); } } catch (IllegalArgumentException ex) { MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, ex.getMessage(), MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } }
From source file:net.rim.ejde.internal.signing.RemoveSignKeysAction.java
License:Open Source License
private void removeKeys() { try {/* www.j a v a2s .c o m*/ File cskFile = new File( VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME); File dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME); if ((!cskFile.exists()) && (!dbFile.exists())) { MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3, null, Messages.CodeSigningPrefsPage_MessageDialogMsg3, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); return; } if (cskFile.exists()) { cskFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis())); } if (dbFile.exists()) { dbFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis())); } if ((!cskFile.exists()) && (!dbFile.exists())) { MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3, null, Messages.CodeSigningPrefsPage_MessageDialogMsg5 + Messages.CodeSigningPrefsPage_MessageDialogMsg6, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg7); } } catch (IOException e) { _log.error(e.getMessage()); } }
From source file:net.rim.ejde.internal.signing.SignatureToolLaunchAction.java
License:Open Source License
/** * Displays a warning dialog indicating that the signature tool is already running. *///from w ww. j a v a2 s. co m private static void warnSignatureToolRunning() { Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(), Messages.SignCommandHandler_SigToolRunningDialogTitleMsg, null, Messages.SignCommandHandler_SigToolRunningDialogMsg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } }); }
From source file:net.rim.ejde.internal.ui.preferences.SignatureToolPrefsPage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite main = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1;//from www . j a v a 2 s .c o m main.setLayout(layout); main.setLayoutData(new GridData(GridData.FILL_BOTH)); Label linkLabel = new Label(main, SWT.NONE); linkLabel.setText(Messages.CodeSigningPrefsPage_ClickHereLabel); Link keyLink = new Link(main, SWT.NONE); keyLink.setText(Messages.CodeSigningPrefsPage_AddNewKeyLabel); keyLink.setToolTipText(Messages.CodeSigningPrefsPage_AddNewKeyToolTip); keyLink.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { ImportCSIFilesAction action = new ImportCSIFilesAction(); action.run(null); } }); _searchKeyLink = new Link(main, SWT.NONE); _searchKeyLink.setText(Messages.CodeSigningPrefsPage_AddOldKeyLabel); _searchKeyLink.setToolTipText(Messages.CodeSigningPrefsPage_AddOldKeyToolTip); _removeKeyLink = new Link(main, SWT.NONE); _removeKeyLink.setText(Messages.CodeSigningPrefsPage_RemoveCurrentKeyLabel); _removeKeyLink.setToolTipText(Messages.CodeSigningPrefsPage_RemoveCurrentKeyToolTip); File cskFile; File dbFile; try { cskFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME); dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME); if ((cskFile.exists()) && (dbFile.exists())) { _searchKeyLink.setEnabled(false); _removeKeyLink.setEnabled(true); } else { _searchKeyLink.setEnabled(true); _removeKeyLink.setEnabled(false); } } catch (IOException io) { _log.error(io.getMessage()); } _searchKeyLink.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { // Open file dialog to allow user select the parent folder of *.csk and *.db files SigningSearchDialog oldKeyDialog = new SigningSearchDialog(getShell()); try { ArrayList<File> oldKeyFiles = oldKeyDialog.search(); if (oldKeyFiles != null) { oldKeyDialog.copyFileIntoSignToolDir(oldKeyFiles); MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, Messages.CodeSigningPrefsPage_MessageDialogMsg1, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); _searchKeyLink.setEnabled(false); _removeKeyLink.setEnabled(true); _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg9); } } catch (IllegalArgumentException ex) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, ex.getMessage(), MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } } }); _removeKeyLink.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (MessageDialog.openQuestion(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3, Messages.CodeSigningPrefsPage_MessageDialogMsg4 + Messages.CodeSigningPrefsPage_MessageDialogMsg6)) { removeKeys(); } } }); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false); gridData.verticalIndent = 15; _runSignToolAutomatically = new Button(main, SWT.CHECK); _runSignToolAutomatically.setText(Messages.SignatureToolPrefsPage_AutomaticallySigningBtnMsg); _runSignToolAutomatically.setToolTipText(Messages.SignatureToolPrefsPage_AutomaticallySigningBtnTooltipMsg); _runSignToolAutomatically.setLayoutData(gridData); _runSignToolSilently = new Button(main, SWT.CHECK); _runSignToolSilently.setText(Messages.SignatureToolPrefsPage_SilentToolBtnMsg); _runSignToolSilently.setToolTipText(Messages.SignatureToolPrefsPage_SilentToolBtnTooltipMsg); _runSignToolSilently.setLayoutData(gridData); initValues(); return parent; }
From source file:net.rim.ejde.internal.ui.preferences.SignatureToolPrefsPage.java
License:Open Source License
private void removeKeys() { try {/*from w ww. ja v a 2 s. com*/ File cskFile = new File( VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME); File dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME); if ((!cskFile.exists()) && (!dbFile.exists())) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3, null, Messages.CodeSigningPrefsPage_MessageDialogMsg3, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); return; } if (cskFile.exists()) { cskFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis())); } if (dbFile.exists()) { dbFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis())); } if ((!cskFile.exists()) && (!dbFile.exists())) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3, null, Messages.CodeSigningPrefsPage_MessageDialogMsg5 + Messages.CodeSigningPrefsPage_MessageDialogMsg6, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); _searchKeyLink.setEnabled(true); _removeKeyLink.setEnabled(false); _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg7); } } catch (IOException e) { _log.error(e.getMessage()); } }
From source file:net.rim.ejde.internal.ui.preferences.WarningsPrefsPage.java
License:Open Source License
private void storePrefValues() { Map<String, Boolean> currentStatusTable = new HashMap<String, Boolean>(); boolean needBuild = false, givePrompt = ContextManager.getDefault().getPreferenceStore() .getBoolean(IConstants.PROMPT_FOR_BUILD_KEY); List<IMarker> problems = null; for (TreeItem item : _checkTree.getItems()) { Integer itemKey = VMUtils.convertPreferenceLabelToKey(item.getText()); currentStatusTable.put(item.getText(), Boolean.valueOf(item.getChecked())); boolean oldCheckedValue = WarningsPreferences.getWarnStatus(item.getText()); if (item.getChecked() && !oldCheckedValue) { if (problems == null) { try { problems = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot() .findMarkers(IRIMMarker.CODE_SIGN_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE)); } catch (CoreException e) { _log.error("Error Finding Workspace Markers", e); }/*w ww .j a v a 2 s.c om*/ if (problems == null) { break; } } List<IMarker> retainedProblems = new ArrayList<IMarker>(); for (IMarker marker : problems) { try { Object key = marker.getAttribute(IRIMMarker.KEY); if (key != null && key.equals(itemKey)) { marker.delete(); } else { retainedProblems.add(marker); } } catch (CoreException e) { _log.error("Error Retrieving Key from marker", e); } } problems = retainedProblems; } else if (!item.getChecked() && oldCheckedValue) { needBuild = true; } } WarningsPreferences.setCodeSignWarnStatus(currentStatusTable); WarningsPreferences.setPromptForMissingDebugFiles(_promptForDebugFileButton.getSelection()); WarningsPreferences .setPromptForMissingDependenciesFiles(_promptForMissingDependenciesFileButton.getSelection()); if (needBuild && givePrompt) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle2, null, Messages.CodeSigningPrefsPage_MessageDialogMsg2, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 2); int res = dialog.open(); if (res == 0) { CoreUtility.getBuildJob(null).schedule(); } } }
From source file:net.rim.ejde.internal.util.FileUtils.java
License:Open Source License
public static IStatus canChange(final java.io.File osFile, final String dialogTitle, final String errorMessage, final boolean showResourcePath, final String questionMessage) { IStatus result = Status.CANCEL_STATUS; if ((osFile != null) && (osFile.exists())) { if (osFile.canWrite()) { result = Status.OK_STATUS;/*from www. j a v a 2 s. c om*/ } else { // prompt for making resource writable Display.getDefault().syncExec(new Runnable() { public void run() { StringBuffer buffer = new StringBuffer(); buffer.append(errorMessage); if (showResourcePath) { buffer.append(osFile.getAbsolutePath()); } buffer.append(questionMessage); String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; Shell shell = new Shell(); MessageDialog promptSaveDia = new MessageDialog(shell, dialogTitle, null, buffer.toString(), MessageDialog.WARNING, buttons, 0); int ret = promptSaveDia.open(); shell.dispose(); if (ret == Window.OK) { // make this resource writable setWritable(osFile); } } }); if (osFile.canWrite()) { result = Status.OK_STATUS; } } } return result; }
From source file:net.sf.eclipse.tomcat.TomcatProjectChangeListener.java
License:Open Source License
public void resourceChanged(IResourceChangeEvent event) { if (event.getResource() instanceof IProject) { final TomcatProject project = TomcatProject.create((IProject) event.getResource()); if (project != null) { Display.getDefault().syncExec(new Runnable() { public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); String[] labels = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog(window.getShell(), WIZARD_PROJECT_REMOVE_TITLE, null, WIZARD_PROJECT_REMOVE_DESCRIPTION, MessageDialog.QUESTION, labels, 1); if (dialog.open() == MessageDialog.OK) { try { project.removeContext(); } catch (Exception ex) { TomcatLauncherPlugin.log(ex.getMessage()); }//from w ww. j a va 2 s . c o m } } }); } } }
From source file:net.sf.eclipsecs.ui.config.CheckConfigurationPropertiesDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#okPressed() *///from w ww . j a v a 2 s.c o m protected void okPressed() { try { // Check if the configuration is valid mCheckConfig = mConfigurationEditor.getEditedWorkingCopy(); CheckConfigurationTester tester = new CheckConfigurationTester(mCheckConfig); List<ResolvableProperty> unresolvedProps = tester.getUnresolvedProperties(); if (!unresolvedProps.isEmpty()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CheckConfigurationPropertiesDialog_titleUnresolvedProps, null, NLS.bind(Messages.CheckConfigurationPropertiesDialog_msgUnresolvedProps, "" + unresolvedProps.size()), //$NON-NLS-1$ MessageDialog.WARNING, new String[] { Messages.CheckConfigurationPropertiesDialog_btnEditProps, Messages.CheckConfigurationPropertiesDialog_btnContinue, Messages.CheckConfigurationPropertiesDialog_btnCancel }, 0); int result = dialog.open(); if (0 == result) { ResolvablePropertiesDialog propsDialog = new ResolvablePropertiesDialog(getShell(), mCheckConfig); propsDialog.open(); return; } else if (1 == result) { super.okPressed(); } else if (2 == result) { return; } } else { super.okPressed(); } } catch (CheckstylePluginException e) { CheckstyleLog.log(e); this.setErrorMessage(e.getLocalizedMessage()); } }
From source file:net.sf.eclipsensis.dialogs.NSISTaskTagsPreferencePage.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w ww .j a v a2 s . c o m public boolean performOk() { if (super.performOk()) { Collection<NSISTaskTag> taskTags = (Collection<NSISTaskTag>) mTableViewer.getInput(); boolean caseSensitive = mCaseSensitiveButton.getSelection(); boolean different = (caseSensitive != NSISPreferences.getInstance().isCaseSensitiveTaskTags()); if (!different) { if (taskTags.size() == mOriginalTags.size()) { for (Iterator<NSISTaskTag> iter = taskTags.iterator(); iter.hasNext();) { if (!mOriginalTags.contains(iter.next())) { different = true; break; } } } else { different = true; } } if (different) { if (taskTags.size() > 0) { boolean defaultFound = false; for (Iterator<NSISTaskTag> iter = taskTags.iterator(); iter.hasNext();) { NSISTaskTag element = iter.next(); if (element.isDefault()) { defaultFound = true; break; } } if (!defaultFound) { if (taskTags.size() == 1) { NSISTaskTag taskTag = (NSISTaskTag) taskTags.toArray()[0]; taskTag.setDefault(true); mTableViewer.setChecked(taskTag, true); } else { Common.openError(getShell(), EclipseNSISPlugin.getResourceString("task.tag.dialog.missing.default"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage()); return false; } } } } boolean updateTaskTags = false; if (different) { NSISPreferences.getInstance().setTaskTags(taskTags); NSISPreferences.getInstance().setCaseSensitiveTaskTags(caseSensitive); MessageDialog dialog = new MessageDialog(getShell(), EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), EclipseNSISPlugin.getResourceString("task.tags.settings.changed"), MessageDialog.QUESTION, //$NON-NLS-1$ new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.setBlockOnOpen(true); int rv = dialog.open(); if (rv == 2) { //Cancel return false; } else { updateTaskTags = (rv == 0); } NSISPreferences.getInstance().store(); } if (updateTaskTags) { new NSISTaskTagUpdater().updateTaskTags(); NSISEditorUtilities.updatePresentations(); mOriginalTags.clear(); mOriginalTags.addAll(taskTags); } return true; } return false; }