本文整理汇总了Java中org.eclipse.ui.editors.text.TextEditor类的典型用法代码示例。如果您正苦于以下问题:Java TextEditor类的具体用法?Java TextEditor怎么用?Java TextEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextEditor类属于org.eclipse.ui.editors.text包,在下文中一共展示了TextEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAdditionalPage
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
@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;
}
示例2: createMessagesBundlePage
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例3: removeMessagesBundle
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
示例4: createPage0
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例5: createPage0
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例6: getAdapter
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
@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;
}
示例7: createPageSource
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例8: createSourcePage
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例9: sourcePage
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
开发者ID:germanattanasio,项目名称:traceability-assistant-eclipse-plugins,代码行数:13,代码来源:TraceabilityEditor.java
示例10: createPrimaryPage
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
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.");
}
}
示例11: createPages
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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());
}
}
示例12: execute
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
* 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;
}
示例13: setEditorContents
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
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));
}
示例14: getLineNumberForCharNumber
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
/**
*
* 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..
}
示例15: setEditorSelection
import org.eclipse.ui.editors.text.TextEditor; //导入依赖的package包/类
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));
}
}