當前位置: 首頁>>代碼示例>>Java>>正文


Java TextEditor類代碼示例

本文整理匯總了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;
}
 
開發者ID:eclipse,項目名稱:eavp,代碼行數:25,代碼來源:CSVPlot.java

示例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());
    }
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:20,代碼來源:AbstractMessagesEditor.java

示例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());        
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:19,代碼來源:AbstractMessagesEditor.java

示例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());
	}
}
 
開發者ID:anatlyzer,項目名稱:anatlyzer,代碼行數:27,代碼來源:ExperimentConfigurationEditor.java

示例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());
	}
}
 
開發者ID:dstl,項目名稱:Open_Source_ECOA_Toolset_AS5,代碼行數:14,代碼來源:TypesEditor.java

示例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;
}
 
開發者ID:tracymiranda,項目名稱:dsp4e,代碼行數:11,代碼來源:DSPEditorAdapterFactory.java

示例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());
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:14,代碼來源:PropEditor.java

示例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());
	}
}
 
開發者ID:germanattanasio,項目名稱:traceability-assistant-eclipse-plugins,代碼行數:17,代碼來源:DXMIEditor.java

示例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.");
    }
}
 
開發者ID:insweat,項目名稱:hssd,代碼行數:14,代碼來源:MultiPageEditorWithTextPage.java

示例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());
    }
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:39,代碼來源:MessagesEditor.java

示例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;
	}
 
開發者ID:anatlyzer,項目名稱:anatlyzer,代碼行數:31,代碼來源:ShowMappingHandler.java

示例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));
}
 
開發者ID:joereddington,項目名稱:EclipseEditorPluginExample,代碼行數:10,代碼來源:EditorActions.java

示例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..
}
 
開發者ID:joereddington,項目名稱:EclipseEditorPluginExample,代碼行數:21,代碼來源:EditorActions.java

示例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));
    }
}
 
開發者ID:henrikor2,項目名稱:eclipsensis,代碼行數:28,代碼來源:NSISEditorUtilities.java


注:本文中的org.eclipse.ui.editors.text.TextEditor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。