Methods Summary |
---|
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());
}
|
void | createPage1()
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, "Sorted");
|
protected void | createPages()
createPage0();
createPage1();
|
public void | doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
getEditor(0).doSave(monitor);
|
public void | doSaveAs()
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)
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)
super.pageChange(newPageIndex);
if (newPageIndex == 1) {
sort();
}
|
void | sort()
String unsortedText =
editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
StringTokenizer stringTokenizer =
new StringTokenizer(unsortedText, " \t\n\r");
ArrayList wordArrayList = new ArrayList();
while (stringTokenizer.hasMoreTokens()) {
wordArrayList.add(stringTokenizer.nextToken());
}
Collections.sort(wordArrayList, Collator.getInstance());
StringWriter sortedText = new StringWriter();
for (int loopIndex = 0; loopIndex < wordArrayList.size(); loopIndex++) {
sortedText.write(((String) wordArrayList.get(loopIndex)));
sortedText.write(System.getProperty("line.separator"));
}
text.setText(sortedText.toString());
|