List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.nokia.carbide.cpp.internal.codescanner.ui.CSGeneralTabPage.java
License:Open Source License
/** * Check whether a directory already exist. * @param path - path of directory to be validated * @return true if directory exists//from w w w . ja v a 2 s . co m */ private boolean validateDirectory(String path) { boolean result = false; IPath dirPath = new Path(path); if (dirPath.toFile().exists()) { result = true; } else { result = MessageDialog.openQuestion(getShell(), "Directory does not exist.", "The directory " + dirPath + " does not exist.\n\nDo you want to continue?"); } return result; }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.BupProfileEditDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { getShell().setText(/*from ww w . ja va 2s .c om*/ Messages.getString("BupProfileEditDialog.editingProfile") + profileForThisEdit.getProfileId()); //$NON-NLS-1$ setTitleImage(ButtonPlugin.getImageDescriptor("icons/PI_Meter_20x20.png").createImage()); //$NON-NLS-1$ setTitle(Messages.getString("BupProfileEditDialog.profile") + profileForThisEdit.getProfileId()); //$NON-NLS-1$ GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); GridLayoutFactory gridLayoutButton = GridLayoutFactory.swtDefaults(); GridDataFactory gridDataButton = GridDataFactory.swtDefaults(); content = new Composite(parent, SWT.NONE); layoutExpandBoth.applyTo(content); gridDataExpandBoth.applyTo(content); PlatformUI.getWorkbench().getHelpSystem().setHelp(content, ComNokiaCarbidePiButtonHelpIDs.PI_PROFILE_EDIT_DIALOG); localeMappingGroup = new Group(content, SWT.NONE); layoutExpandBoth.applyTo(localeMappingGroup); gridDataExpandBoth.applyTo(localeMappingGroup); mappingComposite = new Composite(localeMappingGroup, SWT.NONE); layoutExpandBoth.copy().numColumns(2).applyTo(mappingComposite); gridDataExpandBoth.applyTo(mappingComposite); mappingTableViewer = new BupMapTableViewer(mappingComposite, true); Table mappingTable = mappingTableViewer.getTable(); // enable the edit button only when a single file filter is selected mappingTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleViewerSelection(); } }); int maxWidth; buttonComposite = new Composite(mappingComposite, SWT.NONE); gridLayoutButton.applyTo(buttonComposite); gridDataButton.copy().align(SWT.CENTER, SWT.FILL).grab(false, true).applyTo(buttonComposite); addButton = new Button(buttonComposite, SWT.NONE); addButton.setText(Messages.getString("BupProfileEditDialog.add")); //$NON-NLS-1$ addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleAdd(); } }); maxWidth = buttonComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; editButton = new Button(buttonComposite, SWT.NONE); editButton.setText(Messages.getString("BupProfileEditDialog.edit")); //$NON-NLS-1$ editButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleEdit(); } }); maxWidth = Math.max(maxWidth, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); removeButton = new Button(buttonComposite, SWT.NONE); removeButton.setText(Messages.getString("BupProfileEditDialog.remove")); //$NON-NLS-1$ removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleRemove(); } }); maxWidth = Math.max(maxWidth, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); //dummy label as divider new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); clearButton = new Button(buttonComposite, SWT.NONE); clearButton.setText(Messages.getString("BupProfileEditDialog.clearProfile")); //$NON-NLS-1$ clearButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { if (MessageDialog.openQuestion(getShell(), Messages.getString("BupProfileEditDialog.clearProfile"), //$NON-NLS-1$ Messages.getString("BupProfileEditDialog.clearAllConfirm"))) { //$NON-NLS-1$ Set<Integer> keySet = cachedMap.getKeyCodeSet(); Integer[] keyCodes = keySet.toArray(new Integer[keySet.size()]); for (Integer keyCode : keyCodes) { cachedMap.removeMapping(keyCode); } refreshTable(); } } }); maxWidth = Math.max(maxWidth, clearButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); gridDataButton.hint(maxWidth, addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(addButton); gridDataButton.hint(maxWidth, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(removeButton); gridDataButton.hint(maxWidth, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(editButton); gridDataButton.hint(maxWidth, clearButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(clearButton); initialize(); return content; }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.ButtonTabPage.java
License:Open Source License
public ButtonTabPage(Composite parent) { super(parent, SWT.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ComNokiaCarbidePiButtonHelpIDs.PI_BUTTON_MAP_PREF_TAB); GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); GridLayoutFactory layoutExpandHorizontal = GridLayoutFactory.swtDefaults(); GridDataFactory gridDataExpandHorizontal = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false);/* www.j a v a2s .c o m*/ GridDataFactory gridDataButton = GridDataFactory.swtDefaults(); layoutExpandBoth.applyTo(this); gridDataExpandBoth.applyTo(this); content = new Composite(this, SWT.NONE); layoutExpandBoth.applyTo(content); gridDataExpandBoth.applyTo(content); profileGroup = new Group(content, SWT.NONE); layoutExpandHorizontal.applyTo(profileGroup); gridDataExpandHorizontal.applyTo(profileGroup); profileGroup.setText(Messages.getString("ButtonTabPage.manageProfiles")); //$NON-NLS-1$ profileCombo = new Combo(profileGroup, SWT.READ_ONLY); layoutExpandHorizontal.applyTo(profileCombo); gridDataExpandHorizontal.applyTo(profileCombo); profileCombo.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { refreshTableToCombo(); } }); profileButtonComposite = new Composite(profileGroup, SWT.NONE); layoutExpandHorizontal.copy().numColumns(3).applyTo(profileButtonComposite); gridDataExpandHorizontal.applyTo(profileButtonComposite); int maxWidth; profileNewButton = new Button(profileButtonComposite, SWT.NONE); profileNewButton.setText(Messages.getString("ButtonTabPage.duplicate")); //$NON-NLS-1$ profileNewButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { BupProfileDuplicateDialog dialog = new BupProfileDuplicateDialog(getShell(), profiles.get(profileCombo.getSelectionIndex())); if (dialog.open() == BupProfileDuplicateDialog.OK) { refreshCombo(); profileCombo.select(BupEventMapManager.getInstance().getProfilesFromWorkspacePref().size() - 1); // we cheat a bit by knowing addToWorkspace always append to the end refreshTableToCombo(); // current profile had been removed; } } }); maxWidth = profileNewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; profileEditButton = new Button(profileButtonComposite, SWT.NONE); profileEditButton.setText(Messages.getString("ButtonTabPage.Edit")); //$NON-NLS-1$ profileEditButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { IBupEventMapProfile profile = profiles.get(profileCombo.getSelectionIndex()); if (profile != null) { new BupProfileEditDialog(getShell(), profile).open(); refreshTableToCombo(); // current profile may had changed } } }); maxWidth = Math.max(maxWidth, profileEditButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); profileRemoveButton = new Button(profileButtonComposite, SWT.NONE); profileRemoveButton.setText(Messages.getString("ButtonTabPage.remove")); //$NON-NLS-1$ profileRemoveButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { IBupEventMapProfile profile = profiles.get(profileCombo.getSelectionIndex()); if (profile != null) { if (MessageDialog.openQuestion(getShell(), Messages.getString("ButtonTabPage.confirmRemovalHeading"), //$NON-NLS-1$ Messages.getString("ButtonTabPage.profile") + profile.getProfileId() //$NON-NLS-1$ + Messages.getString("ButtonTabPage.confirmRemoval"))) { //$NON-NLS-1$ //$NON-NLS-3$ if (BupEventMapManager.getInstance().canRemoveProfile(profile)) { BupEventMapManager.getInstance().removeFromWorkspace(profile); refreshCombo(); refreshTableToCombo(); // current profile had been removed; } else { MessageDialog.openInformation(getShell(), Messages.getString("ButtonTabPage.cannotRemoveProfile"), //$NON-NLS-1$ Messages.getString("ButtonTabPage.profile") + profile.getProfileId() //$NON-NLS-1$ + Messages.getString("ButtonTabPage.isStillOpen")); //$NON-NLS-1$ //$NON-NLS-3$ } } } } }); maxWidth = Math.max(maxWidth, profileRemoveButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); importExportButtonComposite = new Composite(content, SWT.NONE); layoutExpandHorizontal.copy().numColumns(2).applyTo(importExportButtonComposite); gridDataExpandHorizontal.applyTo(importExportButtonComposite); profileImportLink = new Link(importExportButtonComposite, SWT.NONE); profileImportLink.setText(Messages.getString("ButtonTabPage.importHref")); //$NON-NLS-1$ profileImportLink.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { importXML(); } }); profileExportLink = new Link(importExportButtonComposite, SWT.NONE); profileExportLink.setText(Messages.getString("ButtonTabPage.exportHref")); //$NON-NLS-1$ profileExportLink.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { exportXML(); } }); gridDataButton.hint(maxWidth, profileNewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileNewButton); gridDataButton.hint(maxWidth, profileRemoveButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileRemoveButton); gridDataButton.hint(maxWidth, profileEditButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileEditButton); mappingGroup = new Group(content, SWT.NONE); layoutExpandBoth.applyTo(mappingGroup); gridDataExpandBoth.applyTo(mappingGroup); mappingGroup.setText(Messages.getString("ButtonTabPage.keyPressMapping")); //$NON-NLS-1$ Composite compositeToLookBetter = new Composite(mappingGroup, SWT.NONE); layoutExpandHorizontal.applyTo(compositeToLookBetter); gridDataExpandHorizontal.applyTo(compositeToLookBetter); mappingTableViewer = new BupMapTableViewer(compositeToLookBetter, false); refreshCombo(); }
From source file:com.nokia.carbide.cpp.internal.pi.wizards.ui.ProfilerActivatorGroup.java
License:Open Source License
/** * Handle temporary profiler data files in case user is tried to close * wizard and user has traced some data from device * /*www. j a v a 2s .c om*/ * @param forceRemove */ public void handleTemporaryProfilerDataFiles(boolean forceRemove) { final List<ProfilerDataPlugins> plugins = new ArrayList<ProfilerDataPlugins>(); plugins.addAll(getProfilerDataFiles()); getProfilerDataFiles().clear(); if (forceRemove) { deleteProfilerDataFiles(plugins); } else if (plugins.size() > 0) { boolean answer = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.getString("ProfilerActivatorGroup.questionDialogTitle"), //$NON-NLS-1$ Messages.getString("ProfilerActivatorGroup.questionDialogMessage")); //$NON-NLS-1$ if (answer) { // open file dialog for selecting a crash file DirectoryDialog dialog = new DirectoryDialog(Display.getDefault().getActiveShell()); dialog.setText(Messages.getString("ProfilerActivatorGroup.directorySelectionDialogTitle")); //$NON-NLS-1$ final String result = dialog.open(); if (result != null) { WorkspaceJob job = new WorkspaceJob( Messages.getString("ProfilerActivatorGroup.movingProfilerDataFilesJob") + result) { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ for (ProfilerDataPlugins plugin : plugins) { IPath dataFile = plugin.getProfilerDataPath(); IPath targetFile = generateDatFile(new Path(result).append(dataFile.lastSegment())); try { moveFile(dataFile, targetFile, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); } catch (Exception e) { List<ProfilerDataPlugins> list = new ArrayList<ProfilerDataPlugins>(); list.add(plugin); deleteProfilerDataFiles(list); e.printStackTrace(); MessageDialog.openError(getShell(), Messages.getString("ProfilerActivatorGroup.errorDialogTitle"), //$NON-NLS-1$ MessageFormat.format( Messages.getString("ProfilerActivatorGroup.failedToMoveFileTo"), //$NON-NLS-1$ dataFile.lastSegment(), result)); } } monitor.done(); return Status.OK_STATUS; } }; job.schedule(); } else { deleteProfilerDataFiles(plugins); } } else { deleteProfilerDataFiles(plugins); } } }
From source file:com.nokia.carbide.cpp.internal.project.ui.editors.images.SelectOrAddImagesDialogBase.java
License:Open Source License
/** * Utility routine used for copying a file from the filesystem to the project. It should * be called once for each selected item in the thumbnail viewer when {@link #copyImagesToProject()} * is called.// w ww. j a va2s . co m * <p> * This uses the settings established by the {@link #createCopyFilesToProjectComposite(Composite)} * UI to determine where in the project to copy the file and whether to overwrite or query. * @param srcFullPath the filesystem path of the source * @param builder status builder to which is added errors * @return the resulting image path, relative to the project, or srcFullPath if the copy failed */ protected IPath copyImageToProject(IPath srcFullPath, StatusBuilder builder) { if (getProject() == null || !doCopyImages) return srcFullPath; String filename = srcFullPath.lastSegment(); IPath destPath = projectDestination.append(filename); try { InputStream is = new FileInputStream(new File(srcFullPath.toOSString())); IFile file = getProject().getFile(destPath); if (file.exists()) { // check to see if the source and destinations are the same and disallow if (file.getLocation().equals(srcFullPath)) { MessageDialog.openError(getShell(), Messages.getString("AddFilesystemImagesDialog.OverwriteFileTitle"), //$NON-NLS-1$ MessageFormat.format( Messages.getString( "AddFilesystemImagesDialog.SameSourceAndDestinationFilesError"), //$NON-NLS-1$ new Object[] { file.getLocation() })); } else { boolean rewrite = false; if (doOverwrite) { rewrite = true; } else { rewrite = MessageDialog.openQuestion(getShell(), Messages.getString("AddFilesystemImagesDialog.OverwriteFileTitle"), //$NON-NLS-1$ MessageFormat.format( Messages.getString("AddFilesystemImagesDialog.OverwriteFileMessage"), //$NON-NLS-1$ new Object[] { file.getLocation() })); } if (rewrite) { file.setContents(is, false, true, new NullProgressMonitor()); } } } else { file.create(is, false, new NullProgressMonitor()); } is.close(); return destPath; } catch (IOException e) { builder.add(Logging.newStatus(CarbideUIPlugin.getDefault(), e)); return srcFullPath; } catch (CoreException e) { builder.add(e.getStatus()); return srcFullPath; } }
From source file:com.nokia.carbide.cpp.internal.project.ui.editors.inf.BldInfEditor.java
License:Open Source License
private boolean fixMissingBuildConfig(ICarbideProjectInfo cpi) { boolean result = false; // Don't put up dialog if the workbench window is still not initialized Shell activeShell = WorkbenchUtils.getActiveShell(); if (activeShell != null && activeShell.isVisible()) { boolean doDialog = MessageDialog.openQuestion(getSite().getShell(), Messages.BldInfEditor_BldInfEditor, Messages.BldInfEditor_noBuildConfig_ChooseNowPrompt); if (doDialog) { ManageConfigurationsDialog dialog = new ManageConfigurationsDialog(getSite().getShell(), cpi); if (dialog.open() == Dialog.OK) { result = cpi.getDefaultConfiguration() != null; }/* w w w. j a v a 2 s . com*/ } } return result; }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.dialogs.ToolOptionsDialog.java
License:Open Source License
/** * Handles the case where the user selects a tool chain * that already has an options setting, allowing the user * to edit the existing value if desired. *//*from w ww . ja v a2s.com*/ protected void toolChainSelectionChanged() { String toolChain = getSelectedToolChain(); if (toolChain != null) { String currValue = currentOptions.get(toolChain); if (currValue != null) { boolean dlgResult = MessageDialog.openQuestion(getShell(), Messages.getString("ToolOptionsDialog.editExistingSettingDialogTitle"), //$NON-NLS-1$ Messages.getString("ToolOptionsDialog.editExistingSettingPrompt")); //$NON-NLS-1$ if (dlgResult) { optionsText.setText(currValue); } else { selectFirstAvailableToolChain(); } } } }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.dialogs.ValidatingDialog.java
License:Open Source License
@Override protected void okPressed() { IStatus validateStatus = validate(); switch (validateStatus.getSeverity()) { case IStatus.OK: captureResults();/*from ww w . ja v a 2 s. c o m*/ super.okPressed(); break; case IStatus.ERROR: MessageDialog.openError(getShell(), Messages.getString("ValidationDialogTitle"), //$NON-NLS-1$ validateStatus.getMessage()); break; case IStatus.CANCEL: // indicates the derived class has already display a validation error. break; default: boolean ok = MessageDialog.openQuestion(getShell(), Messages.getString("ValidatingDialog.confirmationTitle"), //$NON-NLS-1$ validateStatus.getMessage()); if (ok) { captureResults(); super.okPressed(); } break; } }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.MMPEditor.java
License:Open Source License
private boolean fixMissingBuildConfig(ICarbideProjectInfo cpi) { boolean result = false; // Don't put up dialog if the workbench window is still not initialized Shell activeShell = WorkbenchUtils.getActiveShell(); if (activeShell != null && activeShell.isVisible()) { boolean doDialog = MessageDialog.openQuestion(getSite().getShell(), Messages.MMPEditor_dialogTitle, Messages.MMPEditor_noBuildConfig_ChooseNowPrompt); if (doDialog) { ManageConfigurationsDialog dialog = new ManageConfigurationsDialog(getSite().getShell(), cpi); if (dialog.open() == Dialog.OK) { result = cpi.getDefaultConfiguration() != null; }//from w w w . j ava 2s .c om } } return result; }
From source file:com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager.java
License:Open Source License
public boolean checkDevicesXMLExistAndCreate() { Shell shell = WorkbenchUtils.getSafeShell(); File devicesFile = getDevicesXMLFile(); if (!devicesFile.exists()) { if (MessageDialog.openQuestion(shell, "Devices.xml Not Found", "Carbide.c++ requires a valid devices.xml file to manage SDKs.\n\nDo you want Carbide to create this file?")) { try { // First check to make sure the directory exists.... if (!devicesFile.getParentFile().exists()) { devicesFile.getParentFile().mkdirs(); }/*from w w w.j ava2 s. co m*/ devicesFile.createNewFile(); FileWriter fw = new FileWriter(devicesFile); fw.write(EMPTY_DEVICES_XML_CONTENT); fw.close(); MessageDialog.openInformation(shell, "Devices.xml File Created", MessageFormat.format( "{0} was created successfully. Please add an SDK under the SDK Preferences page with the \"Add\" button before you attempt to create a project.", devicesFile.getAbsolutePath())); return true; } catch (IOException e) { String message = "Could not create file: " + devicesFile.getAbsolutePath(); MessageDialog.openError(shell, "Cannot Create File", message); logError(message, e); } } } return false; }