use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class CSSCodeFoldingTest method testAddNode.
/**
* <p><b>TEST:</b> that folding annotations are updated after node is added</p>
*/
public void testAddNode() throws Exception {
IFile file = getFile("CSSFoldingTest2.css");
StructuredTextEditor editor = getEditor(file);
try {
StructuredTextViewer viewer = editor.getTextViewer();
IDocument doc = viewer.getDocument();
doc.replace(255, 0, "\ntd {\nborder: 1px solid black;\n}\n");
editor.doSave(null);
List expectedPositions = new ArrayList();
expectedPositions.add(new Position(291, 69));
expectedPositions.add(new Position(256, 31));
expectedPositions.add(new Position(21, 113));
expectedPositions.add(new Position(434, 120));
expectedPositions.add(new Position(181, 72));
expectedPositions.add(new Position(366, 62));
waitForReconcileThenVerify(viewer, expectedPositions);
} catch (BadLocationException e) {
fail("Test is broken, add location has become invalid.\n" + e.getMessage());
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class CSSCodeFoldingTest method testRemoveNode.
/**
* <p><b>TEST:</b> that folding annotations are updated after node is removed</p>
*/
public void testRemoveNode() throws Exception {
IFile file = getFile("CSSFoldingTest1.css");
StructuredTextEditor editor = getEditor(file);
try {
StructuredTextViewer viewer = editor.getTextViewer();
IDocument doc = viewer.getDocument();
doc.replace(253, 76, "");
editor.doSave(null);
final List expectedPositions = new ArrayList();
expectedPositions.add(new Position(325, 120));
expectedPositions.add(new Position(21, 113));
expectedPositions.add(new Position(181, 72));
expectedPositions.add(new Position(257, 62));
waitForReconcileThenVerify(viewer, expectedPositions);
} catch (BadLocationException e) {
fail("Test is broken, replace location has become invalid.\n" + e.getMessage());
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class CSSCodeFoldingTest method testInitFolding.
/**
* <p><b>TEST:</b> the initially placed folding annotations</p>
*/
public void testInitFolding() throws Exception {
IFile file = getFile("CSSFoldingTest1.css");
StructuredTextEditor editor = getEditor(file);
List expectedPositions = new ArrayList();
expectedPositions.add(new Position(401, 120));
expectedPositions.add(new Position(333, 62));
expectedPositions.add(new Position(181, 72));
expectedPositions.add(new Position(258, 69));
expectedPositions.add(new Position(21, 113));
waitForReconcileThenVerify(editor.getTextViewer(), expectedPositions);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class PlatformStatusLineUtil method _displayTemporaryMessage.
static boolean _displayTemporaryMessage(ITextViewer viewer, String msg, boolean isError) {
boolean messageShown = false;
IEditorPart editor = getActiveEditor();
if (editor != null) {
ITextEditor textEditor = editor.getAdapter(ITextEditor.class);
if (textEditor != null && textEditor instanceof StructuredTextEditor) {
if (((StructuredTextEditor) textEditor).getTextViewer() == viewer) {
IStatusLineManager statusLineManager = editor.getEditorSite().getActionBars().getStatusLineManager();
if (isError)
statusLineManager.setErrorMessage(msg);
else
statusLineManager.setMessage(msg);
new OneTimeListener(viewer.getTextWidget(), new ClearStatusLine(statusLineManager, isError));
messageShown = true;
}
}
}
if (!messageShown) {
displayErrorMessage(msg);
addOneTimeClearListener();
}
return messageShown;
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class FindOccurrencesActionDelegate method run.
public void run(IAction action) {
boolean okay = false;
if (fEditor instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) fEditor;
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
if (document != null) {
ITextSelection textSelection = getTextSelection(textEditor);
FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
if (findOccurrenceProcessor != null) {
if (textEditor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
}
}
}
}
if (okay) {
// clear status message
PlatformStatusLineUtil.clearStatusLine();
} else {
// $NON-NLS-1$
String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0;
if (fEditor instanceof StructuredTextEditor) {
PlatformStatusLineUtil.displayTemporaryErrorMessage(((StructuredTextEditor) fEditor).getTextViewer(), errorMessage);
} else {
PlatformStatusLineUtil.displayErrorMessage(errorMessage);
PlatformStatusLineUtil.addOneTimeClearListener();
}
}
}
Aggregations