List of usage examples for org.eclipse.jface.action IStatusLineManager setErrorMessage
public void setErrorMessage(String message);
From source file:ccw.editors.clojure.BasicClojureEditorActionContributor.java
License:Open Source License
public void setActiveEditor(IEditorPart part) { if (fActiveEditorPart == part) return;/*from w w w . j a v a2 s . c om*/ fActiveEditorPart = part; super.setActiveEditor(part); if (fActiveEditorPart instanceof ITextEditorExtension) { ITextEditorExtension extension = (ITextEditorExtension) fActiveEditorPart; for (int i = 0; i < STATUS_FIELD_DEFS.length; i++) extension.setStatusField(null, STATUS_FIELD_DEFS[i].category); } ITextEditor textEditor = null; if (part instanceof ITextEditor) textEditor = (ITextEditor) part; IActionBars actionBars = getActionBars(); IStatusLineManager manager = actionBars.getStatusLineManager(); manager.setMessage(null); manager.setErrorMessage(null); /** The global actions to be connected with editor actions */ IAction action = getAction(textEditor, ITextEditorActionConstants.NEXT); actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action); actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action); action = getAction(textEditor, ITextEditorActionConstants.PREVIOUS); actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action); actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action); for (int i = 0; i < STATUS_FIELD_DEFS.length; i++) { if (fActiveEditorPart instanceof ITextEditorExtension) { StatusLineContributionItem statusField = (StatusLineContributionItem) fStatusFields .get(STATUS_FIELD_DEFS[i]); statusField.setActionHandler(getAction(textEditor, STATUS_FIELD_DEFS[i].actionId)); ITextEditorExtension extension = (ITextEditorExtension) fActiveEditorPart; extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category); } } }
From source file:cl.utfsm.acs.acg.gui.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
public void postWindowOpen() { final IStatusLineManager status = getWindowConfigurer().getActionBarConfigurer().getStatusLineManager(); status.setMessage("Application starting..."); final Display display = getWindowConfigurer().getWindow().getShell().getDisplay(); // Disables the initial view IViewReference[] views = getWindowConfigurer().getWindow().getWorkbench().getActiveWorkbenchWindow() .getActivePage().getViewReferences(); for (int i = 0; i < views.length; i++) { if (views[i].getId().compareTo(AlarmSystemView.ID) == 0) ((IMyViewPart) views[i].getView(false)).setEnabled(false); }/* w w w .j ava 2 s . com*/ boolean authenticated = false; AuthenticationDialog d = new AuthenticationDialog( ApplicationWorkbenchWindowAdvisor.this.getWindowConfigurer().getWindow().getShell()); UserAuthenticator.Role role = null; while (!authenticated) { d.open(); UserAuthenticator userAuth = new UserAuthenticator(); try { role = userAuth.authenticate(d.getUser(), d.getPassword()); } catch (UserAuthenticatorException e) { d.setErrorMessage("Authentication unsuccessful"); continue; } catch (IllegalArgumentException e) { d.setErrorMessage("Please authenticate yourselve"); continue; } finally { status.setMessage("Authentication successful"); } authenticated = true; } final UserAuthenticator.Role finalRole = role; new Thread(new Runnable() { @Override public void run() { AlarmSystemManager asm = AlarmSystemManager.getInstance(finalRole); try { display.asyncExec(new Runnable() { public void run() { status.setMessage("Connecting to Manager"); } }); asm.connectToManager(); display.asyncExec(new Runnable() { public void run() { status.setMessage("Connecting to CDB DAL"); } }); asm.connectToDAL(); display.asyncExec(new Runnable() { public void run() { status.setMessage("Loading contents from the CDB"); } }); asm.loadFromCDB(); final String error = asm.checkCDB(); if (error.compareTo("") != 0) { display.asyncExec(new Runnable() { public void run() { ErrorDialog edialog = new ErrorDialog(getWindowConfigurer().getWindow().getShell(), "CDB Error", "Error while checking CDB integrity", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", error), IStatus.ERROR); edialog.setBlockOnOpen(true); edialog.open(); } }); } } catch (Exception e) { e.printStackTrace(); display.asyncExec(new Runnable() { public void run() { status.setErrorMessage("Couldn't successfully connect to AS configuation"); } }); return; } /* If everything went OK: * Show the other views * Enable the widgets and inform the user */ display.asyncExec(new Runnable() { public void run() { IWorkbenchPage page = getWindowConfigurer().getWindow().getActivePage(); try { if (finalRole == Role.Administrator || finalRole == Role.Operator) { page.showView(SourcesView.ID, null, IWorkbenchPage.VIEW_VISIBLE); page.showView(CategoriesView.ID, null, IWorkbenchPage.VIEW_VISIBLE); page.showView(AlarmsView.ID, null, IWorkbenchPage.VIEW_VISIBLE); page.showView(ReductionsView.ID, null, IWorkbenchPage.VIEW_VISIBLE); page.showView("org.eclipse.pde.runtime.LogView", null, IWorkbenchPage.VIEW_VISIBLE); } } catch (PartInitException e) { status.setErrorMessage("Cannot open other views"); } IViewReference[] views = page.getViewReferences(); for (int i = 0; i < views.length; i++) { if (views[i].getId().compareTo(AlarmSystemView.ID) == 0) ((IMyViewPart) views[i].getView(false)).setEnabled(true); if (finalRole == Role.Operator) if (views[i].getView(false) instanceof IMyViewPart) ((IMyViewPart) views[i].getView(false)).setReadOnly(true); } status.setMessage("Application started successfully"); } }); } }).start(); }
From source file:com.agynamix.platform.infra.PlatformUtils.java
License:Open Source License
public static void setStatusLineErrorMsg(final String msg) { safeAsyncRunnable(new Runnable() { public void run() { IStatusLineManager statusLine = getStatusLine(); if (statusLine != null) { statusLine.setErrorMessage(msg); }/*from w w w . ja va 2s .c o m*/ } }); }
From source file:com.android.ide.eclipse.adt.internal.editors.Hyperlinks.java
License:Open Source License
private static void displayError(String message) { // Failed: display message to the user IEditorSite editorSite = getEditor().getEditorSite(); IStatusLineManager status = editorSite.getActionBars().getStatusLineManager(); status.setErrorMessage(message); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.GestureManager.java
License:Open Source License
/** * Update the Eclipse status message with any feedback messages from the given * {@link DropFeedback} object, or clean up if there is no more feedback to process * @param feedback the feedback whose message we want to display, or null to clear the * message if previously set/*from www . jav a 2s .c om*/ */ void updateMessage(DropFeedback feedback) { IEditorSite editorSite = mCanvas.getEditorDelegate().getEditor().getEditorSite(); IStatusLineManager status = editorSite.getActionBars().getStatusLineManager(); if (feedback == null) { if (mDisplayingMessage != null) { status.setMessage(null); status.setErrorMessage(null); mDisplayingMessage = null; } } else if (feedback.errorMessage != null) { if (!feedback.errorMessage.equals(mDisplayingMessage)) { mDisplayingMessage = feedback.errorMessage; status.setErrorMessage(mDisplayingMessage); } } else if (feedback.message != null) { if (!feedback.message.equals(mDisplayingMessage)) { mDisplayingMessage = feedback.message; status.setMessage(mDisplayingMessage); } } else if (mDisplayingMessage != null) { // TODO: Can we check the existing message and only clear it if it's the // same as the one we set? mDisplayingMessage = null; status.setMessage(null); status.setErrorMessage(null); } // Tooltip if (feedback != null && feedback.tooltip != null) { Pair<Boolean, Boolean> position = mCurrentGesture.getTooltipPosition(); boolean below = position.getFirst(); if (feedback.tooltipY != null) { below = feedback.tooltipY == SegmentType.BOTTOM; } boolean toRightOf = position.getSecond(); if (feedback.tooltipX != null) { toRightOf = feedback.tooltipX == SegmentType.RIGHT; } if (mTooltip == null) { mTooltip = new GestureToolTip(mCanvas, below, toRightOf); } mTooltip.update(feedback.tooltip, below, toRightOf); } else if (mTooltip != null) { mTooltip.dispose(); mTooltip = null; } }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas.java
License:Open Source License
/** * Shows the layout file referenced by the given url in the same project. * * @param url The layout attribute url of the form @layout/foo *//*w w w. j a v a 2s .c om*/ private void showInclude(String url) { GraphicalEditorPart graphicalEditor = getGraphicalEditor(); IPath filePath = graphicalEditor.findResourceFile(url); if (filePath == null) { // Should not be possible - if the URL had been bad, then we wouldn't // have been able to render the scene and you wouldn't have been able // to click on it return; } // Save the including file, if necessary: without it, the "Show Included In" // facility which is invoked automatically will not work properly if the <include> // tag is not in the saved version of the file, since the outer file is read from // disk rather than from memory. IEditorSite editorSite = graphicalEditor.getEditorSite(); IWorkbenchPage page = editorSite.getPage(); page.saveEditor(mEditorDelegate.getEditor(), false); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); IFile xmlFile = null; IPath workspacePath = workspace.getLocation(); if (workspacePath.isPrefixOf(filePath)) { IPath relativePath = filePath.makeRelativeTo(workspacePath); xmlFile = (IFile) workspace.findMember(relativePath); } else if (filePath.isAbsolute()) { xmlFile = workspace.getFileForLocation(filePath); } if (xmlFile != null) { IFile leavingFile = graphicalEditor.getEditedFile(); Reference next = Reference.create(graphicalEditor.getEditedFile()); try { IEditorPart openAlready = EditorUtility.isOpenInEditor(xmlFile); // Show the included file as included within this click source? if (openAlready != null) { LayoutEditorDelegate delegate = LayoutEditorDelegate.fromEditor(openAlready); if (delegate != null) { GraphicalEditorPart gEditor = delegate.getGraphicalEditor(); if (gEditor != null && gEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { gEditor.showIn(next); } } } else { try { // Set initial state of a new file // TODO: Only set rendering target portion of the state String state = ConfigurationDescription.getDescription(leavingFile); xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INITIAL_STATE, state); } catch (CoreException e) { // pass } if (graphicalEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { try { xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INCLUDE, next); } catch (CoreException e) { // pass - worst that can happen is that we don't //start with inclusion } } } EditorUtility.openInEditor(xmlFile, true); return; } catch (PartInitException ex) { AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } } else { // It's not a path in the workspace; look externally // (this is probably an @android: path) if (filePath.isAbsolute()) { IFileStore fileStore = EFS.getLocalFileSystem().getStore(filePath); // fileStore = fileStore.getChild(names[i]); if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) { try { IDE.openEditorOnFileStore(page, fileStore); return; } catch (PartInitException ex) { AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } } } } // Failed: display message to the user String message = String.format("Could not find resource %1$s", url); IStatusLineManager status = editorSite.getActionBars().getStatusLineManager(); status.setErrorMessage(message); getDisplay().beep(); }
From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gle2.LayoutCanvas.java
License:Open Source License
/** * Shows the layout file referenced by the given url in the same project. * * @param url The layout attribute url of the form @layout/foo *//*from w w w .ja va2 s . c o m*/ private void showInclude(String url) { GraphicalEditorPart graphicalEditor = mEditorDelegate.getGraphicalEditor(); IPath filePath = graphicalEditor.findResourceFile(url); if (filePath == null) { // Should not be possible - if the URL had been bad, then we wouldn't // have been able to render the scene and you wouldn't have been able // to click on it return; } // Save the including file, if necessary: without it, the "Show Included In" // facility which is invoked automatically will not work properly if the <include> // tag is not in the saved version of the file, since the outer file is read from // disk rather than from memory. IEditorSite editorSite = graphicalEditor.getEditorSite(); IWorkbenchPage page = editorSite.getPage(); page.saveEditor(mEditorDelegate.getEditor(), false); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); IFile xmlFile = null; IPath workspacePath = workspace.getLocation(); if (workspacePath.isPrefixOf(filePath)) { IPath relativePath = filePath.makeRelativeTo(workspacePath); xmlFile = (IFile) workspace.findMember(relativePath); } else if (filePath.isAbsolute()) { xmlFile = workspace.getFileForLocation(filePath); } if (xmlFile != null) { IFile leavingFile = graphicalEditor.getEditedFile(); Reference next = Reference.create(graphicalEditor.getEditedFile()); try { IEditorPart openAlready = EditorUtility.isOpenInEditor(xmlFile); // Show the included file as included within this click source? if (openAlready != null) { LayoutEditorDelegate delegate = LayoutEditorDelegate.fromEditor(openAlready); if (delegate != null) { GraphicalEditorPart gEditor = delegate.getGraphicalEditor(); if (gEditor != null && gEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { gEditor.showIn(next); } } } else { try { // Set initial state of a new file // TODO: Only set rendering target portion of the state QualifiedName qname = ConfigurationComposite.NAME_CONFIG_STATE; String state = AdtPlugin.getFileProperty(leavingFile, qname); xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INITIAL_STATE, state); } catch (CoreException e) { // pass } if (graphicalEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { try { xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INCLUDE, next); } catch (CoreException e) { // pass - worst that can happen is that we don't //start with inclusion } } } EditorUtility.openInEditor(xmlFile, true); return; } catch (PartInitException ex) { AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } } else { // It's not a path in the workspace; look externally // (this is probably an @android: path) if (filePath.isAbsolute()) { IFileStore fileStore = EFS.getLocalFileSystem().getStore(filePath); // fileStore = fileStore.getChild(names[i]); if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) { try { IDE.openEditorOnFileStore(page, fileStore); return; } catch (PartInitException ex) { AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } } } } // Failed: display message to the user String message = String.format("Could not find resource %1$s", url); IStatusLineManager status = editorSite.getActionBars().getStatusLineManager(); status.setErrorMessage(message); getDisplay().beep(); }
From source file:com.aptana.editor.findbar.impl.FindHelper.java
License:Open Source License
private static IWorkbenchPage getActivePage(IStatusLineManager statusLineManager) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { if (statusLineManager != null) { statusLineManager.setErrorMessage(Messages.FindHelper_Error_workbench_window_null); }/* w ww.ja v a2 s. c om*/ return null; } IWorkbenchPage activePage = window.getActivePage(); if (activePage == null) { if (statusLineManager != null) { statusLineManager.setErrorMessage(Messages.FindHelper_Error_active_page_null); } } return activePage; }
From source file:com.aptana.editor.findbar.impl.FindInOpenDocuments.java
License:Open Source License
/** * Here, all the editors available will be gotten and searched (if possible). Note that editors that are not in the * workspace may not be searched (it should be possible to do, but one may have to reimplement large portions of the * search for that to work).// w ww .ja v a 2s . c om */ public static void findInOpenDocuments(final String searchText, final boolean caseSensitive, final boolean wholeWord, final boolean isRegEx, IStatusLineManager statusLineManager) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { if (statusLineManager != null) { statusLineManager.setErrorMessage("Active workbench window is null."); //$NON-NLS-1$ } return; } IWorkbenchPage activePage = window.getActivePage(); if (activePage == null) { if (statusLineManager != null) { statusLineManager.setErrorMessage("Active page is null."); //$NON-NLS-1$ } return; } IEditorReference editorsArray[] = activePage.getEditorReferences(); final List<IFile> files = new ArrayList<IFile>(); for (int i = 0; i < editorsArray.length; i++) { IEditorPart realEditor = editorsArray[i].getEditor(true); if (realEditor != null) { if (realEditor instanceof MultiPageEditorPart) { try { Method getPageCount = MultiPageEditorPart.class.getDeclaredMethod("getPageCount"); //$NON-NLS-1$ getPageCount.setAccessible(true); Method getEditor = MultiPageEditorPart.class.getDeclaredMethod("getEditor", int.class); //$NON-NLS-1$ getEditor.setAccessible(true); Integer pageCount = (Integer) getPageCount.invoke(realEditor); for (int j = 0; j < pageCount; j++) { IEditorPart part = (IEditorPart) getEditor.invoke(realEditor, j); if (part != null) { IEditorInput input = part.getEditorInput(); if (input != null) { IFile file = (IFile) input.getAdapter(IFile.class); if (file != null) { files.add(file); } } } } } catch (Throwable e1) { // Log it but keep going on. FindBarPlugin.log(e1); } } else { IEditorInput input = realEditor.getEditorInput(); if (input != null) { IFile file = (IFile) input.getAdapter(IFile.class); if (file != null) { files.add(file); } else { // it has input, but it's not adaptable to an IFile! if (statusLineManager != null) { statusLineManager.setMessage(Messages.FindInOpenDocuments_FileNotInWorkspace); } // but we keep on going... } } } } } if (files.size() == 0) { if (statusLineManager != null) { statusLineManager.setMessage(Messages.FindInOpenDocuments_NoFileFound); } return; } try { ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new TextSearchInput() { public boolean isRegExSearch() { return isRegEx; } public boolean isCaseSensitiveSearch() { return caseSensitive; } public String getSearchText() { return searchText; } public FileTextSearchScope getScope() { return FileTextSearchScope.newSearchScope(files.toArray(new IResource[files.size()]), new String[] { "*" }, true); //$NON-NLS-1$ } }); NewSearchUI.runQueryInBackground(query); } catch (CoreException e1) { FindBarPlugin.log(e1); } }
From source file:com.aptana.ruby.internal.debug.ui.breakpoints.AbstractDetailPane.java
License:Open Source License
public void doSave(IProgressMonitor monitor) { IStatusLineManager statusLine = getStatusLine(); if (statusLine != null) { statusLine.setErrorMessage(null); }// ww w .java 2 s . c o m try { fEditor.doSave(); } catch (CoreException e) { if (statusLine != null) { statusLine.setErrorMessage(e.getMessage()); Display.getCurrent().beep(); } else { IdeLog.logError(RubyDebugUIPlugin.getDefault(), e); } } }