Java Code Examples for org.eclipse.xtext.ui.editor.XtextEditor#isEditable()

The following examples show how to use org.eclipse.xtext.ui.editor.XtextEditor#isEditable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtendEditorErrorTickUpdater.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void updateEditorImage(XtextEditor xtextEditor) {
	if (xtextEditor != null && !xtextEditor.isEditable()) {
		Severity severity = getSeverity(xtextEditor);
		if (severity != null && severity != Severity.INFO) {
			ImageDescriptor descriptor = severity == Severity.ERROR ? XtextPluginImages.DESC_OVR_ERROR
					: XtextPluginImages.DESC_OVR_WARNING;
			// TODO replace with new constructor that takes an ImageDescription when on Oxygen+
			DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(pluginImageHelper.getImage(images.forReadonly()), descriptor,
					IDecoration.BOTTOM_LEFT);
			scheduleUpdateEditor(decorationOverlayIcon);
		} else {
			scheduleUpdateEditor(images.forReadonly());
		}
	} else {
		super.updateEditorImage(xtextEditor);
	}
}
 
Example 2
Source File: OwnResourceValidatorAwareValidatingEditorCallback.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void afterCreatePartControl(final XtextEditor editor) {
	super.afterCreatePartControl(editor);
	if (editor.isEditable()) {
		newValidationJob(editor).schedule();
	}
}
 
Example 3
Source File: OwnResourceValidatorAwareValidatingEditorCallback.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void afterSave(final XtextEditor editor) {
	super.afterSave(editor);
	if (editor.isEditable()) {
		newValidationJob(editor).schedule();
	}
}
 
Example 4
Source File: ValidatingEditorCallback.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void afterCreatePartControl(XtextEditor editor) {
	super.afterCreatePartControl(editor);
	if (editor.isEditable()) {
		ValidationJob validationJob = newValidationJob(editor);
		validationJob.schedule();
	}
}
 
Example 5
Source File: ValidatingEditorCallback.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void afterSave(XtextEditor editor) {
	super.afterSave(editor);
	if (editor.isEditable()) {
		ValidationJob validationJob = newValidationJob(editor);
		validationJob.schedule();
	}
}
 
Example 6
Source File: PasteJavaCodeHandler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	final XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (activeXtextEditor == null || !activeXtextEditor.isEditable()) {
		return null;
	}

	String clipboardText = ClipboardUtil.getTextFromClipboard();
	if (!Strings.isEmpty(clipboardText)) {
		JavaImportData javaImports = ClipboardUtil.getJavaImportsContent();
		doPasteJavaCode(activeXtextEditor, clipboardText, javaImports);
	}
	return null;
}