List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.
Click Source Link
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.core.SQLExecutionJobListener.java
License:Open Source License
public void done(IJobChangeEvent event) { if (_editor == null) { SOEUIPlugin.getActiveWorkbenchShell().getDisplay().syncExec(new Runnable() { public void run() { if (_monitor != null) { _monitor.setCanceled(true); }/*from ww w . j a v a 2s . c o m*/ } }); return; } if (event.getResult().isOK()) { final ISchemaObjectEditorInput input = (ISchemaObjectEditorInput) _editor.getEditorInput(); input.getEditModelObject().stopLogging(); // Check if the editor is disposed // [544833-1] we also need to refresh database while use close dirty editor part and save the edit result at // the same time IEditorPart part = SOEUIPlugin.getActiveWorkbenchPage().findEditor(_editor.getEditorInput()); if (part != null) { SOEUIPlugin.getActiveWorkbenchShell().getDisplay().syncExec(new Runnable() { public void run() { _editor.setEditorPartName(input.getEditModelObject().getMainSQLObject().getName()); } }); } ISchemaObjectEditorHandler handler = _editor.getEditorHandler(); if (handler != null && _editor.needRefreshAfterSave()) { // Set the name of the immutable model to make it consistent with edit model RefreshEditModelJob refreshJob = new RefreshEditModelJob( Messages.SQLExecutionJobListener_refreshing, handler); refreshJob.setUser(true); refreshJob.schedule(); refreshJob.addJobChangeListener(new JobChangeAdapter() { public void done(IJobChangeEvent event) { super.done(event); SOEUIPlugin.getActiveWorkbenchShell().getDisplay().syncExec(new Runnable() { public void run() { if (_monitor != null) { _monitor.done(); } } }); } }); } } // not all the scripts are successfully executed else { SOEUIPlugin.getActiveWorkbenchShell().getDisplay().syncExec(new Runnable() { public void run() { String[] buttons = new String[] { IDialogConstants.YES_LABEL }; MessageDialog d = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(), Messages.SavePreviewDialog_problem, null, Messages.SavePreviewDialog_execution_failed_msg, MessageDialog.ERROR, buttons, 0); d.open(); if (_monitor != null) { _monitor.setCanceled(true); } } }); } }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.preference.SchemaObjectEditorPreferencePage.java
License:Open Source License
protected Control createContents(Composite parent) { _parent = parent;/*from w ww .j a va 2 s. c o m*/ GridLayout layout = new GridLayout(); parent.setLayout(layout); Composite container = new Composite(parent, SWT.NONE); layout = new GridLayout(); container.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); container.setLayoutData(gd); Group editorsComp = new Group(container, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); layout = new GridLayout(); layout.numColumns = 4; layout.makeColumnsEqualWidth = true; editorsComp.setLayout(layout); editorsComp.setText(Messages.SchemaObjectEditorPreferencePage_available_editors); editorsComp.setLayoutData(gd); Composite dbdefsComp = new Composite(editorsComp, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; dbdefsComp.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; dbdefsComp.setLayoutData(gd); Label dbTypeLabel = new Label(dbdefsComp, SWT.NONE); dbTypeLabel.setText(Messages.SchemaObjectEditorPreferencePage_databaseType); _dbType = new Combo(dbdefsComp, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; _dbType.setLayoutData(gd); Composite edComp = new Composite(editorsComp, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; edComp.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; edComp.setLayoutData(gd); Label editorTypeLabel = new Label(edComp, SWT.NONE); editorTypeLabel.setText(Messages.SchemaObjectEditorPreferencePage_editors); _editorName = new Combo(edComp, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; _editorName.setLayoutData(gd); Group pagesComp = new Group(container, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); layout = new GridLayout(); layout.numColumns = 3; pagesComp.setLayout(layout); pagesComp.setLayoutData(gd); pagesComp.setText(Messages.SchemaObjectEditorPreferencePage_pagesSetting); Composite selectedComposite = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); selectedComposite.setLayoutData(gd); layout = new GridLayout(); selectedComposite.setLayout(layout); Label selectedPages = new Label(selectedComposite, SWT.NONE); selectedPages.setText(Messages.SchemaObjectEditorPreferencePage_selected_pages); gd = new GridData(); gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; selectedPages.setLayoutData(gd); _displayedPages = new List(selectedComposite, SWT.BORDER | SWT.MULTI); gd = new GridData(GridData.FILL_BOTH); _displayedPages.setLayoutData(gd); Composite buttonsComp = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_VERTICAL); buttonsComp.setLayoutData(gd); layout = new GridLayout(); buttonsComp.setLayout(layout); GC gc = new GC(buttonsComp); int maxAddRemoveButtonsWidth = computeMaxAddRemoveButtonsWidth(gc); gc.dispose(); new Label(buttonsComp, SWT.NONE); _rightOne = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _rightOne.setLayoutData(gd); _rightOne.setText(Messages.SchemaObjectEditorPreferencePage_remove); _rightOne.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _displayedPages.getSelection(); boolean isSucceeded = false; int movedNum = 0; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _displayedPages.getData(name); IEditorPageDescriptor page = (IEditorPageDescriptor) data; if (page.isRequired()) { continue; } _hiddenPages.add(name); _hiddenPages.setData(name, data); _displayedPages.remove(name); isSucceeded = true; movedNum++; } setOrClearErrorMsg(); if (!isSucceeded) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_error, null, Messages.SchemaObjectEditorPreferencePage_can_not_remove, MessageDialog.ERROR, buttons, 0); d.open(); } else { _dirty = true; int[] indecies = new int[movedNum]; for (int i = 0; i < movedNum; i++) { indecies[i] = _hiddenPages.getItemCount() - 1 - i; } _hiddenPages.setSelection(indecies); } setButtonStatus(); } }); _rightAll = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _rightAll.setLayoutData(gd); _rightAll.setText(Messages.SchemaObjectEditorPreferencePage_remove_all); _rightAll.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _displayedPages.getItems(); boolean isSucceeded = false; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _displayedPages.getData(name); IEditorPageDescriptor page = (IEditorPageDescriptor) data; if (page.isRequired()) { continue; } _hiddenPages.add(name); _hiddenPages.setData(name, data); _displayedPages.remove(name); isSucceeded = true; } setOrClearErrorMsg(); setButtonStatus(); if (!isSucceeded) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_erroe, null, Messages.SchemaObjectEditorPreferencePage_can_not_remove, MessageDialog.ERROR, buttons, 0); d.open(); } else { _dirty = true; } } }); _leftOne = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _leftOne.setLayoutData(gd); _leftOne.setText(Messages.SchemaObjectEditorPreferencePage_add); _leftOne.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _hiddenPages.getSelection(); int movedNum = 0; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _hiddenPages.getData(name); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(_editorName.getText()); IEditorPageDescriptor page = (IEditorPageDescriptor) data; boolean isPageMandatoryFirstOne = editor.getMandatoryFirstPage() != null && editor.getMandatoryFirstPage().getPageId().equals(page.getPageId()); boolean isPageMandatoryLastOne = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(page.getPageId()); if (isPageMandatoryFirstOne) { _displayedPages.add(name, 0); _displayedPages.setData(name, data); } else if (isPageMandatoryLastOne) { _displayedPages.add(name, _displayedPages.getItemCount()); _displayedPages.setData(name, data); } else { // Check if the last visible page is a mandatory page if (_displayedPages.getItemCount() > 0) { String displayedLastOne = _displayedPages.getItem(_displayedPages.getItemCount() - 1); IEditorPageDescriptor displayedLast = (IEditorPageDescriptor) _displayedPages .getData(displayedLastOne); boolean isLastPageMandatory = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(displayedLast.getPageId()); if (isLastPageMandatory) { _displayedPages.add(name, _displayedPages.getItemCount() - 1); _displayedPages.setData(name, data); } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } _hiddenPages.remove(name); movedNum++; } setOrClearErrorMsg(); if (movedNum > 0) { _dirty = true; } int[] indecies = new int[movedNum]; for (int i = 0; i < movedNum; i++) { indecies[i] = _displayedPages.getItemCount() - 1 - i; } _displayedPages.setSelection(indecies); setButtonStatus(); } }); _leftAll = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _leftAll.setLayoutData(gd); _leftAll.setText(Messages.SchemaObjectEditorPreferencePage_add_all); _leftAll.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _hiddenPages.getItems(); for (int i = 0; i < selectedItems.length; i++) { _dirty = true; String name = selectedItems[i]; Object data = _hiddenPages.getData(name); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(_editorName.getText()); IEditorPageDescriptor page = (IEditorPageDescriptor) data; boolean isPageMandatoryFirstOne = editor.getMandatoryFirstPage() != null && editor.getMandatoryFirstPage().getPageId().equals(page.getPageId()); boolean isPageMandatoryLastOne = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(page.getPageId()); if (isPageMandatoryFirstOne) { _displayedPages.add(name, 0); _displayedPages.setData(name, data); } else if (isPageMandatoryLastOne) { _displayedPages.add(name, _displayedPages.getItemCount()); _displayedPages.setData(name, data); } else { // Check if the last visible page is a mandatory page if (_displayedPages.getItemCount() > 0) { String displayedLastOne = _displayedPages.getItem(_displayedPages.getItemCount() - 1); IEditorPageDescriptor displayedLast = (IEditorPageDescriptor) _displayedPages .getData(displayedLastOne); boolean isLastPageMandatory = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(displayedLast.getPageId()); if (isLastPageMandatory) { _displayedPages.add(name, _displayedPages.getItemCount() - 1); _displayedPages.setData(name, data); } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } _hiddenPages.remove(name); } setOrClearErrorMsg(); setButtonStatus(); } }); _upMove = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _upMove.setLayoutData(gd); _upMove.setText(Messages.SchemaObjectEditorPreferencePage_move_up); _upMove.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { moveItem(_displayedPages, true); } }); _downMove = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _downMove.setLayoutData(gd); _downMove.setText(Messages.SchemaObjectEditorPreferencePage_move_down); _downMove.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { moveItem(_displayedPages, false); } }); Composite availableComp = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); availableComp.setLayoutData(gd); layout = new GridLayout(); availableComp.setLayout(layout); Label availablePages = new Label(availableComp, SWT.NONE); availablePages.setText(Messages.SchemaObjectEditorPreferencePage_available_pages); gd = new GridData(); gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; availablePages.setLayoutData(gd); _hiddenPages = new List(availableComp, SWT.BORDER | SWT.MULTI); gd = new GridData(GridData.FILL_BOTH); _hiddenPages.setLayoutData(gd); final Map editorsMap = SchemaObjectEditorUtils.getEditorsCatalogedByDBDefinition(); // Sort the dbdefinitions java.util.List keys = new ArrayList(); Iterator iter = editorsMap.keySet().iterator(); while (iter.hasNext()) { String dbdefi = (String) iter.next(); keys.add(dbdefi); } Collections.sort(keys); iter = keys.iterator(); while (iter.hasNext()) { String dbdefi = (String) iter.next(); _dbType.add(dbdefi); } _dbType.setFocus(); _dbType.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { String dbdefi = _dbType.getText(); if (dbdefi != null && dbdefi.trim().length() != 0) { _editorName.removeAll(); java.util.List editors = (java.util.List) editorsMap.get(dbdefi); if (editors != null) { Collections.sort(editors, new EditorComparator()); Iterator iter = editors.iterator(); while (iter.hasNext()) { IEditorDescriptor editor = (IEditorDescriptor) iter.next(); _editorName.add(editor.getEditorName()); _editorName.setData(editor.getEditorName(), editor); } } if (_editorName.getItemCount() > 0) { _editorName.select(0); _editorName.notifyListeners(SWT.Selection, new Event()); } } } }); _editorName.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String name = _editorName.getText(); if (_dirty && isValid()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_question, null, Messages.SchemaObjectEditorPreferencePage_save_modification, MessageDialog.QUESTION, buttons, 0); int result = d.open(); switch (result) { case 0: savePreferences(); break; case 1: break; default: break; } } _dirty = false; if (name != null && name.trim().length() != 0) { _displayedPages.removeAll(); _hiddenPages.removeAll(); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(name); if (editor != null) { IEditorPageDescriptor[] pages = editor.getPageDescriptors(); for (int i = 0; i < pages.length; i++) { if (!_store.getBoolean(Constants.EDITOR_PAGE_VISIABILITY + pages[i].getEditorId() + pages[i].getPageId())) { _hiddenPages.add(pages[i].getPageName()); _hiddenPages.setData(pages[i].getPageName(), pages[i]); } } IEditorPageDescriptor[] sortedPages = editor.getSortedPages(); for (int j = 0; j < sortedPages.length; j++) { if (sortedPages[j].isSelectedToShow()) { _displayedPages.add(sortedPages[j].getPageName()); _displayedPages.setData(sortedPages[j].getPageName(), sortedPages[j]); } } } setOrClearErrorMsg(); setButtonStatus(); } } }); String preDBdef = _store.getString(Constants.PREFERENCE_PREVIOUS_DB_DEFINITION); String preEditor = _store.getString(Constants.PREFERENCE_PREVIOUS_EDIOR_NAME); if (preDBdef != null) { int index = _dbType.indexOf(preDBdef); if (index != -1) { _dbType.select(index); _dbType.notifyListeners(SWT.Selection, new Event()); } } if (preEditor != null) { int index = _editorName.indexOf(preEditor); if (index != -1) { _editorName.select(index); _editorName.notifyListeners(SWT.Selection, new Event()); } } _displayedPages.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { setButtonStatus(); } }); _hiddenPages.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { setButtonStatus(); } }); setButtonStatus(); _alwaysShowPreview = new Button(container, SWT.CHECK); _alwaysShowPreview.setText(Messages.SchemaObjectEditorPreferencePage_always_show_preview); _alwaysShowPreview.setSelection(_store.getBoolean(Constants.PREFERENCE_ALWAYS_SHOW_PREVIEW)); _promptIfNoExactEditorFound = new Button(container, SWT.CHECK); _promptIfNoExactEditorFound.setText(Messages.SchemaObjectEditorPreferencePage_use_latest_version_to_open); _promptIfNoExactEditorFound .setToolTipText(Messages.SchemaObjectEditorPreferencePage_latest_version_open_tooltip); _promptIfNoExactEditorFound.setSelection(_store.getBoolean(Constants.PREFERENCE_USE_LATEST_VERSION)); // add by sul - CR470356-2 _checkWhenActivated = new Button(container, SWT.CHECK); _checkWhenActivated.setText(Messages.SchemaObjectEditorPreferencePage_check_existence_when_activated); _checkWhenActivated.setSelection(_store.getBoolean(Constants.PREFERENCE_CHECK_EXISTENCE)); _checkWhenActivated .setToolTipText(Messages.SchemaObjectEditorPreferencePage_check_existence_when_activated_tooltip); // add end // add by sul - CR497357-1 _openFileAfterSaveas = new Button(container, SWT.CHECK); _openFileAfterSaveas.setText(Messages.SchemaObjectEditorPreferencePage_open_file_after_saveas); _openFileAfterSaveas.setSelection(_store.getBoolean(Constants.PREFERENCE_OPEN_FILE_AFTER_SAVEAS)); _openFileAfterSaveas .setToolTipText(Messages.SchemaObjectEditorPreferencePage_open_file_after_saveas_tooltip); // add end return container; }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.preference.SchemaObjectEditorPreferencePage.java
License:Open Source License
private void moveItem(List list, boolean upDirection) { if (list.getItemCount() == 0) { // no item } else if (list.getSelectionCount() == 0) { // no selection } else if (list.getSelectionCount() > 1) { // multiple selections } else if (list.getSelectionIndex() == 0 && upDirection) { // can not move the top one up } else if (list.getSelectionIndex() == list.getItemCount() - 1 && !upDirection) { // can not move the lowest one down } else {/* ww w.j a v a2 s . c o m*/ int selectionIndex = list.getSelectionIndex(); String selectionItem = list.getItem(selectionIndex); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(_editorName.getText()); String firstItem = list.getItem(0); String lastItem = list.getItem(list.getItemCount() - 1); IEditorPageDescriptor firstPage = (IEditorPageDescriptor) _displayedPages.getData(firstItem); IEditorPageDescriptor lastPage = (IEditorPageDescriptor) _displayedPages.getData(lastItem); boolean isFirstPageMandatory = editor.getMandatoryFirstPage() != null && editor.getMandatoryFirstPage().getPageId().equals(firstPage.getPageId()); boolean isLastPageMandatory = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(lastPage.getPageId()); // can not move the mandatory first page if (!upDirection && selectionIndex == 0 && isFirstPageMandatory) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), "Error", null, //$NON-NLS-1$ Messages.SchemaObjectEditorPreferencePage_must_be_first, MessageDialog.ERROR, buttons, 0); d.open(); return; } // can not move the mandatory last page if (upDirection && selectionIndex == list.getItemCount() - 1 && isLastPageMandatory) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), "Error", null, //$NON-NLS-1$ Messages.SchemaObjectEditorPreferencePage_must_be_last, MessageDialog.ERROR, buttons, 0); d.open(); return; } // move the second page to the first one if (upDirection && selectionIndex == 1 && isFirstPageMandatory) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), "Error", null, //$NON-NLS-1$ Messages.SchemaObjectEditorPreferencePage_can_not_up, MessageDialog.ERROR, buttons, 0); d.open(); return; } // move the last but one page to the last one if (!upDirection && selectionIndex == list.getItemCount() - 2 && isLastPageMandatory) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), "Error", null, //$NON-NLS-1$ Messages.SchemaObjectEditorPreferencePage_can_not_down, MessageDialog.ERROR, buttons, 0); d.open(); return; } _dirty = true; if (upDirection) { list.add(selectionItem, selectionIndex - 1); list.remove(selectionIndex + 1); list.select(selectionIndex - 1); } else { list.add(selectionItem, selectionIndex + 2); list.remove(selectionIndex); list.select(selectionIndex + 1); } setButtonStatus(); } }
From source file:org.eclipse.dltk.mod.ui.text.completion.CompletionProposalComputerRegistry.java
License:Open Source License
/** * Log the status and inform the user about a misbehaving extension. * // w ww . j av a2s. c om * @param descriptor the descriptor of the misbehaving extension * @param status a status object that will be logged */ void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) { DLTKUIPlugin.log(status); String title = ScriptTextMessages.CompletionProposalComputerRegistry_error_dialog_title; CompletionProposalCategory category = descriptor.getCategory(); IContributor culprit = descriptor.getContributor(); Set affectedPlugins = getAffectedContributors(category, culprit); final String avoidHint; final String culpritName = culprit == null ? null : culprit.getName(); if (affectedPlugins.isEmpty()) avoidHint = Messages.format(ScriptTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] { culpritName, category.getDisplayName() }); else avoidHint = Messages.format( ScriptTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) }); String message = status.getMessage(); // inlined from MessageDialog.openError MessageDialog dialog = new MessageDialog(DLTKUIPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { protected Control createCustomArea(Composite parent) { Link link = new Link(parent, SWT.NONE); link.setText(avoidHint); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.dltk.mod.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); return link; } }; dialog.open(); }
From source file:org.eclipse.dltk.ui.text.completion.CompletionProposalComputerRegistry.java
License:Open Source License
/** * Log the status and inform the user about a misbehaving extension. * //w w w . j av a 2 s . c o m * @param descriptor * the descriptor of the misbehaving extension * @param status * a status object that will be logged */ void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) { DLTKUIPlugin.log(status); String title = ScriptTextMessages.CompletionProposalComputerRegistry_error_dialog_title; CompletionProposalCategory category = descriptor.getCategory(); IContributor culprit = descriptor.getContributor(); Set<String> affectedPlugins = getAffectedContributors(category, culprit); final String avoidHint; final String culpritName = culprit == null ? null : culprit.getName(); if (affectedPlugins.isEmpty()) avoidHint = Messages.format(ScriptTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] { culpritName, category.getDisplayName() }); else avoidHint = Messages.format( ScriptTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) }); String message = status.getMessage(); // inlined from MessageDialog.openError MessageDialog dialog = new MessageDialog(DLTKUIPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { protected Control createCustomArea(Composite parent) { Link link = new Link(parent, SWT.NONE); link.setText(avoidHint); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil .createPreferenceDialogOn(getShell(), "org.eclipse.dltk.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); return link; } }; dialog.open(); }
From source file:org.eclipse.e4.xwt.tools.ui.designer.dialogs.AccessorConfigurationDialog.java
License:Open Source License
/** * If file already exist but with different case,show the dialog. *//*from w w w . jav a 2 s . c o m*/ private void showFileExistDialog(String name, String extension, String path) { String dialogMessage = "File '" + path.replace(".", "/") + "/" + name + extension + "' already exist with different case."; String[] dialogButtonLabels = { "Ok" }; MessageDialog messageDialog = new MessageDialog(getShell(), "Configure Accessor Class", null, dialogMessage, MessageDialog.ERROR, dialogButtonLabels, 1); messageDialog.open(); }
From source file:org.eclipse.ease.discovery.ui.internal.common.DiscoveryUiUtil.java
License:Open Source License
public static void displayStatus(Shell shell, final String title, final IStatus status, boolean showLinkToErrorLog) { String message = status.getMessage(); if (showLinkToErrorLog) { message += " \n see error log"; }//from w ww . j ava 2 s . c o m switch (status.getSeverity()) { case IStatus.CANCEL: case IStatus.INFO: createDialog(shell, title, message, MessageDialog.INFORMATION).open(); break; case IStatus.WARNING: createDialog(shell, title, message, MessageDialog.WARNING).open(); break; case IStatus.ERROR: default: createDialog(shell, title, message, MessageDialog.ERROR).open(); break; } }
From source file:org.eclipse.edt.ide.ui.internal.contentassist.EGLCompletionProposalComputerRegistry.java
License:Open Source License
void informUser(EGLCompletionProposalComputerDescriptor descriptor, IStatus status) { EDTUIPlugin.log(status);/*ww w .j a va2s. c o m*/ String title = EGLTextMessages.CompletionProposalComputerRegistry_error_dialog_title; EGLCompletionProposalCategory category = descriptor.getCategory(); IContributor culprit = descriptor.getContributor(); Set affectedPlugins = getAffectedContributors(category, culprit); final String avoidHint; final String culpritName = culprit == null ? null : culprit.getName(); if (affectedPlugins.isEmpty()) avoidHint = Messages.format(EGLTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] { culpritName, category.getDisplayName() }); else avoidHint = Messages.format( EGLTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) }); String message = status.getMessage(); // inlined from MessageDialog.openError MessageDialog dialog = new MessageDialog(EDTUIPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { protected Control createCustomArea(Composite parent) { Link link = new Link(parent, SWT.NONE); link.setText(avoidHint); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil .createPreferenceDialogOn(getShell(), "org.eclipse.edt.ide.ui.ContentAssistAdvancedPreferences", null, null) //$NON-NLS-1$ .open(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); return link; } }; dialog.open(); }
From source file:org.eclipse.egit.ui.internal.dialogs.SourceBranchFailureDialog.java
License:Open Source License
private SourceBranchFailureDialog(Shell parentShell, String cause) { super(parentShell, UIText.CloneFailureDialog_tile, null, null, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); this.cause = cause; }
From source file:org.eclipse.emf.compare.mpatch.extension.MPatchApplicationResult.java
License:Open Source License
/** * Show a dialog with some user friendly version of the application results. * /*ww w . ja v a2 s.c om*/ * @param shell * The shell. * @param adapterFactory * An adapter factory for some formatting ;-) */ public void showDialog(Shell shell, AdapterFactory adapterFactory) { final String msg = getMessage(adapterFactory); final int messageDialogType; // overall result if (ApplicationStatus.SUCCESSFUL.equals(status)) { messageDialogType = MessageDialog.INFORMATION; } else if (ApplicationStatus.REFERENCES.equals(status)) { messageDialogType = MessageDialog.WARNING; } else if (ApplicationStatus.FAILURE.equals(status)) { messageDialogType = MessageDialog.ERROR; } else { throw new IllegalStateException("Unknown result status!"); } // show the actual dialog MessageDialog.open(messageDialogType, shell, MPatchConstants.MPATCH_SHORT_NAME + " Application results", msg, SWT.NONE); }