use of org.eclipse.wst.sse.core.internal.text.IExecutionDelegatable in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method dispose.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
// $NON-NLS-1$ //$NON-NLS-2$
Logger.trace("Source Editor", "StructuredTextEditor::dispose entry");
if (org.eclipse.wst.sse.core.internal.util.Debug.perfTestAdapterClassLoading) {
// $NON-NLS-1$
System.out.println("Total calls to getAdapter: " + adapterRequests);
// $NON-NLS-1$
System.out.println("Total time in getAdapter: " + adapterTime);
// $NON-NLS-1$
System.out.println("Average time per call: " + (adapterTime / adapterRequests));
}
ISourceViewer viewer = getSourceViewer();
if (viewer instanceof ITextViewerExtension)
((ITextViewerExtension) viewer).removeVerifyKeyListener(fPairInserter);
// dispose of information presenter
if (fInformationPresenter != null) {
fInformationPresenter.dispose();
fInformationPresenter = null;
}
if (fOutlineHandler != null) {
fOutlineHandler.dispose();
fOutlineHandler = null;
}
// dispose of selection history
if (fSelectionHistory != null) {
fSelectionHistory.dispose();
fSelectionHistory = null;
}
if (fProjectionSupport != null) {
fProjectionSupport.dispose();
fProjectionSupport = null;
}
if (fFoldingGroup != null) {
fFoldingGroup.dispose();
fFoldingGroup = null;
}
// dispose of menus that were being tracked
if (fTextContextMenu != null) {
fTextContextMenu.dispose();
fTextContextMenu = null;
}
if (fRulerContextMenu != null) {
fRulerContextMenu.dispose();
fRulerContextMenu = null;
}
if (fTextContextMenuManager != null) {
fTextContextMenuManager.removeMenuListener(getContextMenuListener());
fTextContextMenuManager.removeAll();
fTextContextMenuManager.dispose();
}
if (fRulerContextMenuManager != null) {
fRulerContextMenuManager.removeMenuListener(getContextMenuListener());
fRulerContextMenuManager.removeAll();
fRulerContextMenuManager.dispose();
}
// less severe.
if (fStructuredModel != null) {
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
// fStructuredModel.setStructuredDocument(null);
/* BUG398460 - Editor is still marked dirty when relaunching editor after closing without saving changes */
// fStructuredModel = null;
}
// to document, so nothing to remove
if (getDocumentProvider() != null) {
IDocument doc = getDocumentProvider().getDocument(getEditorInput());
if (doc != null) {
if (doc instanceof IExecutionDelegatable) {
((IExecutionDelegatable) doc).setExecutionDelegate(null);
}
}
}
// up after themselves
if (fOutlinePage != null) {
if (fOutlinePage instanceof ConfigurableContentOutlinePage && fOutlinePageListener != null) {
((ConfigurableContentOutlinePage) fOutlinePage).removeDoubleClickListener(fOutlinePageListener);
}
if (fOutlinePageListener != null) {
fOutlinePage.removeSelectionChangedListener(fOutlinePageListener);
fOutlinePageListener = null;
}
fOutlinePage = null;
}
fEditorDisposed = true;
disposeModelDependentFields();
if (fDropTarget != null)
fDropTarget.dispose();
if (fPartListener != null) {
getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
fPartListener = null;
}
uninstallSemanticHighlighting();
if (fPairInserter != null) {
fPairInserter.dispose();
fPairInserter = null;
}
setPreferenceStore(null);
/*
* Strictly speaking, but following null outs should not be needed,
* but in the event of a memory leak, they make the memory leak less
* severe
*/
fDropAdapter = null;
fDropTarget = null;
if (fStructuredSelectionProvider != null) {
fStructuredSelectionProvider.dispose();
fStructuredSelectionProvider = null;
}
if (fStatusLineLabelProvider != null) {
fStatusLineLabelProvider.dispose();
fStatusLineLabelProvider = null;
}
setStatusLineMessage(null);
super.dispose();
// $NON-NLS-1$ //$NON-NLS-2$
Logger.trace("Source Editor", "StructuredTextEditor::dispose exit");
}
use of org.eclipse.wst.sse.core.internal.text.IExecutionDelegatable in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method tryToGetModel.
/**
* <p>Attempts to get the {@link IStructuredModel} for the given {@link IEditorInput}</p>
*
* @param input the {@link IEditorInput} to try and get the {@link IStructuredModel} for
*
* @return The {@link IStructuredModel} associated with the given {@link IEditorInput} or
* <code>null</code> if no associated {@link IStructuredModel} could be found.
*/
private IStructuredModel tryToGetModel(IEditorInput input) {
IStructuredModel model = null;
IDocument newDocument = getDocumentProvider().getDocument(input);
if (newDocument instanceof IExecutionDelegatable) {
((IExecutionDelegatable) newDocument).setExecutionDelegate(new EditorExecutionContext(this));
}
// if we have a Model provider, get the model from it
if (getDocumentProvider() instanceof IModelProvider) {
model = ((IModelProvider) getDocumentProvider()).getModel(getEditorInput());
if (!model.isShared()) {
EditorModelUtil.addFactoriesTo(model);
}
} else if (newDocument instanceof IStructuredDocument) {
// corresponding releaseFromEdit occurs in dispose()
model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) newDocument);
EditorModelUtil.addFactoriesTo(model);
}
return model;
}
use of org.eclipse.wst.sse.core.internal.text.IExecutionDelegatable in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method doSetInput.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
*/
protected void doSetInput(IEditorInput input) throws CoreException {
IEditorInput oldInput = getEditorInput();
if (oldInput != null) {
IDocument olddoc = getDocumentProvider().getDocument(oldInput);
if (olddoc != null && olddoc instanceof IExecutionDelegatable) {
((IExecutionDelegatable) olddoc).setExecutionDelegate(null);
}
}
if (fStructuredModel != null && !(getDocumentProvider() instanceof IModelProvider)) {
fStructuredModel.releaseFromEdit();
}
// attempt to get the model for the given input
super.doSetInput(input);
IStructuredModel model = tryToGetModel(input);
/* if could not get the model prompt user to update content type
* if preferences allow, then try to get model again
*/
if (model == null && SSEUIPlugin.getDefault().getPreferenceStore().getBoolean(EditorPreferenceNames.SHOW_UNKNOWN_CONTENT_TYPE_MSG)) {
if (fInitializationData != null && fInitializationData.containsKey(PREFERRED_CONTENT_TYPE_WHEN_UNSUPPORTED)) {
IContentType contentType = Platform.getContentTypeManager().getContentType(fInitializationData.get(PREFERRED_CONTENT_TYPE_WHEN_UNSUPPORTED).toString());
if (contentType != null && !StringUtils.contains(contentType.getFileSpecs(IContentTypeSettings.FILE_NAME_SPEC), input.getName(), false)) {
/*
* Display a dialog informing user of unknown content type,
* offering to update preferences for them
*/
UnknownContentTypeDialog2 dialog = new UnknownContentTypeDialog2(getSite().getShell(), SSEUIPlugin.getDefault().getPreferenceStore(), input.getName(), contentType);
dialog.open();
}
} else {
/*
* Display a dialog informing user of unknown content type,
* giving them chance to update preferences
*/
UnknownContentTypeDialog dialog = new UnknownContentTypeDialog(getSite().getShell(), SSEUIPlugin.getDefault().getPreferenceStore(), EditorPreferenceNames.SHOW_UNKNOWN_CONTENT_TYPE_MSG);
dialog.open();
}
// try to get model again in hopes user updated preferences
super.doSetInput(input);
model = tryToGetModel(input);
// still could not get the model to open this editor, so log
if (model == null) {
logUnexpectedDocumentKind(input);
}
}
if (fStructuredModel != null || model != null) {
setModel(model);
}
if (getInternalModel() != null) {
updateEditorControlsForContentType(getInternalModel().getContentTypeIdentifier());
} else {
updateEditorControlsForContentType(null);
}
// start editor with smart insert mode
setInsertMode(SMART_INSERT);
}
Aggregations