Java 类org.eclipse.ui.editors.text.TextEditor 实例源码
项目:eavp
文件:CSVPlot.java
@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;
}
项目:PDFReporter-Studio
文件:AbstractMessagesEditor.java
/**
* 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());
}
}
项目:PDFReporter-Studio
文件:AbstractMessagesEditor.java
/**
* 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());
}
项目:anatlyzer
文件:ExperimentConfigurationEditor.java
/**
* 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());
}
}
项目:Open_Source_ECOA_Toolset_AS5
文件:TypesEditor.java
/**
* 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());
}
}
项目:Open_Source_ECOA_Toolset_AS5
文件:CompDefEditor.java
/**
* 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());
}
}
项目:Open_Source_ECOA_Toolset_AS5
文件:ServicesEditor.java
/**
* 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());
}
}
项目:dsp4e
文件:DSPEditorAdapterFactory.java
@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;
}
项目:bdf2
文件:PropEditor.java
/**
* 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());
}
}
项目:traceability-assistant-eclipse-plugins
文件:DXMIEditor.java
/**
* 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());
}
}
项目:traceability-assistant-eclipse-plugins
文件:TraceabilityEditor.java
/**
* 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());
}
}
项目:hssd
文件:MultiPageEditorWithTextPage.java
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.");
}
}
项目:mytourbook
文件:MessagesEditor.java
/**
* 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());
}
}
项目:mytourbook
文件:MessagesEditor.java
/**
* 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());
}
}
项目:mytourbook
文件:MessagesEditor.java
/**
* 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());
}
}
项目:anatlyzer
文件:ShowMappingHandler.java
/**
* 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;
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
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));
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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);
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
*
* 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..
}
项目:eclipsensis
文件:NSISEditorUtilities.java
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));
}
}
项目:vdt-plugin
文件:VerilogUtils.java
/**
* 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;
}
项目:patternbox-eclipse
文件:MultiPageEditor.java
/**
* 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());
}
}
项目:emfviews
文件:ViewpointEditor.java
/**
* 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());
}
}
项目:bdf2
文件:PropEditor.java
public TextEditor getEditor() {
return editor;
}
项目:bdf2
文件:PropertiesOutlinePage.java
PropertiesOutlinePage(PropEditor propEditor, PropertyFile input, TextEditor editor) {
this.propEditor = propEditor;
this.inputPropertyFile = propEditor.getInput();
this.editor = propEditor.getEditor();
}
项目:hssd
文件:MultiPageEditorWithTextPage.java
public TextEditor getPrimaryEditor() {
return editor;
}
项目:mondo-integration
文件:HawkMultiPageEditor.java
private void createRawTextEditorPage() throws PartInitException {
textEditor = new TextEditor();
textEditorPageIndex = addPage(textEditor, getEditorInput());
setPageText(textEditorPageIndex, textEditor.getTitle());
setPartName(textEditor.getTitle());
}
项目:PDFReporter-Studio
文件:AbstractI18NEntry.java
public boolean isEditable() {
IMessagesBundleGroup messagesBundleGroup = editor.getBundleGroup();
IMessagesBundle bundle = messagesBundleGroup.getMessagesBundle(locale);
return ((TextEditor) bundle.getResource().getSource()).isEditable();
}
项目:mytourbook
文件:I18NEntry.java
public boolean isEditable() {
return ((TextEditor) messagesBundleGroup.
getMessagesBundle(locale).getResource().getSource()).isEditable();
}
项目:mytourbook
文件:I18NEntry.java
public boolean isEditable() {
return ((TextEditor) messagesBundleGroup.
getMessagesBundle(locale).getResource().getSource()).isEditable();
}
项目:mytourbook
文件:I18NEntry.java
public boolean isEditable() {
return ((TextEditor) messagesBundleGroup.
getMessagesBundle(locale).getResource().getSource()).isEditable();
}
项目:mondo-hawk
文件:HawkMultiPageEditor.java
private void createRawTextEditorPage() throws PartInitException {
textEditor = new TextEditor();
textEditorPageIndex = addPage(textEditor, getEditorInput());
setPageText(textEditorPageIndex, textEditor.getTitle());
setPartName(textEditor.getTitle());
}
项目:mondo-collab-framework
文件:HawkMultiPageEditor.java
private void createRawTextEditorPage() throws PartInitException {
textEditor = new TextEditor();
textEditorPageIndex = addPage(textEditor, getEditorInput());
setPageText(textEditorPageIndex, textEditor.getTitle());
setPartName(textEditor.getTitle());
}
项目:XPagesExtensionLibrary
文件:ManifestMultiPageEditor.java
public TextEditor getSrcEditor() {
return _srcEditor;
}
项目:birt
文件:ReportXMLSourceEditorFormPage.java
protected TextEditor getTextEditor( )
{
return reportXMLEditor;
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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());
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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();
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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();
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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();
}
项目:EclipseEditorPluginExample
文件:EditorActions.java
/**
* 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));
}