List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:com.aptana.ide.core.ui.RESTServiceListener.java
License:Open Source License
/** * @see com.aptana.ide.core.model.RESTServiceProvider.Listener#authenticationFailed(com.aptana.ide.core.model.user.User) *//*from ww w. j a v a 2 s .c om*/ public void authenticationFailed(User user) { // Let user know UIJob uiJob = new UIJob("Signing Out") //$NON-NLS-1$ { @Override public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbench workbench = EclipseUtils.getWorkbenchInstance(); if (workbench != null && workbench.getActiveWorkbenchWindow() != null && workbench.getActiveWorkbenchWindow().getShell() != null) { MessageDialog.openInformation(workbench.getActiveWorkbenchWindow().getShell(), Messages.getString("RESTServiceProvider.CouldNotAuthenticateTitle"), //$NON-NLS-1$ Messages.getString("RESTServiceProvider.AuthenticationFailedSigningOut") + //$NON-NLS-1$ "\n\n" + //$NON-NLS-1$ Messages.getString("RESTServiceProvider.SignInWithCorrectCredentials")); //$NON-NLS-1$ } return Status.OK_STATUS; } }; uiJob.setPriority(UIJob.INTERACTIVE); uiJob.schedule(); }
From source file:com.aptana.ide.core.ui.WindowActionDelegate.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//* w w w.ja v a 2 s . c o m*/ public void run(IAction action) { String id = action.getId(); if (id.equals(VIEW_LOG_ID)) { String logFile = getLogFile(); try { WorkbenchHelper.openFile(new File(logFile), PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } catch (Exception e) { IdeLog.logError(CoreUIPlugin.getDefault(), StringUtils.format(Messages.WindowActionDelegate_UnableToOpenLogFile, logFile), e); } } else if (id.equals(CLEAR_LOG_ID)) { if (!MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.ClearLogConfirmTitle, Messages.ClearLogConfirmDescription)) { return; } String logFile = getLogFile(); try { File file = new File(logFile); FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.close(); } catch (Exception e) { IdeLog.logError(CoreUIPlugin.getDefault(), StringUtils.format(Messages.WindowActionDelegate_UnableToOpenLogFile, logFile), e); } } else if (id.equals("Overview.Action")) //$NON-NLS-1$ { String currentPerspectiveID = WebPerspectiveFactory.PERSPECTIVE_ID; try { IPerspectiveDescriptor desc = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getPerspective(); // If it is not one of ours, then just show the default if (!WebPerspectiveFactory.isSameOrDescendantPerspective(desc)) { MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.WindowActionDelegate_AptanaOverviewErrorTitle, Messages.WindowActionDelegate_AptanaOverviewErrorMessage); return; } } catch (Exception e) { } } else if (id.equals(CLEAN_CONFIG_ID)) { if (!MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.WindowActionDelegate_CleanConfigurationTitle, Messages.WindowActionDelegate_CleanConfigurationDescription)) { return; } IPreferenceStore prefs = CoreUIPlugin.getDefault().getPreferenceStore(); prefs.setValue(IPreferenceConstants.PREF_CLEAN_RESTART, true); window.getWorkbench().restart(); } else if (id.equals(LEARN_MORE_ID)) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault().getActiveShell(), LICENSE_PREFERENCE_ID, new String[] { LICENSE_PREFERENCE_ID }, null); dialog.open(); } }
From source file:com.aptana.ide.debug.internal.ui.actions.OpenScriptSourceAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.IAction#run() */// ww w . j a va 2 s. com public void run() { if (scriptElement == null) { selectionChanged(getStructuredSelection()); if (scriptElement == null) { return; } } String location = scriptElement.getLocation(); if (location == null || location.length() == 0) { return; } int lineNumber = scriptElement.getBaseLine(); try { Object sourceElement = DebugUITools.lookupSource(scriptElement, getSourceLocator(scriptElement)) .getSourceElement(); IEditorInput editorInput = SourceDisplayUtil.getEditorInput(sourceElement); if (editorInput != null) { SourceDisplayUtil.openInEditor(editorInput, lineNumber); return; } MessageDialog.openInformation(DebugUiPlugin.getActiveWorkbenchShell(), Messages.OpenScriptSourceAction_Information, StringUtils.format( Messages.OpenScriptSourceAction_SourceNotFoundFor_0, new String[] { location })); } catch (CoreException e) { DebugUiPlugin.errorDialog(Messages.OpenScriptSourceAction_ExceptionWhileOpeningScriptSource, e); } }
From source file:com.aptana.ide.debug.internal.ui.console.JSConsoleHyperlink.java
License:Open Source License
/** * @see org.eclipse.ui.console.IHyperlink#linkActivated() *///from ww w .jav a 2 s .c om public void linkActivated() { try { Object sourceElement = DebugUITools.lookupSource(fFilename, getSourceLocator()).getSourceElement(); IEditorInput editorInput = SourceDisplayUtil.getEditorInput(sourceElement); if (editorInput != null) { SourceDisplayUtil.openInEditor(editorInput, fLineNumber); return; } MessageDialog.openInformation(DebugUiPlugin.getActiveWorkbenchShell(), Messages.getString("JSConsoleHyperlink.Information"), //$NON-NLS-1$ StringUtils.format(Messages.getString("JSConsoleHyperlink.SourceNotFoundFor_0"), //$NON-NLS-1$ new String[] { fFilename })); } catch (CoreException e) { DebugUiPlugin.errorDialog(Messages.getString("JSConsoleHyperlink.ExceptionWhileFollowingLink"), e); //$NON-NLS-1$ } }
From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *///ww w . j a va 2s.c o m public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$ /* continue */ case 1: return new Boolean(true); case 3: WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$ return new Boolean(true); default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, new String[] { ((String) source).substring(5) })); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, new String[] { ((String) source).substring(10) })); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } } IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return new Boolean(true); } } String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, new String[] { (String) source }); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return new Boolean(true); case IDialogConstants.NO_ID: return new Boolean(false); default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.editor.css.preferences.PreviewPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) *///from w w w . j a v a 2 s . c o m protected Control createContents(Composite parent) { displayArea = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.makeColumnsEqualWidth = false; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 5; layout.horizontalSpacing = 0; displayArea.setLayout(layout); displayArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); useTempFiles = new Button(displayArea, SWT.CHECK); useTempFiles.setText(Messages.PreviewPreferencePage_UseTempFilesText); useTempFiles.setSelection(getPreferenceStore().getBoolean(IPreferenceConstants.USE_TEMP_FILES_FOR_PREVIEW)); description = new Label(displayArea, SWT.WRAP); description.setText(Messages.PreviewPreferencePage_DescriptionText); browsers = new Group(displayArea, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; browsers.setLayout(gridLayout); browsers.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); browsers.setText(Messages.PreviewPreferencePage_BrowsersText); Table table = new Table(browsers, SWT.CHECK | SWT.BORDER | SWT.SINGLE); table.setFont(parent.getFont()); previewViewer = new CheckboxTableViewer(table); previewViewer.setContentProvider(new ArrayContentProvider()); previewViewer.setLabelProvider(new LabelProvider()); previewViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (Platform.getOS().equals(Platform.OS_MACOSX)) { if (previewViewer.getChecked("Firefox") && !previewViewer.getChecked("Safari")) //$NON-NLS-1$ //$NON-NLS-2$ { MessageDialog.openInformation(getShell(), Messages.PreviewPreferencePage_FirefoxIssueTitle, Messages.PreviewPreferencePage_FireFoxIssueMessage); previewViewer.setChecked("Firefox", false); //$NON-NLS-1$ } } } }); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); addPreviewBrowsers(); addCheckedBrowsers(); Label templateDescription = new Label(displayArea, SWT.LEFT | SWT.WRAP); templateDescription.setText(Messages.PreviewPreferencePage_TemplateDescText); GridData tdData = new GridData(SWT.FILL, SWT.FILL, true, false); tdData.verticalIndent = 5; templateDescription.setLayoutData(tdData); boolean useTemplate = getPreferenceStore() .getBoolean(IPreferenceConstants.CSSEDITOR_BROWSER_USE_TEMPLATE_PREFERENCE); useCustomTemplate = new Button(displayArea, SWT.RADIO); useCustomTemplate.setText(Messages.PreviewPreferencePage_UseCustomTemplateText); useCustomTemplate.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean template = useCustomTemplate.getSelection(); defaultTemplate.setEnabled(template); globalUrlText.setEnabled(!template); browseButton.setEnabled(!template); } }); useCustomTemplate.setSelection(useTemplate); Group template = new Group(displayArea, SWT.NONE); template.setText(Messages.PreviewPreferencePage_TemplateGroupTitle); GridLayout tLayout = new GridLayout(1, true); tLayout.marginHeight = 0; tLayout.marginWidth = 0; template.setLayout(tLayout); GridData tData = new GridData(GridData.FILL, GridData.FILL, true, false); tData.horizontalIndent = 13; template.setLayoutData(tData); defaultTemplate = new Text(template, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); GridData dtData = new GridData(SWT.FILL, SWT.FILL, true, true); dtData.heightHint = 225; dtData.widthHint = 500; defaultTemplate.setText( getPreferenceStore().getString(IPreferenceConstants.CSSEDITOR_BROWSER_TEMPLATE_PREFERENCE)); defaultTemplate.setLayoutData(dtData); defaultTemplate.setEnabled(useTemplate); useUrl = new Button(displayArea, SWT.RADIO); useUrl.setText(Messages.PreviewPreferencePage_UseUrlText); useUrl.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean url = useUrl.getSelection(); defaultTemplate.setEnabled(!url); globalUrlText.setEnabled(url); browseButton.setEnabled(url); } }); useUrl.setSelection(!useTemplate); Composite globalUrl = new Composite(displayArea, SWT.NONE); GridLayout guLayout = new GridLayout(3, false); guLayout.marginHeight = 0; guLayout.marginWidth = 0; guLayout.marginBottom = 10; globalUrl.setLayout(guLayout); GridData gData = new GridData(GridData.FILL, GridData.FILL, true, false); gData.horizontalIndent = 15; globalUrl.setLayoutData(gData); globalUrlLabel = new Label(globalUrl, SWT.LEFT); globalUrlLabel.setText(Messages.PreviewPreferencePage_UrlLabel); globalUrlText = new Text(globalUrl, SWT.SINGLE | SWT.BORDER); globalUrlText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); globalUrlText .setText(getPreferenceStore().getString(IPreferenceConstants.CSSEDITOR_BROWSER_URL_PREFERENCE)); globalUrlText.setEnabled(!useTemplate); browseButton = new Button(globalUrl, SWT.PUSH); browseButton.setText(Messages.PreviewPreferencePage_BrowseText); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(browseButton.getShell(), SWT.OPEN); String file = dialog.open(); if (file != null) { globalUrlText.setText(file); } } }); browseButton.setEnabled(!useTemplate); return displayArea; }
From source file:com.aptana.ide.editor.text.preferences.TextEditorPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) *///from w ww . j a v a2 s . c om protected Control createContents(Composite parent) { this.noDefaultAndApplyButton(); changed = false; imagesToDispose = new ArrayList<Image>(); mappings = new ArrayList<FileEditorMapping>(); mappingsToGrammars = new HashMap<String, String>(); activeProviders = new HashMap<String, LanguageStructureProvider>(); displayArea = new Composite(parent, SWT.NONE); final Composite buffer = new Composite(displayArea, SWT.NONE); header = new PreferenceMastHead(buffer, Messages.TextEditorPreferencePage_Allows_Users_To_Create_Custom_Editors, 3, TextPlugin.getImageDescriptor("images/generic_file.png")); //$NON-NLS-1$ buffer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); buffer.setBackground(PreferenceMastHead.HEADER_BG_COLOR); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 0; layout.marginWidth = 0; layout.marginBottom = 10; displayArea.setLayout(layout); buffer.setLayout(layout); buffer.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = new GC(buffer); gc.setBackground(PreferenceMastHead.FOOTER_BG_COLOR); if (buffer.getSize().y - 4 >= 0) { gc.fillRectangle(0, buffer.getSize().y - 5, buffer.getSize().x, 5); } } }); displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); description = new Label(displayArea, SWT.WRAP | SWT.LEFT); description.setText(Messages.TextEditorPreferencePage_ASSOCIATED_FILE_EXTENSIONS); Composite middle = new Composite(displayArea, SWT.NONE); layout = new GridLayout(2, false); GridData middleData = new GridData(SWT.FILL, SWT.FILL, true, false); middleData.heightHint = 120; middle.setLayout(layout); middle.setLayoutData(middleData); typesTable = new Table(middle, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); typesTable.setLayout(new GridLayout(1, true)); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = 100; typesTable.setLayoutData(data); typesTable.addSelectionListener(tableSelectionListener); Composite buttons = new Composite(middle, SWT.NONE); layout = new GridLayout(1, true); buttons.setLayout(layout); buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); add = new Button(buttons, SWT.PUSH); add.setText(StringUtils.ellipsify(Messages.TextEditorPreferencePage_ADD)); add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); add.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileExtensionDialog dialog = new FileExtensionDialog(displayArea.getShell()); if (dialog.open() == Window.OK) { changed = true; String newName = dialog.getName(); String newExtension = dialog.getExtension(); // Find the index at which to insert the new entry. String newFilename = (newName + (newExtension == null || newExtension.length() == 0 ? "" : "." + newExtension)) //$NON-NLS-1$//$NON-NLS-2$ .toUpperCase(); IFileEditorMapping newMapping; TableItem[] items = typesTable.getItems(); boolean found = false; int i = 0; while (i < items.length && !found) { newMapping = (IFileEditorMapping) items[i].getData(); int result = newFilename.compareToIgnoreCase(newMapping.getLabel()); if (result == 0) { // Same resource type not allowed! MessageDialog.openInformation(getControl().getShell(), Messages.TextEditorPreferencePage_FILE_TYPE_EXISTS, Messages.TextEditorPreferencePage_FILE_TYPE_EXISTS_TITLE); return; } if (result < 0) { found = true; } else { i++; } } newMapping = getFileEditorMapping(newName, newExtension); addTypesTableItem(newMapping, i); typesTable.setFocus(); typesTable.setSelection(i); tableSelectionListener.widgetSelected(null); } } }); remove = new Button(buttons, SWT.PUSH); remove.setText(Messages.TextEditorPreferencePage_REMOVE_ASSOCIATION); remove.setEnabled(false); remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); remove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (typesTable.getSelectionCount() == 1) { changed = true; TableItem item = typesTable.getSelection()[0]; FileEditorMapping data = (FileEditorMapping) item.getData(); mappings.remove(data); browseGrammar.setEnabled(false); grammarText.setText(""); //$NON-NLS-1$ remove.setEnabled(false); String label = item.getText(); String prefId = TextPlugin.getColorizerPreference(label); UnifiedEditorsPlugin.getDefault().getPreferenceStore().setValue(prefId, ""); //$NON-NLS-1$ LanguageStructureProvider provider = (LanguageStructureProvider) activeProviders.remove(prefId); if (provider != null) { LanguageRegistry.unregisterLanguageColorizer(provider.getLanguage()); TokenList tokenList = LanguageRegistry.getTokenList(provider.getLanguage()); if (tokenList != null) { LanguageRegistry.unregisterTokenList(tokenList); } UnifiedEditorsPlugin.getDefault().getPreferenceStore().firePropertyChangeEvent( "Colorization removed", "Colorization removed", "Colorization removed"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } colorizer.setProvider(null); item.dispose(); } } }); IEditorRegistry registry = EclipseUIUtils.getWorkbenchEditorRegistry(); // Look up generic text editor descriptor = (EditorDescriptor) registry.findEditor(GenericTextEditor.ID); IFileEditorMapping[] array = registry.getFileEditorMappings(); int count = 0; for (int i = 0; i < array.length; i++) { FileEditorMapping mapping = (FileEditorMapping) array[i]; mapping = (FileEditorMapping) mapping.clone(); // want a copy mappings.add(mapping); if (mapping.getDefaultEditor() != null && mapping.getDefaultEditor().getId().equals(GenericTextEditor.ID)) { String label = mapping.getLabel(); String extension = mapping.getExtension(); // This check allows us to internally contribute generic text editor association without making them // visible in the pref page (but configurable elsewhere) if (LanguageRegistry.getTokenListByExtension(extension) == null) { String grammarFile = store.getString(TextPlugin.getGrammarPreference(label)); if (!grammarFile.equals("")) //$NON-NLS-1$ { mappingsToGrammars.put(label, grammarFile); } addTypesTableItem(mapping, count); count++; } } } grammarGroup = new Group(displayArea, SWT.NONE); grammarGroup.setLayout(new GridLayout(2, false)); grammarGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); grammarGroup.setText(Messages.TextEditorPreferencePage_GRAMMAR_FILE); grammarText = new Text(grammarGroup, SWT.READ_ONLY | SWT.LEFT | SWT.SINGLE | SWT.BORDER); ModifyListener gListener = new ModifyListener() { public void modifyText(ModifyEvent e) { if (typesTable.getSelectionCount() == 1) { TableItem item = typesTable.getSelection()[0]; mappingsToGrammars.put(item.getText(), grammarText.getText()); changed = true; } } }; grammarText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); grammarText.addModifyListener(gListener); browseGrammar = new Button(grammarGroup, SWT.PUSH); browseGrammar.setText(StringUtils.ellipsify(Messages.TextEditorPreferencePage_BROWSE)); browseGrammar.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(displayArea.getShell()); fileDialog.setFilterExtensions(new String[] { "*.lxr" }); //$NON-NLS-1$ String fileName = fileDialog.open(); if (fileName != null) { try { AttributeSniffer sniffer = new AttributeSniffer("lexer", "language"); //$NON-NLS-1$ //$NON-NLS-2$ sniffer.read(fileName); String newLanguage = sniffer.getMatchedValue(); if (newLanguage != null) { if (!LanguageRegistry.hasTokenList(newLanguage)) { grammarText.setText(fileName); tableSelectionListener.widgetSelected(e); } else { UIJob errorJob = new UIJob( Messages.TextEditorPreferencePage_Error_Loading_Language) { public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getShell(), Messages.TextEditorPreferencePage_Error_Adding_Language, Messages.TextEditorPreferencePage_Language_Already_Supported); return Status.OK_STATUS; } }; errorJob.schedule(); } } } catch (final Exception e1) { UIJob errorJob = new UIJob(Messages.TextEditorPreferencePage_Error_Loading_Lexer_File) { public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getShell(), Messages.TextEditorPreferencePage_Error_Loading_Lexer_File, e1.getMessage()); return Status.OK_STATUS; } }; errorJob.schedule(); } } } }); browseGrammar.setEnabled(false); colorizerGroup = new Group(displayArea, SWT.NONE); colorizerGroup.setText(Messages.TextEditorPreferencePage_COLORIATION_FILE); colorizerGroup.setLayout(new GridLayout(1, false)); colorizerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); applyChanges = new Button(colorizerGroup, SWT.PUSH); applyChanges.setText(Messages.TextEditorPreferencePage_Apply_Changes); applyChanges.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (typesTable.getSelectionCount() == 1) { TableItem item = typesTable.getSelection()[0]; String colorizerId = TextPlugin.getColorizerPreference(item.getText()); if (activeProviders.containsKey(colorizerId)) { LanguageStructureProvider provider = (LanguageStructureProvider) activeProviders .get(colorizerId); LanguageColorizer colorizer = LanguageRegistry.getLanguageColorizer(provider.getLanguage()); provider.buildLanguageColorizer(colorizer, colorizerId); } } } }); applyChanges.setEnabled(true); colorizer = new LanguageColorizationWidget(); data = new GridData(SWT.FILL, SWT.FILL, true, true); colorizer.createControl(colorizerGroup, data); colorizer.collapseAll(); return displayArea; }
From source file:com.aptana.ide.editors.unified.BaseFormatter.java
License:Open Source License
/** * Logs an error// ww w . ja v a2s . co m * * @param original * @param formatted */ protected void logError(String original, String formatted) { original = printReturns(original); formatted = printReturns(formatted); IdeLog.logError(UnifiedEditorsPlugin.getDefault(), StringUtils.format(Messages.BaseFormatter_ERR_FormattingFailure, new String[] { stripSpace(original), stripSpace(formatted) })); if (displayErrors) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.BaseFormatter_TTL_ErrorFormatting, Messages.BaseFormatter_INF_FormattingErrorDetails); } }
From source file:com.aptana.ide.editors.unified.UnifiedEditor.java
License:Open Source License
void showPairError() { MessageDialog.openInformation(null, Messages.UnifiedEditor_MatchingPairError, Messages.UnifiedEditor_MatchingPairErrorMessage); }
From source file:com.aptana.ide.editors.untitled.BaseTextEditor.java
License:Open Source License
private File doExternalSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell();/*w ww .j a v a 2 s.c om*/ IDocumentProvider provider = getDocumentProvider(); IEditorInput input = getEditorInput(); FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); String fileName = getDefaultSaveAsFile(); fileDialog.setFileName(getBaseFilename(fileName)); FileDialogFilterInfo filterInfo = getFileDialogFilterInformation(fileName); String[] fileExtensions = filterInfo.getFilterExtensions(); if (fileExtensions != null && fileExtensions.length > 0) { fileDialog.setFilterExtensions(fileExtensions); fileDialog.setFilterNames(filterInfo.getFilterNames()); } // [IM] This appears to have no effect on OSX. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=101948 if (directoryHint != null) { File f = new File(directoryHint); if (f.exists()) { fileDialog.setFilterPath(directoryHint); } } String text = fileDialog.open(); if (text == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return null; } File file = new File(text); final IEditorInput newInput = CoreUIUtils.createJavaFileEditorInput(file); boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = Messages.BaseTextEditor_SaveFileError; String msg = StringUtils.format(Messages.BaseTextEditor_ErrorSaving, new Object[] { x.getMessage() }); if (status != null) { switch (status.getSeverity()) { case IStatus.INFO: MessageDialog.openInformation(shell, title, msg); break; case IStatus.WARNING: MessageDialog.openWarning(shell, title, msg); break; default: MessageDialog.openError(shell, title, msg); } } else { MessageDialog.openError(shell, title, msg); } } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } if (success) { return file; } else { return null; } }