use of org.eclipse.wst.sse.ui.internal.UnknownContentTypeDialog2 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