List of usage examples for org.eclipse.jface.dialogs Dialog getImage
public static Image getImage(String key)
From source file:com.google.dart.tools.ui.internal.dialogs.SortMembersMessageDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite parent) { initializeDialogUnits(parent);//from w w w . ja v a 2 s .c o m Composite messageComposite = new Composite(parent, SWT.NONE); messageComposite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); createLinkControl(messageComposite); int indent = convertWidthInCharsToPixels(3); fNotSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null), indent); fSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fSortAllRadio.getSelectionButton(null), indent); final Composite warningComposite = new Composite(messageComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; warningComposite.setLayout(layout); warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); warningComposite.setFont(messageComposite.getFont()); Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); final Label imageLabel1 = new Label(warningComposite, SWT.LEFT | SWT.WRAP); imageLabel1.setImage(image); imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1)); final Label label = new Label(warningComposite, SWT.WRAP); label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1); gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(gridData); label.setFont(warningComposite.getFont()); fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() { @Override public void dialogFieldChanged(DialogField field) { imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); } }); imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); return messageComposite; }
From source file:com.htmlhifive.tools.jslint.dialog.OptionSettingDialog.java
License:Apache License
/** * ??.//from w w w . ja v a2 s . co m * * @param errorMessages */ private void updateErrorMessage(String[] errorMessages) { if (errorMessages == null || errorMessages.length == 0) { messageLabel.setText(Messages.DT0006.getText()); messageLabel.setImage(null); return; } messageLabel.setText(StringUtils.join(errorMessages, " ")); messageLabel.setImage(Dialog.getImage(DLG_IMG_MESSAGE_ERROR)); }
From source file:com.htmlhifive.tools.wizard.download.DownloadModule.java
License:Apache License
/** * 1????./*from w ww . ja v a 2 s . com*/ * * @param monitor * @param totalWork * @param iFile * @param fileContentsHandler ? * @throws IOException IO * @return ? */ private boolean updateFile(IProgressMonitor monitor, int totalWork, ResultStatus logger, IFile iFile, IFileContentsHandler fileContentsHandler) throws IOException { // PI0112=INFO,[{0}]... monitor.subTask(Messages.PI0112.format(iFile.getFullPath())); int ret = 0; InputStream is = null; try { if (iFile.exists()) { // ????. if (defaultOverwriteMode != 0) { ret = defaultOverwriteMode; } else { MessageDialog dialog = new MessageDialog(null, Messages.SE0113.format(), Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO), Messages.SE0114.format(iFile.getRawLocation().toString()), MessageDialog.QUESTION, new String[] { UIMessages.Dialog_OVERWRITE, UIMessages.Dialog_ALL_OVERWRITE, UIMessages.Dialog_IGNORE, UIMessages.Dialog_ALL_IGNORE }, 0); ret = dialog.open(); } switch (ret) { case 1: defaultOverwriteMode = ret; case 0: // ???. logger.log(Messages.SE0097, iFile.getFullPath()); is = fileContentsHandler.getInputStream(); iFile.setContents(is, true, true, null); logger.log(Messages.SE0098, iFile.getFullPath()); break; case 3: defaultOverwriteMode = ret; case 2: // ?. break; } } else { if (!iFile.getParent().exists()) { // ??. H5IOUtils.createParentFolder(iFile.getParent(), null); } is = fileContentsHandler.getInputStream(); logger.log(Messages.SE0091, iFile.getFullPath()); iFile.create(is, true, null); logger.log(Messages.SE0092, iFile.getFullPath()); } return true; } catch (CoreException e) { // SE0024=ERROR,({0})??????? logger.log(e, Messages.SE0024, iFile.getFullPath().toString()); } finally { IOUtils.closeQuietly(is); } return false; }
From source file:com.htmlhifive.tools.wizard.download.DownloadModule.java
License:Apache License
/** * 1???.//from w w w . j ava 2 s . co m * * @param monitor * @param totalWork * @param file * @param uri URI * @throws CoreException */ private ZipFile download(final IProgressMonitor monitor, final int totalWork, ResultStatus logger, IFile file, final String urlStr) throws CoreException { // PI0111=INFO,[{0}]... monitor.subTask(Messages.PI0111.format(urlStr)); lastDownloadStatus = false; int ret = 0; while (ret == 0) { try { if (file != null) { // ??. IConnectMethod method = ConnectMethodFactory.getMethod(urlStr, true); method.setConnectionTimeout(PluginConstant.URL_LIBRARY_CONNECTION_TIMEOUT); method.setProxy(getProxyService()); method.getInputStream(); boolean updateResult = updateFile(monitor, 0, logger, file, method); if (updateResult) { lastDownloadStatus = true; } monitor.worked(totalWork); } else { // file?null?????ZipFile???. BufferedInputStream bufferIs = null; OutputStream os = null; try { IConnectMethod method = ConnectMethodFactory.getMethod(urlStr, true); method.setConnectionTimeout(PluginConstant.URL_LIBRARY_CONNECTION_TIMEOUT); method.setProxy(getProxyService()); if (!method.connect()) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(Messages.SE0101, urlStr, file != null ? file.toString() : ""); return null; } final int contentLength = method.getContentLength(); // final int perWork; // if (contentLength > 0) { // perWork = Math.max(1, totalWork * DEFAULT_BUFFER_SIZE / 8 / contentLength); // }else{ // perWork = totalWork; // } InputStream is = method.getInputStream(); // if (H5IOUtils.isClassResources(urlStr)) { // // url?null??????. // is = DownloadModule.class.getResourceAsStream(urlStr); // } else { // // ?URL // HttpMethod method = DownloadModule.this.connect(urlStr, // PluginResource.URL_LIBRARY_CONNECTION_TIMEOUT); // if (method == null) { // return null; // } // // // ??????. // Header header = method.getResponseHeader("Content-Length"); // if (header != null) { // contentLength = Integer.valueOf(header.getValue()); // } // if (contentLength > 0) { // perWork = Math.max(1, perWork * DEFAULT_BUFFER_SIZE / contentLength); // } // is = method.getResponseBodyAsStream(); // } if (is == null) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(Messages.SE0101, urlStr, file != null ? file.toString() : ""); return null; } bufferIs = new BufferedInputStream(is) { private int current = 0; private final int perWork = Math.max(1, totalWork * buf.length / 8 / contentLength); @Override public synchronized int read() throws IOException { int result = super.read(); current += result * 16; monitor.subTask(Messages.PI0143.format(current, contentLength, urlStr)); //monitor.worked(result * 16); monitor.worked(perWork); return result; } }; // SE0093=INFO,{0}??? logger.log(Messages.SE0093, urlStr); // ZIP. File tempFile = File.createTempFile(H5WizardPlugin.getId(), "tmp"); // VM????. tempFile.deleteOnExit(); // ??. os = FileUtils.openOutputStream(tempFile); IOUtils.copy(bufferIs, os); // byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; // int n = 0; // while (-1 != (n = is.read(buffer))) { // os.write(buffer, 0, n); // if (contentLength > 0) { // monitor.worked(perWork); // } // } if (contentLength == 0) { monitor.worked(totalWork); } // SE0094=INFO,{0}???? logger.log(Messages.SE0094, urlStr); lastDownloadStatus = true; return new ZipFile(tempFile); } finally { IOUtils.closeQuietly(bufferIs); IOUtils.closeQuietly(os); } } ret = 1; } catch (IOException e) { // SE0101=ERROR,({0})??????URL={1}, File={2} logger.log(e, Messages.SE0101, urlStr, file != null ? file.toString() : ""); // ?????. MessageDialog dialog = new MessageDialog(null, Messages.SE0115.format(), Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING), Messages.SE0116.format(urlStr), MessageDialog.QUESTION, new String[] { UIMessages.Dialog_RETRY, UIMessages.Dialog_IGNORE, UIMessages.Dialog_STOP }, 0); ret = dialog.open(); if (ret == 2) { // throw new OperationCanceledException( Messages.SE0101.format(urlStr, file != null ? file.toString() : "")); } } } return null; }
From source file:ext.org.eclipse.jdt.internal.ui.dialogs.SortMembersMessageDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite parent) { initializeDialogUnits(parent);// ww w.ja va 2s . co m Composite messageComposite = new Composite(parent, SWT.NONE); messageComposite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); createLinkControl(messageComposite); int indent = convertWidthInCharsToPixels(3); fNotSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null), indent); fSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fSortAllRadio.getSelectionButton(null), indent); final Composite warningComposite = new Composite(messageComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; warningComposite.setLayout(layout); warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); warningComposite.setFont(messageComposite.getFont()); Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); final Label imageLabel1 = new Label(warningComposite, SWT.LEFT | SWT.WRAP); imageLabel1.setImage(image); imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1)); final Label label = new Label(warningComposite, SWT.WRAP); label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1); gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(gridData); label.setFont(warningComposite.getFont()); fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); } }); imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); return messageComposite; }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.cleanup.CodeFormatingTabPage.java
License:Open Source License
@Override protected void doCreatePreferences(Composite composite, int numColumns) { Group group = createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_GroupName_Formatter); if (!isSaveAction()) { final CheckboxPreference format = createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatSourceCode, CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpModifyDialog.FALSE_TRUE); registerPreference(format);//from w w w .j a va 2 s. c o m format.addObserver(new Observer() { public void update(Observable o, Object arg) { fPreview.setFormat(format.getChecked()); fPreview.update(); } }); } final CheckboxPreference whiteSpace = createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES, CleanUpModifyDialog.FALSE_TRUE); intent(group); final RadioPreference allPref = createRadioPref(group, 1, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL, CleanUpModifyDialog.FALSE_TRUE); final RadioPreference ignoreEmptyPref = createRadioPref(group, 1, CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio, CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, CleanUpModifyDialog.FALSE_TRUE); registerSlavePreference(whiteSpace, new RadioPreference[] { allPref, ignoreEmptyPref }); final CheckboxPreference correctIndentation = createCheckboxPref(group, numColumns, CleanUpMessages.CodeFormatingTabPage_correctIndentation_checkbox_text, CleanUpConstants.FORMAT_CORRECT_INDENTATION, CleanUpModifyDialog.FALSE_TRUE); registerPreference(correctIndentation); correctIndentation.addObserver(new Observer() { public void update(Observable o, Object arg) { fPreview.setCorrectIndentation(correctIndentation.getChecked()); fPreview.update(); } }); if (!isSaveAction()) { createLabel(numColumns, group, CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description) .setFont(composite.getFont()); Group importsGroup = createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_Imports_GroupName); CheckboxPreference organizeImports = createCheckboxPref(importsGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_OrganizeImports_CheckBoxLable, CleanUpConstants.ORGANIZE_IMPORTS, CleanUpModifyDialog.FALSE_TRUE); registerPreference(organizeImports); createLabel(numColumns, importsGroup, CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description) .setFont(composite.getFont()); } Group sortMembersGroup = createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_SortMembers_GroupName); final CheckboxPreference sortMembersPref = createCheckboxPref(sortMembersGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_SortMembers_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS, CleanUpModifyDialog.FALSE_TRUE); intent(sortMembersGroup); final RadioPreference sortAllPref = createRadioPref(sortMembersGroup, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_SortMembersFields_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS_ALL, CleanUpModifyDialog.FALSE_TRUE); intent(sortMembersGroup); final Button nullRadio = new Button(sortMembersGroup, SWT.RADIO); nullRadio.setText(CleanUpMessages.CodeFormatingTabPage_SortMembersExclusive_radio0); nullRadio.setLayoutData(createGridData(numColumns - 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT)); nullRadio.setFont(composite.getFont()); intent(sortMembersGroup); final Label warningImage = new Label(sortMembersGroup, SWT.LEFT | SWT.WRAP); warningImage.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); warningImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); final Label warningLabel = createLabel(numColumns - 2, sortMembersGroup, CleanUpMessages.CodeFormatingTabPage_SortMembersSemanticChange_warning); registerSlavePreference(sortMembersPref, new RadioPreference[] { sortAllPref }); sortMembersPref.addObserver(new Observer() { public void update(Observable o, Object arg) { nullRadio.setEnabled(sortMembersPref.getChecked()); boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked(); warningImage.setEnabled(warningEnabled); warningLabel.setEnabled(warningEnabled); } }); sortAllPref.addObserver(new Observer() { public void update(Observable o, Object arg) { boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked(); warningImage.setEnabled(warningEnabled); warningLabel.setEnabled(warningEnabled); } }); nullRadio.setEnabled(sortMembersPref.getChecked()); nullRadio.setSelection(CleanUpOptions.FALSE.equals(fValues.get(CleanUpConstants.SORT_MEMBERS_ALL))); boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked(); warningImage.setEnabled(warningEnabled); warningLabel.setEnabled(warningEnabled); createLabel(numColumns, sortMembersGroup, CleanUpMessages.CodeFormatingTabPage_SortMembers_Description); }
From source file:ext.org.eclipse.jdt.internal.ui.refactoring.reorg.RenameTypeWizardSimilarElementsOptionsDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite parent) { initializeDialogUnits(parent);/*from w ww. j a v a2s . c om*/ Composite messageComposite = new Composite(parent, SWT.NONE); messageComposite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label infoLabel = new Label(messageComposite, SWT.WRAP); infoLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_select_strategy); GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false); gd.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); infoLabel.setLayoutData(gd); infoLabel.setFont(parent.getFont()); int indent = convertWidthInCharsToPixels(3); fExactStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fExactStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_1); fExactStrategyRadio.doFillIntoGrid(messageComposite, 1); fExactStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EXACT); LayoutUtil.setHorizontalIndent(fExactStrategyRadio.getSelectionButton(null), indent); fEmbeddedStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fEmbeddedStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_2); fEmbeddedStrategyRadio.doFillIntoGrid(messageComposite, 1); fEmbeddedStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EMBEDDED); LayoutUtil.setHorizontalIndent(fEmbeddedStrategyRadio.getSelectionButton(null), indent); fSuffixStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fSuffixStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_3); fSuffixStrategyRadio.doFillIntoGrid(messageComposite, 1); fSuffixStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_SUFFIX); LayoutUtil.setHorizontalIndent(fSuffixStrategyRadio.getSelectionButton(null), indent); final Composite warningComposite = new Composite(messageComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; warningComposite.setLayout(layout); warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); warningComposite.setFont(messageComposite.getFont()); Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); fWarningImageLabel = new Label(warningComposite, SWT.LEFT | SWT.WRAP); fWarningImageLabel.setImage(image); fWarningImageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1)); fWarningLabel = new Label(warningComposite, SWT.WRAP); fWarningLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1); gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); fWarningLabel.setLayoutData(gridData); fWarningLabel.setFont(warningComposite.getFont()); fExactStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EXACT; } }); fEmbeddedStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EMBEDDED; } }); fSuffixStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_SUFFIX; } }); updateLabel(); return messageComposite; }
From source file:melnorme.util.swt.components.misc.StatusMessageWidget.java
License:Open Source License
public static Image getImageForSeverity(Severity severity) { switch (severity) { case INFO:/*from w ww .ja va2s .c om*/ return Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO); case WARNING: return Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); case ERROR: return Dialog.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); } throw assertFail(); }
From source file:net.refractions.udig.tools.edit.EditBlackboardUtil.java
License:Open Source License
public static void openDataChangedDialog(final ILayer layer, final Envelope dirtyArea) { Display d = Display.getCurrent();// www. ja v a2 s . c o m if (d == null) d = Display.getDefault(); Condition condition = blackboardLock.newCondition(); try { blackboardLock.lock(); if (dialog != null) { // we're in the display thread, which means that the viewport is repainting since the dialog has any other input blocked. // so just return if (Display.getCurrent() != null) return; // the issue is being resolved we should wait for it to be resolved. while (dialog != null) { try { condition.await(500, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { return; } } return; } } finally { blackboardLock.unlock(); } PlatformGIS.syncInDisplayThread(d, new Runnable() { public void run() { try { blackboardLock.lock(); if (dirtyAreas.get(layer) == null) return; dialog = new Dialog(Display.getCurrent().getActiveShell()) { private final int UPDATE = 1; private final int CLEAR = 2; private final int IGNORE = 3; public Control createDialogArea(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); Display display = Display.getCurrent(); Label label = new Label(comp, SWT.NONE); label.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); label.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); label.setImage(Dialog.getImage(Dialog.DLG_IMG_WARNING)); label.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); Text text = new Text(comp, SWT.WRAP | SWT.READ_ONLY); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); text.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); text.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); text.setText(Messages.EditBlackboardUtil_data_changed); return comp; } public void createButtonsForButtonBar(Composite composite) { createButton(composite, UPDATE, Messages.EditBlackboardUtil_update, false); createButton(composite, CLEAR, Messages.EditBlackboardUtil_clear, true); createButton(composite, IGNORE, Messages.EditBlackboardUtil_ignore, false); } public void buttonPressed(int button) { switch (button) { case UPDATE: { boolean ok = MessageDialog.openConfirm(getParentShell(), Messages.EditBlackboardUtil_Update_Selection, Messages.EditBlackboardUtil_update_selection_confirmation); if (ok) { try { ProgressMonitorDialog d = new ProgressMonitorDialog(this.getParentShell()); blackboardLock.unlock(); d.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { updateFeatures(layer, monitor, dirtyArea); } }); okPressed(); } catch (Exception e) { EditPlugin.log("", e); //$NON-NLS-1$ } } break; } case CLEAR: { boolean ok = MessageDialog.openConfirm(getParentShell(), Messages.EditBlackboardUtil_clear_selection, Messages.EditBlackboardUtil_changes_will_be_lost); if (ok) { blackboardLock.unlock(); (getEditBlackBoardFromLayer(layer)).clear(); layer.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE, null); ((EditManager) layer.getMap().getEditManager()).setEditFeature(null, null); okPressed(); } break; } case IGNORE: boolean ok = MessageDialog.openConfirm(getParentShell(), Messages.EditBlackboardUtil_ignore_change, Messages.EditBlackboardUtil_changes_will_be_overwritten); if (ok) { okPressed(); } break; default: cancelPressed(); break; } } public void okPressed() { dirtyAreas.remove(layer); super.okPressed(); } }; dialog.setBlockOnOpen(true); dialog.open(); } finally { blackboardLock.unlock(); dialog = null; } } }); }
From source file:org.eclipse.m2e.core.ui.internal.util.M2EUIUtils.java
License:Open Source License
/** * @param shell/*from www .j a va 2 s . com*/ * @param string * @param string2 * @param updateErrors */ public static void showErrorsForProjectsDialog(final Shell shell, final String title, final String message, final Map<String, Throwable> errorMap) { // TODO Auto-generated method showErrorsForProjectsDialog Display.getDefault().asyncExec(new Runnable() { public void run() { String[] buttons = { IDialogConstants.OK_LABEL }; int ok_button = 0; M2EErrorDialog errDialog = new M2EErrorDialog(shell, title, Dialog.getImage(Dialog.DLG_IMG_MESSAGE_ERROR), message, MessageDialog.ERROR, buttons, ok_button, errorMap); errDialog.create(); errDialog.open(); } }); }