@Override public String createAdditionalPage(MultiPageEditorPart parent, IFileEditorInput file, int pageNum) { // Create the specified page switch (pageNum) { // Page 2 is the file's data displayed in text case 1: // Create a text editor with the file as input and add its page with // the name Data try { editor = (IEditorPart) new TextEditor(); parent.addPage(editor, file); return "Data"; } catch (PartInitException e) { logger.error("Error initializing text editor for CSV Plot Editor."); } break; } // If the page number is not supported, return null return null; }
/** * Creates a new text editor for the messages bundle, which gets added to a new page */ protected void createMessagesBundlePage(MessagesBundle messagesBundle) { try { IMessagesResource resource = messagesBundle.getResource(); final TextEditor textEditor = (TextEditor) resource.getSource(); int index = addPage(textEditor, textEditor.getEditorInput()); setPageText(index, UIUtils.getDisplayName(messagesBundle.getLocale())); setPageImage(index, UIUtils.getImage(UIUtils.IMAGE_PROPERTIES_FILE)); localesIndex.add(messagesBundle.getLocale()); textEditorsIndex.add(textEditor); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating text editor page.", //$NON-NLS-1$ null, e.getStatus()); } }
/** * Removes the text editor page + the entry from the i18n page of the given locale and messages bundle. */ protected void removeMessagesBundle(MessagesBundle messagesBundle) { IMessagesResource resource = messagesBundle.getResource(); final TextEditor textEditor = (TextEditor) resource.getSource(); // index + 1 because of i18n page int pageIndex = textEditorsIndex.indexOf(textEditor) + 1; removePage(pageIndex); textEditorsIndex.remove(textEditor); localesIndex.remove(messagesBundle.getLocale()); textEditor.dispose(); // remove entry from i18n page i18nPage.removeI18NEntry(messagesBundle.getLocale()); }
/** * Creates page 0 of the multi-page editor, * which contains a text editor. */ void createPage0() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, editor.getTitle()); IHandlerService serv = (IHandlerService) getSite().getService(IHandlerService.class); MyCopyHandler cp = new MyCopyHandler(); serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_PASTE, cp); //serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_, cp); } catch (PartInitException e) { ErrorDialog.openError( getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
/** * Creates page 0 of the multi-page editor, which contains a text editor. */ void createPage0() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, "XML"); setPartName(((FileEditorInput) editor.getEditorInput()).getFile().getName()); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adapterType == IToggleBreakpointsTarget.class) { if (adaptableObject instanceof ExtensionBasedTextEditor || adaptableObject instanceof TextEditor) { return (T) new DSPBreakpointAdapter(); } } return null; }
/** * Creates page 1 of the multi-page editor, which allows you to change the * font used in page 2. */ void createPageSource() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, "Source"); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
/** * Creates the source page. */ void createSourcePage() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, "Source"); } catch (PartInitException e) { ErrorDialog.openError( getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
/** * Creates a View Source page */ void sourcePage() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, "Source"); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(),"Error creating nested text editor", null, e.getStatus()); } }
protected void createPrimaryPage(TextEditor editor) { try { this.editor = editor; pageIndex = addPage(editor, getEditorInput()); setPageText(pageIndex, editor.getTitle()); setPartName(editor.getTitle()); } catch (PartInitException e) { handlePartInitException( e, "Part Initialization Failure", "Failed to create primary page."); } }
/** * Creates the pages of the multi-page editor. */ protected void createPages() { // Create I18N page i18nPage = new I18NPage( getContainer(), SWT.NONE, this); int index = addPage(i18nPage); setPageText(index, MessagesEditorPlugin.getString( "editor.properties")); //$NON-NLS-1$ setPageImage(index, UIUtils.getImage(UIUtils.IMAGE_RESOURCE_BUNDLE)); // Create text editor pages for each locales try { Locale[] locales = messagesBundleGroup.getLocales(); //first: sort the locales. UIUtils.sortLocales(locales); //second: filter+sort them according to the filter preferences. locales = UIUtils.filterLocales(locales); for (int i = 0; i < locales.length; i++) { Locale locale = locales[i]; MessagesBundle messagesBundle = messagesBundleGroup.getMessagesBundle(locale); IMessagesResource resource = messagesBundle.getResource(); TextEditor textEditor = (TextEditor) resource.getSource(); index = addPage(textEditor, textEditor.getEditorInput()); setPageText(index, UIUtils.getDisplayName( messagesBundle.getLocale())); setPageImage(index, UIUtils.getImage(UIUtils.IMAGE_PROPERTIES_FILE)); localesIndex.add(locale); textEditorsIndex.add(textEditor); } } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating text editor page.", //$NON-NLS-1$ null, e.getStatus()); } }
/** * the command has been executed, so extract extract the needed information * from the application context. */ public Object execute(ExecutionEvent event) throws ExecutionException { // IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); // MessageDialog.openInformation( // window.getShell(), // "Ide", // "Show mapping"); IEditorPart editor = HandlerUtil.getActiveEditor(event); if ( editor instanceof AtlEditorExt ) { AtlEditorExt atlEditor = (AtlEditorExt) editor; IFile file = (IFile) atlEditor.getUnderlyingResource(); AnalysisResult r = AnalysisIndex.getInstance().getAnalysisOrLoad(file); if ( r == null ) return null; //MappingDialog dialog = new MappingDialog(HandlerUtil.getActiveShell(event), new AtlTransformationMapping(r.getAnalyser())); //dialog.open(); IDocument doc = ((TextEditor) atlEditor).getDocumentProvider().getDocument(atlEditor.getEditorInput()); showView(r.getAnalyser(), doc); } return null; }
public static void setEditorContents(String in, TextEditor editor, final int newCursorPosition) { IDocumentProvider prov = editor.getDocumentProvider(); IDocument doc = prov.getDocument(editor.getEditorInput()); int currentCursorPosition = getcursorPosition(editor); ConsoleActions.debug("Current positions is:" + currentCursorPosition); doc.set(in); editor.getSelectionProvider().setSelection( new OurSelectionProvider(newCursorPosition, currentCursorPosition)); }
/** * Replaces the contents of an editor with the input string s * * * @param in The replacement string to display in the editor */ public static void setEditorContents(String in) { TextEditor editor = (TextEditor) getEditor(); IDocumentProvider prov = editor.getDocumentProvider(); IDocument doc = prov.getDocument(editor.getEditorInput()); doc.set(in); }
/** * * Returns the line number, given a character number. * * @param editor * @param target * @return */ public static int getLineNumberForCharNumber(TextEditor editor, int target) { String editorContents = editorContents(editor); String[] lines = editorContents.split("\\n"); int charsLeft = target; for (int i = 0; i < lines.length; i++) { if (charsLeft <= lines[i].length()) { return i; } charsLeft = charsLeft - lines[i].length(); } return -1;// because there are more chars than lines to hold them.. }
private static void setEditorSelection(IEditorPart editor, Position pos, int lineNum) { if(editor instanceof TextEditor) { int offset = -1; int length = 0; IDocument doc = ((TextEditor)editor).getDocumentProvider().getDocument(editor.getEditorInput()); if(pos != null) { if(pos.getOffset() >= 0 && doc.getLength() >= pos.getOffset()+pos.getLength()) { offset = pos.getOffset(); length = pos.getLength(); } } else { if(doc.getNumberOfLines() >= lineNum) { try { IRegion region = doc.getLineInformation(lineNum-1); offset = region.getOffset(); length = region.getLength(); } catch (BadLocationException e) { EclipseNSISPlugin.getDefault().log(e); } } } ((TextEditor)editor).getSelectionProvider().setSelection(new TextSelection(doc,offset,length)); } }
/** * Get the full text from one of the open editor windows or null (if there is none) * @param file IFile for which we are looking for text * @return full text of the current state of the file or null */ public static String getEditorText(IFile file){ try { IEditorPart editor=org.eclipse.ui.ide.ResourceUtil.findEditor(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(), file); if (editor instanceof TextEditor) { IDocument doc = ((ITextEditor)editor).getDocumentProvider().getDocument(editor.getEditorInput()); return doc.get(); } } catch (Exception e) { } return null; }
/** * Creates page 0 of the multi-page editor, which contains a text editor. */ void createPage0() { try { editor = new TextEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, editor.getTitle()); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
/** * Creates page 0 of the multi-page editor, which contains a text editor. */ void createViewpointTextEditorPage() { try { viewpointTextEditor = new TextEditor(); int index = addPage(viewpointTextEditor, getEditorInput()); setPageText(index, "Source"); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
public TextEditor getEditor() { return editor; }
PropertiesOutlinePage(PropEditor propEditor, PropertyFile input, TextEditor editor) { this.propEditor = propEditor; this.inputPropertyFile = propEditor.getInput(); this.editor = propEditor.getEditor(); }
public TextEditor getPrimaryEditor() { return editor; }
private void createRawTextEditorPage() throws PartInitException { textEditor = new TextEditor(); textEditorPageIndex = addPage(textEditor, getEditorInput()); setPageText(textEditorPageIndex, textEditor.getTitle()); setPartName(textEditor.getTitle()); }
public boolean isEditable() { IMessagesBundleGroup messagesBundleGroup = editor.getBundleGroup(); IMessagesBundle bundle = messagesBundleGroup.getMessagesBundle(locale); return ((TextEditor) bundle.getResource().getSource()).isEditable(); }
public boolean isEditable() { return ((TextEditor) messagesBundleGroup. getMessagesBundle(locale).getResource().getSource()).isEditable(); }
public TextEditor getSrcEditor() { return _srcEditor; }
protected TextEditor getTextEditor( ) { return reportXMLEditor; }
/** * This returns the contents of the current editor as a string. * * @return contents of the current editor as a string. */ public static String editorContents() { return editorContents((TextEditor) getEditor()); }
/** * This returns the contents of the current editor tab, as a string. if passed null, it throws a * null pointer exception implicitly * * @return contents of the current editor as a string. */ public static String editorContents(TextEditor editor) { IDocumentProvider prov = editor.getDocumentProvider(); IDocument doc = prov.getDocument(editor.getEditorInput()); return doc.get(); }
/** * Returns the cursor location for a given editor, cursor position is an int defined as the number * of times you would have to press the left arrow key to get to the start of the file * * @param editor * @return */ public static int getcursorPosition(TextEditor editor) { ISelection selection = editor.getSelectionProvider().getSelection(); ITextSelection its = (ITextSelection) selection; return its.getOffset(); }
/** * Returns the cursor location for a given editor, cursor position is an int defined as the number * of times you would have to press the up arrow key to get to the start line of the file * * @param editor * @return */ public static int getcursorLine(TextEditor editor) { ISelection selection = editor.getSelectionProvider().getSelection(); ITextSelection its = (ITextSelection) selection; return its.getStartLine(); }
/** * For a given editor sets the cursor position to input int. Cursor position is defined as the * number of times you would have to press the left arrow key to get to the start of the file * * @param editor * @return */ public static void setcursorPosition(TextEditor editor, int position) { editor.getSelectionProvider().setSelection(new OurSelectionProvider(position, 0)); }