List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:au.gov.ga.earthsci.application.compatibility.WorkspaceHelper.java
License:Apache License
public static Object checkInstanceLocation(Shell shell, @SuppressWarnings("rawtypes") Map applicationArguments) { // -data @none was specified but an ide requires workspace Location instanceLoc = Platform.getInstanceLocation(); if (instanceLoc == null) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceMandatoryTitle, IDEWorkbenchMessages.IDEApplication_workspaceMandatoryMessage); return IApplication.EXIT_OK; }/*from w w w . j a v a 2 s . co m*/ // -data "/valid/path", workspace already set if (instanceLoc.isSet()) { // make sure the meta data version is compatible (or the user has // chosen to overwrite it). if (!checkValidWorkspace(shell, instanceLoc.getURL())) { return IApplication.EXIT_OK; } // at this point its valid, so try to lock it and update the // metadata version information if successful try { if (instanceLoc.lock()) { writeWorkspaceVersion(); return null; } // we failed to create the directory. // Two possibilities: // 1. directory is already in use // 2. directory could not be created File workspaceDirectory = new File(instanceLoc.getURL().getFile()); if (workspaceDirectory.exists()) { if (isDevLaunchMode(applicationArguments)) { return EXIT_WORKSPACE_LOCKED; } MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotLockTitle, NLS.bind(IDEWorkbenchMessages.IDEApplication_workspaceCannotLockMessage, workspaceDirectory.getAbsolutePath())); } else { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage); } } catch (IOException e) { logger.error("Could not obtain lock for workspace location", //$NON-NLS-1$ e); MessageDialog.openError(shell, IDEWorkbenchMessages.InternalError, e.getMessage()); } return IApplication.EXIT_OK; } // -data @noDefault or -data not specified, prompt and set ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc.getDefault()); boolean force = false; while (true) { URL workspaceUrl = promptForWorkspace(shell, launchData, force); if (workspaceUrl == null) { return IApplication.EXIT_OK; } // if there is an error with the first selection, then force the // dialog to open to give the user a chance to correct force = true; try { // the operation will fail if the url is not a valid // instance data area, so other checking is unneeded if (instanceLoc.set(workspaceUrl, true)) { launchData.writePersistedData(); writeWorkspaceVersion(); return null; } } catch (IOException e) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage); return IApplication.EXIT_OK; } // by this point it has been determined that the workspace is // already in use -- force the user to choose again MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceInUseTitle, NLS.bind(IDEWorkbenchMessages.IDEApplication_workspaceInUseMessage, workspaceUrl.getFile())); } }
From source file:au.gov.ga.earthsci.application.compatibility.WorkspaceHelper.java
License:Apache License
/** * Open a workspace selection dialog on the argument shell, populating the * argument data with the user's selection. Perform first level validation * on the selection by comparing the version information. This method does * not examine the runtime state (e.g., is the workspace already locked?). * /* w w w . ja v a2 s . c om*/ * @param shell * @param launchData * @param force * setting to true makes the dialog open regardless of the * showDialog value * @return An URL storing the selected workspace or null if the user has * canceled the launch operation. */ private static URL promptForWorkspace(Shell shell, ChooseWorkspaceData launchData, boolean force) { URL url = null; do { // okay to use the shell now - this is the splash shell new ChooseWorkspaceDialog(shell, launchData, false, true).prompt(force); String instancePath = launchData.getSelection(); if (instancePath == null) { return null; } // the dialog is not forced on the first iteration, but is on every // subsequent one -- if there was an error then the user needs to be // allowed to fix it force = true; // 70576: don't accept empty input if (instancePath.length() <= 0) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceEmptyTitle, IDEWorkbenchMessages.IDEApplication_workspaceEmptyMessage); continue; } // create the workspace if it does not already exist File workspace = new File(instancePath); if (!workspace.exists()) { workspace.mkdir(); } try { // Don't use File.toURL() since it adds a leading slash that Platform does not // handle properly. See bug 54081 for more details. String path = workspace.getAbsolutePath().replace(File.separatorChar, '/'); url = new URL("file", null, path); //$NON-NLS-1$ } catch (MalformedURLException e) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceInvalidTitle, IDEWorkbenchMessages.IDEApplication_workspaceInvalidMessage); continue; } } while (!checkValidWorkspace(shell, url)); return url; }
From source file:au.gov.ga.earthsci.eclipse.extras.browser.WebBrowserUtil.java
License:Open Source License
/** * Open a dialog window.//from ww w. ja v a2s. c o m * * @param message * java.lang.String */ public static void openError(String message) { Display d = Display.getCurrent(); if (d == null) d = Display.getDefault(); Shell shell = d.getActiveShell(); MessageDialog.openError(shell, Messages.errorDialogTitle, message); }
From source file:automaticexperiment.presentation.AutomaticexperimentModelWizard.java
License:Open Source License
/** * Do the work after everything is specified. * <!-- begin-user-doc -->/*ww w . jav a 2 s. c o m*/ * <!-- end-user-doc --> * @generated */ @Override public boolean performFinish() { try { // Remember the file. // final IFile modelFile = getModelFile(); // Do the work within an operation. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) { try { // Create a resource set // ResourceSet resourceSet = new ResourceSetImpl(); // Get the URI of the model file. // URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); // Create a resource for this file. // Resource resource = resourceSet.createResource(fileURI); // Add the initial model object to the contents. // EObject rootObject = createInitialModel(); if (rootObject != null) { resource.getContents().add(rootObject); } // Save the contents of the resource to the file system. // Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); resource.save(options); } catch (Exception exception) { AutomaticexperienceEditPlugin.INSTANCE.log(exception); } finally { progressMonitor.done(); } } }; getContainer().run(false, false, operation); // Select the new file resource in the current view. // IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(modelFile); getShell().getDisplay().asyncExec(new Runnable() { public void run() { ((ISetSelectionTarget) activePart).selectReveal(targetSelection); } }); } // Open an editor on the new file. // try { page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); } catch (PartInitException exception) { MessageDialog.openError(workbenchWindow.getShell(), AutomaticexperienceEditPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); return false; } return true; } catch (Exception exception) { AutomaticexperienceEditPlugin.INSTANCE.log(exception); return false; } }
From source file:backup.gui.BackupTool.java
License:Open Source License
public BackupTool(Display display) { Launcher.configWindowOpen = true;//from w w w . ja va 2s .co m shell_ = new Shell(display); shell_.setLayout(new GridLayout(5, false)); shell_.setText("Backup Configuration - " + Utility.getVersionNumber()); shell_.setImage(new Image(display, this.getClass().getResourceAsStream("/icons/icon.gif"))); shell_.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent arg0) { Launcher.configWindowOpen = false; } }); makeLabel(shell_, "Choose the location to create the backup:", GridData.BEGINNING, 4); Link l = makeLink(shell_, "<a>about</a>", GridData.END, 1); l.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { MessageBox mb = new MessageBox(shell_, SWT.OK); mb.setText("About Backup Tool - " + Utility.getVersionNumber()); mb.setMessage("Backup Tool Version " + Utility.getVersionNumber() + "\n" + "Copyright 2010, Daniel Armbrust All Rights Reserved\n" + "This code is licensed under the Apache License - v 2.0. \n" + "A full copy of the license has been included with the distribution.\n" + "E-Mail me at daniel.armbrust@gmail.com.\n" + "or visit http://armbrust.webhop.net/"); mb.open(); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); backupLocation_ = new Combo(shell_, SWT.READ_ONLY); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 5; backupLocation_.setLayoutData(gd); backupLocation_.setToolTipText("The folder where the backup should be created"); backupLocation_.setItems(new String[] { "", "Browse..." }); backupLocation_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { if (backupLocation_.getSelectionIndex() == backupLocation_.getItemCount() - 1) { DirectoryDialog dd = new DirectoryDialog(shell_); String result = dd.open(); if (result != null && result.length() > 0) { backupLocation_.setItem(0, result); getCurrentBackupConfig().setTargetFile(new File(result)); } backupLocation_.select(0); } } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); makeLabel(shell_, "Optionally choose a virtual drive root to use when writing to the backup location:", GridData.BEGINNING, 5); topWrittenFolder_ = new Combo(shell_, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 5; topWrittenFolder_.setLayoutData(gd); topWrittenFolder_.setToolTipText( "Optional - By default, all folders to the drive root are written to the backup folder. When selected, only folders below this folder are created in the backup location."); topWrittenFolder_.setItems(new String[] { "<Default>", "Browse..." }); topWrittenFolder_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { if (topWrittenFolder_.getSelectionIndex() == topWrittenFolder_.getItemCount() - 1) { DirectoryDialog dd = new DirectoryDialog(shell_); String result = dd.open(); if (result != null && result.length() > 0) { if (topWrittenFolder_.getItemCount() == 3) { topWrittenFolder_.setItem(1, result); } else //must be two { topWrittenFolder_.add(result, 1); } topWrittenFolder_.select(1); } else { topWrittenFolder_.select(0); } } if (topWrittenFolder_.getItemCount() == 2 || topWrittenFolder_.getSelectionIndex() == 0) { getCurrentBackupConfig().setParentOfTopWrittenFolder(null); } else { getCurrentBackupConfig().setParentOfTopWrittenFolder(new File(topWrittenFolder_.getItem(1))); } } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); removeObsolete_ = new Button(shell_, SWT.CHECK); removeObsolete_.setText("Remove Obsolete Files"); removeObsolete_.setToolTipText( "If you select this option - any file that exists in the backup location but does not exist in the source selection will be removed from the backup location"); removeObsolete_.setSelection(true); removeObsolete_.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); removeObsolete_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { getCurrentBackupConfig().setRemoveObsoleteFiles(removeObsolete_.getSelection()); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); Label tsl = makeLabel(shell_, "Time Stamp Leniancy", SWT.NONE, 1); tsl.setToolTipText( "The time difference that is allowed between when comparing files before deciding that they are different"); timeStampLeniancy_ = new Combo(shell_, SWT.READ_ONLY); timeStampLeniancy_.setToolTipText( "The time difference that is allowed between when comparing files before deciding that they are different"); timeStampLeniancy_.setItems(new String[] { "0", "5", "10", "100", "1000" }); timeStampLeniancy_.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); timeStampLeniancy_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { getCurrentBackupConfig().setTimeStampLeniancy(Integer.parseInt(timeStampLeniancy_.getText())); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); Label tc = makeLabel(shell_, "Simultaneous copy operations", SWT.NONE, 1); tc.setToolTipText( "The number of files to copy at a time. \nIf you are backing up to a local disk, 1 is recommended. \nIf you are backing up to a remote location, a higher number is recommended.\nThis only affect the speed of the copy."); tc.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); copyThreads_ = new Combo(shell_, SWT.READ_ONLY); copyThreads_.setToolTipText( "The number of files to copy at a time. \nIf you are backing up to a local disk, 1 is recommended. \nIf you are backing up to a remote location, a higher number is recommended.\nThis only affect the speed of the copy."); copyThreads_.setItems(new String[] { "1", "2", "3", "5", "10" }); copyThreads_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { getCurrentBackupConfig().setCopyThreads(Integer.parseInt(copyThreads_.getText())); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); makeLabel(shell_, "Choose the files to backup and the files to skip:", GridData.BEGINNING, 4); tv_ = new CheckboxTreeViewer(shell_); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 5; gd.heightHint = 250; tv_.getTree().setLayoutData(gd); tv_.setContentProvider(new FileTreeContentProvider()); tv_.setLabelProvider(new FileTreeLabelProvider(shell_.getDisplay())); tv_.setInput("root"); // pass a non-null that will be ignored tv_.getTree().setToolTipText( "Check the files and folders that you would like to backup. \nChecking a folder will cause the folder and all of its contents to be backed up. \nIf you check a file or folder under a folder which is already checked - then this file or folder (and all subfolders) will be ignored."); csl_ = new CheckStateListener(this, tv_); tv_.addCheckStateListener(csl_); Composite lower = makeLowerSection(shell_); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 5; lower.setLayoutData(gd); shell_.pack(); shell_.open(); try { File configFile = BackupConfigStore.locateConfig(); if (configFile == null) { MessageDialog.openError(shell_, "Configuration read error", "Could not create the necessary folder structure to store your configuration. This is bad!"); } else { if (configFile.exists()) { backupConfigs = BackupConfigStore.readConfigs(configFile); } else { MessageDialog.openInformation(shell_, "No configuration file found", "No configuration file was found. This is expected if this is the first time you have run the program."); } } } catch (Exception e) { MessageDialog.openError(shell_, "Configuration read error", "An unexpected error happened while reading the configuration file. It is corrupt or unreadable."); } tv_.getTree().forceFocus(); if (backupConfigs.size() == 0) { populateBackupConfigList(1, 0); backupConfigs.add(new BackupConfig()); } else { populateBackupConfigList(backupConfigs.size(), 0); } updateForBackupSelection(); }
From source file:backup.gui.BackupTool.java
License:Open Source License
private Composite makeLowerSection(Shell shell) { Composite lower = new Composite(shell, SWT.None); GridLayout gl = new GridLayout(3, false); gl.marginWidth = 0;//from w w w. jav a2 s . co m gl.marginHeight = 0; lower.setLayout(gl); makeLabel(lower, "Files to skip at any level", GridData.HORIZONTAL_ALIGN_BEGINNING, 1); globalSkip_ = makeText(lower, 2); globalSkip_.setToolTipText( "Comma seperated list of file names or file * prefixed extensions to skip. For example: 'file1, *.lock'"); globalSkip_.addFocusListener(new FocusListener() { public void focusLost(FocusEvent arg0) { getCurrentBackupConfig().setGlobalFilesToSkip(globalSkip_.getText()); } public void focusGained(FocusEvent arg0) { // noop } }); backupSelection_ = new Combo(lower, SWT.READ_ONLY); GridData gd = new GridData(GridData.CENTER); backupSelection_.setLayoutData(gd); backupConfigs.add(new BackupConfig()); populateBackupConfigList(backupConfigs.size(), 0); backupSelection_.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { if (backupSelection_.getSelectionIndex() == backupSelection_.getItemCount() - 1) { backupConfigs.add(new BackupConfig()); String newItem = "Backup Configuration " + backupConfigs.size(); backupSelection_.add(newItem, backupSelection_.getItemCount() - 1); backupSelection_.select(backupSelection_.getItemCount() - 2); } updateForBackupSelection(); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); backupSelection_.select(0); Button remove = makeButton(lower, "Remove Configuration", GridData.CENTER); remove.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { int i = backupSelection_.getSelectionIndex(); if (backupSelection_.getItemCount() > 2) { backupConfigs.remove(i); populateBackupConfigList(backupConfigs.size(), 0); } else { backupConfigs.set(0, new BackupConfig()); } updateForBackupSelection(); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); Button run = makeButton(lower, "Run Backup Now", GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END); run.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { for (int i = 0; i < backupConfigs.size(); i++) { String validation = backupConfigs.get(i).validate(); if (validation != null) { backupSelection_.select(i); updateForBackupSelection(); MessageDialog.openError(backupSelection_.getShell(), "Validation Error", validation); return; } } if (!saveConfig()) { MessageDialog.openError(backupSelection_.getShell(), "Configuration Save Error", "Could not save the configuration."); return; } new CopySummary(shell_, BackupTool.this); } public void widgetDefaultSelected(SelectionEvent arg0) { // noop } }); return lower; }
From source file:backup.gui.RunStatusViewer.java
License:Open Source License
public RunStatusViewer(Display display) { Launcher.statusWindowOpen = true;//from w w w . ja v a2s . c o m shell_ = new Shell(display); shell_.setLayout(new GridLayout(1, false)); shell_.setSize(640, 480); shell_.setText("Backup Status - " + Utility.getVersionNumber()); shell_.setImage(new Image(display, this.getClass().getResourceAsStream("/icons/icon.gif"))); text_ = new StyledText(shell_, SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL); text_.setLayoutData(new GridData(GridData.FILL_BOTH)); shell_.setVisible(true); shell_.forceFocus(); try { File configFile = BackupConfigStore.locateConfig(); if (configFile == null) { MessageDialog.openError(shell_, "Configuration read error", "An unexpected error happened while reading the configuration file. It is corrupt or unreadable."); System.exit(0); } else { backupConfigs_ = BackupConfigStore.readConfigs(configFile); configFile_ = configFile.getAbsolutePath(); } } catch (Exception e) { MessageDialog.openError(shell_, "Configuration read error", "An unexpected error happened while reading the configuration file. It is corrupt or unreadable."); System.exit(0); } final Thread thread = new Thread(new Monitor()); thread.start(); shell_.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent arg0) { stop = true; thread.interrupt(); Launcher.statusWindowOpen = false; } }); }
From source file:be.ac.vub.uml2cs.instantmessenger.presentation.LiveValidationContentAdapter.java
License:Open Source License
public void notifyChanged(final Notification notification) { super.notifyChanged(notification); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { if (validator == null) { validator = (ILiveValidator) ModelValidationService.getInstance() .newValidator(EvaluationMode.LIVE); }//from w w w . jav a 2s . c om IStatus status = validator.validate(notification); if (!status.isOK()) { if (status.isMultiStatus()) { status = status.getChildren()[0]; } MessageDialog.openError(InstantMessengerEditorPlugin.INSTANCE.getShell(), "Live Validation Error", status.getMessage()); editingDomain.getCommandStack().undo(); } } }); }
From source file:be.ibridge.kettle.trans.step.selectvalues.SelectValuesDialog.java
License:LGPL
/** * Reads in the fields from the previous steps and from the ONE next step and opens an * EnterMappingDialog with this information. After the user did the mapping, those information * is put into the Select/Rename table.//w w w. j a v a2s .co m */ private void generateMappings() { if (!bPreviousFieldsLoaded) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.ColumnInfo.Loading"), Messages.getString("SelectValuesDialog.ColumnInfo.Loading")); return; } if ((wRemove.getItemCount() > 0) || (wMeta.getItemCount() > 0)) { for (int i = 0; i < wRemove.getItemCount(); i++) { String[] columns = wRemove.getItem(i); for (int a = 0; a < columns.length; a++) { if (columns[a].length() > 0) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMetaTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMeta")); return; } } } for (int i = 0; i < wMeta.getItemCount(); i++) { String[] columns = wMeta.getItem(i); for (int a = 0; a < columns.length; a++) { String col = columns[a]; if (col.length() > 0) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMetaTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMeta")); return; } } } } Row nextStepRequiredFields = null; StepMeta stepMeta = new StepMeta(stepname, input); StepMeta[] nextSteps = transMeta.getNextSteps(stepMeta); if (nextSteps.length == 0 || nextSteps.length > 1) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoNextStepTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoNextStep")); return; } StepMeta outputStepMeta = nextSteps[0]; StepMetaInterface stepMetaInterface = outputStepMeta.getStepMetaInterface(); try { nextStepRequiredFields = stepMetaInterface.getRequiredFields(); } catch (KettleException e) { log.logError(toString(), Messages.getString("SelectValuesDialog.DoMapping.UnableToFindOutput")); nextStepRequiredFields = new Row(); } String[] inputNames = new String[prevFields.size()]; for (int i = 0; i < prevFields.size(); i++) { Value value = prevFields.getValue(i); inputNames[i] = value.getName() + EnterMappingDialog.STRING_ORIGIN_SEPARATOR + value.getOrigin() + ")"; } String[] outputNames = new String[nextStepRequiredFields.size()]; for (int i = 0; i < nextStepRequiredFields.size(); i++) { outputNames[i] = nextStepRequiredFields.getValue(i).getName(); } String[] selectName = new String[wFields.getItemCount()]; String[] selectRename = new String[wFields.getItemCount()]; for (int i = 0; i < wFields.getItemCount(); i++) { selectName[i] = wFields.getItem(i, 1); selectRename[i] = wFields.getItem(i, 2); } ArrayList mappings = new ArrayList(); StringBuffer missingFields = new StringBuffer(); for (int i = 0; i < selectName.length; i++) { String valueName = selectName[i]; String valueRename = selectRename[i]; int inIndex = prevFields.searchValueIndex(valueName); if (inIndex < 0) { missingFields.append(Const.CR + " " + valueName + " --> " + valueRename); continue; } if (null == valueRename || valueRename.equals("")) { valueRename = valueName; } int outIndex = nextStepRequiredFields.searchValueIndex(valueRename); if (outIndex < 0) { missingFields.append(Const.CR + " " + valueName + " --> " + valueRename); continue; } SourceToTargetMapping mapping = new SourceToTargetMapping(inIndex, outIndex); mappings.add(mapping); } // show a confirm dialog if some misconfiguration was found if (missingFields.length() > 0) { boolean goOn = MessageDialog.openConfirm(shell, Messages.getString("SelectValuesDialog.DoMapping.SomeFieldsNotFoundTitle"), Messages.getString( "SelectValuesDialog.DoMapping.SomeFieldsNotFound", missingFields.toString())); if (!goOn) { return; } } EnterMappingDialog d = new EnterMappingDialog(SelectValuesDialog.this.shell, inputNames, outputNames, mappings); mappings = d.open(); // mappings == null if the user pressed cancel if (null != mappings) { wFields.table.removeAll(); wFields.table.setItemCount(mappings.size()); for (int i = 0; i < mappings.size(); i++) { SourceToTargetMapping mapping = (SourceToTargetMapping) mappings.get(i); TableItem item = wFields.table.getItem(i); item.setText(1, prevFields.getValue(mapping.getSourcePosition()).getName()); item.setText(2, outputNames[mapping.getTargetPosition()]); item.setText(3, "-1"); item.setText(4, "-1"); } wFields.setRowNums(); wFields.optWidth(true); wTabFolder.setSelection(0); } }
From source file:bixie.plugin.util.UI.java
License:Open Source License
/** * Prints an error message//w w w . j a v a 2 s .c om * * @param text * Text to be printed */ public static void printError(String text) { final String printText = text; Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", printText); } }); }