use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class ViewerTestJSP method addActions.
protected void addActions(IContributionManager mgr) {
if (mgr != null) {
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "New JSP";
}
public void run() {
super.run();
BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
public void run() {
setupViewerForNew();
fSourceViewer.setEditable(true);
}
});
}
});
mgr.add(new Separator());
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Change Visibility";
}
public void run() {
super.run();
NumberInputDialog dlg = new NumberInputDialog(fSourceViewer.getControl().getShell());
int proceed = dlg.open();
if (proceed == Window.CANCEL)
return;
fSourceViewer.resetVisibleRegion();
fSourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Show All";
}
public void run() {
super.run();
fSourceViewer.resetVisibleRegion();
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Change Visibility in Editor";
}
public void run() {
super.run();
StructuredTextViewer sourceViewer = null;
IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
if (part != null && part instanceof StructuredTextEditor) {
sourceViewer = ((StructuredTextEditor) part).getTextViewer();
}
if (sourceViewer != null) {
NumberInputDialog dlg = new NumberInputDialog(sourceViewer.getControl().getShell());
int proceed = dlg.open();
if (proceed == Window.CANCEL)
return;
sourceViewer.resetVisibleRegion();
sourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
}
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Show All in Editor";
}
public void run() {
super.run();
StructuredTextViewer sourceViewer = null;
IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
if (part != null && part instanceof StructuredTextEditor) {
sourceViewer = ((StructuredTextEditor) part).getTextViewer();
}
if (sourceViewer != null) {
sourceViewer.resetVisibleRegion();
}
}
});
mgr.add(new Separator());
// no longer able to set input to NULL
// mgr.add(new Action() {
// public String getText() {
// return getToolTipText();
// }
//
// public String getToolTipText() {
// return "Set Input to NULL";
// }
// public void run() {
// super.run();
// viewer.setInput(null);
// }
// });
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input from Active Editor";
}
public void run() {
super.run();
ITextEditor textEditor = getActiveEditor();
if (textEditor != null) {
setupViewerForEditor(textEditor);
fSourceViewer.setEditable(true);
}
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input and Follow Selection";
}
public void run() {
super.run();
followSelection();
fSourceViewer.setEditable(true);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Take Input and Follow Selection As ReadOnly";
}
public void run() {
super.run();
followSelection();
fSourceViewer.setEditable(false);
}
});
mgr.add(new Action() {
public String getText() {
return getToolTipText();
}
public String getToolTipText() {
return "Stop Following Selection";
}
public void run() {
super.run();
stopFollowSelection();
}
});
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestEmbededCSSContentAssistComputers method runProposalTest.
/**
* <p>Run a proposal test by opening the given file and invoking content assist for
* each expected proposal count at the given line number and line character
* offset and then compare the number of proposals for each invocation (pages) to the
* expected number of proposals.</p>
*
* @param fileName
* @param lineNum
* @param lineRelativeCharOffset
* @param expectedProposalCounts
* @throws Exception
*/
private static void runProposalTest(String fileName, int lineNum, int lineRelativeCharOffset, int[] expectedProposalCounts) throws Exception {
IFile file = getFile(fileName);
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
int offset = viewer.getDocument().getLineOffset(lineNum) + lineRelativeCharOffset;
ICompletionProposal[][] pages = getProposals(viewer, offset, expectedProposalCounts.length);
verifyProposalCounts(pages, expectedProposalCounts);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestEmbededCSSContentAssistComputers method getEditor.
/**
* <p>Given a <code>file</code> get an editor for it. If an editor has already
* been retrieved for the given <code>file</code> then return the same already
* open editor.</p>
*
* <p>When opening the editor it will also standardized the line
* endings to <code>\n</code></p>
*
* @param file open and return an editor for this
* @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
*/
private static StructuredTextEditor getEditor(IFile file) {
StructuredTextEditor editor = (StructuredTextEditor) fFileToEditorMap.get(file);
if (editor == null) {
try {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorPart editorPart = IDE.openEditor(page, file, "org.eclipse.wst.html.core.htmlsource.source", true);
if (editorPart instanceof StructuredTextEditor) {
editor = ((StructuredTextEditor) editorPart);
} else {
fail("Unable to open structured text editor: " + editorPart.getClass().getName());
}
if (editor != null) {
standardizeLineEndings(editor);
fFileToEditorMap.put(file, editor);
} else {
fail("Could not open editor for " + file);
}
} catch (Exception e) {
fail("Could not open editor for " + file + " exception: " + e.getMessage());
}
}
return editor;
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestCSSContentAssistComputers method runProposalTest.
/**
* <p>Run a proposal test by opening the given file and invoking content assist for
* each expected proposal count at the given line number and line character
* offset and then compare the number of proposals for each invocation (pages) to the
* expected number of proposals.</p>
*
* @param fileName
* @param lineNum
* @param lineRelativeCharOffset
* @param expectedProposalCounts
* @throws Exception
*/
private static void runProposalTest(String fileName, int lineNum, int lineRelativeCharOffset, int[] expectedProposalCounts) throws Exception {
IFile file = getFile(fileName);
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
int offset = viewer.getDocument().getLineOffset(lineNum) + lineRelativeCharOffset;
ICompletionProposal[][] pages = getProposals(viewer, offset, expectedProposalCounts.length);
verifyProposalCounts(pages, expectedProposalCounts);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestCSSContentAssistComputers method getEditor.
/**
* <p>Given a <code>file</code> get an editor for it. If an editor has already
* been retrieved for the given <code>file</code> then return the same already
* open editor.</p>
*
* <p>When opening the editor it will also standardized the line
* endings to <code>\n</code></p>
*
* @param file open and return an editor for this
* @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
*/
private static StructuredTextEditor getEditor(IFile file) {
StructuredTextEditor editor = (StructuredTextEditor) fFileToEditorMap.get(file);
if (editor == null) {
try {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorPart editorPart = IDE.openEditor(page, file, "org.eclipse.wst.css.core.csssource.source", true);
if (editorPart instanceof StructuredTextEditor) {
editor = ((StructuredTextEditor) editorPart);
} else {
fail("Unable to open structured text editor: " + editorPart.getClass().getName());
}
if (editor != null) {
standardizeLineEndings(editor);
fFileToEditorMap.put(file, editor);
} else {
fail("Could not open editor for " + file);
}
} catch (Exception e) {
fail("Could not open editor for " + file + " exception: " + e.getMessage());
}
}
return editor;
}
Aggregations