Methods Summary |
---|
void | createPage0()Creates page 0 of the multi-page editor,
which contains a text editor.
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());
}
|
void | createPage1()Creates page 1 of the multi-page editor,
which allows you to change the font used in page 2.
Composite composite = new Composite(getContainer(), SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
layout.numColumns = 2;
Button fontButton = new Button(composite, SWT.NONE);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 2;
fontButton.setLayoutData(gd);
fontButton.setText("Change Font...");
fontButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFont();
}
});
int index = addPage(composite);
setPageText(index, "Properties");
|
void | createPage2()Creates page 2 of the multi-page editor,
which shows the sorted text.
Composite composite = new Composite(getContainer(), SWT.NONE);
FillLayout layout = new FillLayout();
composite.setLayout(layout);
text = new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL);
text.setEditable(false);
int index = addPage(composite);
setPageText(index, "Preview");
|
protected void | createPages()Creates the pages of the multi-page editor.
createPage0();
// createPage1();
// createPage2();
|
public void | doSave(org.eclipse.core.runtime.IProgressMonitor monitor)Saves the multi-page editor's document.
getEditor(0).doSave(monitor);
|
public void | doSaveAs()Saves the multi-page editor's document as another file.
Also updates the text for page 0's tab, and updates this multi-page editor's input
to correspond to the nested editor's.
IEditorPart editor = getEditor(0);
editor.doSaveAs();
setPageText(0, editor.getTitle());
setInput(editor.getEditorInput());
|
public void | gotoMarker(org.eclipse.core.resources.IMarker marker)
setActivePage(0);
getEditor(0).gotoMarker(marker);
|
public void | init(IEditorSite site, IEditorInput editorInput)The MultiPageEditorExample implementation of this method
checks that the input is an instance of IFileEditorInput .
if (!(editorInput instanceof IFileEditorInput))
throw new PartInitException("Invalid Input: Must be IFileEditorInput");
super.init(site, editorInput);
|
public boolean | isSaveAsAllowed()
return true;
|
protected void | pageChange(int newPageIndex)Calculates the contents of page 2 when the it is activated.
super.pageChange(newPageIndex);
if (newPageIndex == 2) {
sortWords();
}
|
void | setFont()Sets the font related data to be applied to the text in page 2.
FontDialog fontDialog = new FontDialog(getSite().getShell());
fontDialog.setFontList(text.getFont().getFontData());
FontData fontData = fontDialog.open();
if (fontData != null) {
if (font != null)
font.dispose();
font = new Font(text.getDisplay(), fontData);
text.setFont(font);
}
|
void | sortWords()Sorts the words in page 0, and shows them in page 2.
String editorText =
editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
StringTokenizer tokenizer =
new StringTokenizer(editorText, " \t\n\r\f!@#\u0024%^&*()-_=+`~[]{};:'\",.<>/?|\\");
ArrayList editorWords = new ArrayList();
while (tokenizer.hasMoreTokens()) {
editorWords.add(tokenizer.nextToken());
}
Collections.sort(editorWords, Collator.getInstance());
StringWriter displayText = new StringWriter();
for (int i = 0; i < editorWords.size(); i++) {
displayText.write(((String) editorWords.get(i)));
displayText.write(System.getProperty("line.separator"));
}
text.setText(displayText.toString());
|