use of org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method createPropertySheetConfiguration.
protected PropertySheetConfiguration createPropertySheetConfiguration() {
PropertySheetConfiguration cfg = null;
ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
String[] ids = getConfigurationPoints();
for (int i = 0; cfg == null && i < ids.length; i++) {
cfg = (PropertySheetConfiguration) builder.getConfiguration(ExtendedConfigurationBuilder.PROPERTYSHEETCONFIGURATION, ids[i]);
}
return cfg;
}
use of org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration in project webtools.sourceediting by eclipse.
the class TestPropertySheetConfiguration method testPropertySourceRemoval.
public void testPropertySourceRemoval() throws BadLocationException {
IDocument document = (IDocument) fEditor.getAdapter(IDocument.class);
// set up the editor document
document.replace(0, 0, "<test><myproperty props=\"yes\" /></test>");
// set current selection in editor
ISelection setSelection = new TextSelection(9, 0);
fEditor.getSelectionProvider().setSelection(setSelection);
// get current selection in editor
Object item = null;
ISelection selection = fEditor.getSelectionProvider().getSelection();
if (selection instanceof IStructuredSelection) {
item = ((IStructuredSelection) selection).getFirstElement();
IPropertySheetPage propertySheet = (IPropertySheetPage) fEditor.getAdapter(IPropertySheetPage.class);
assertTrue("No ConfigurablePropertySheetPage found", propertySheet instanceof ConfigurablePropertySheetPage);
if (propertySheet instanceof ConfigurablePropertySheetPage) {
ConfigurablePropertySheetPage cps = (ConfigurablePropertySheetPage) propertySheet;
PropertySheetConfiguration config = cps.getConfiguration();
assertNotNull("No property sheet configuration found", config);
IPropertySourceProvider provider = config.getPropertySourceProvider(cps);
assertNotNull("No property sheet provider found", provider);
IPropertySource source = provider.getPropertySource(item);
if (source instanceof IPropertySourceExtension) {
boolean canRemove = ((IPropertySourceExtension) source).isPropertyRemovable("props");
assertTrue("Current property cannot be removed", canRemove);
if (canRemove) {
((IPropertySourceExtension) source).removeProperty("props");
assertTrue("Current property cannot be removed", true);
// failing assert
return;
}
}
}
}
// if we get to here, always fail, since something went wrong.
assertTrue("testPropertySourceRemoval test did not take expected path", false);
}
use of org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method update.
/**
* Update should be called whenever the model is set or changed (as in
* swapped)
* <p>
* Not API. May be removed in the future.
* </p>
*/
public void update() {
if (fOutlinePage != null && fOutlinePage instanceof ConfigurableContentOutlinePage) {
ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
((ConfigurableContentOutlinePage) fOutlinePage).setConfiguration(cfg);
IStructuredModel internalModel = getInternalModel();
((ConfigurableContentOutlinePage) fOutlinePage).setInputContentTypeIdentifier(internalModel == null ? null : internalModel.getContentTypeIdentifier());
((ConfigurableContentOutlinePage) fOutlinePage).setInput(internalModel);
}
if (fPropertySheetPage != null && fPropertySheetPage instanceof ConfigurablePropertySheetPage) {
PropertySheetConfiguration cfg = createPropertySheetConfiguration();
((ConfigurablePropertySheetPage) fPropertySheetPage).setConfiguration(cfg);
}
disposeModelDependentFields();
fShowInTargetIds = createShowInTargetIds();
if (getSourceViewerConfiguration() instanceof StructuredTextViewerConfiguration && fStatusLineLabelProvider != null) {
fStatusLineLabelProvider.dispose();
}
String configurationId = fViewerConfigurationTargetId;
updateSourceViewerConfiguration();
/* Only reinstall if the configuration id has changed */
if (configurationId != null && !configurationId.equals(fViewerConfigurationTargetId)) {
uninstallSemanticHighlighting();
installSemanticHighlighting();
}
if (getSourceViewerConfiguration() instanceof StructuredTextViewerConfiguration) {
fStatusLineLabelProvider = ((StructuredTextViewerConfiguration) getSourceViewerConfiguration()).getStatusLineLabelProvider(getSourceViewer());
updateStatusLine(null);
}
if (fEncodingSupport != null && fEncodingSupport instanceof EncodingSupport) {
((EncodingSupport) fEncodingSupport).reinitialize(getConfigurationPoints());
}
createModelDependentFields();
}
use of org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method getAdapter.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class required) {
if (org.eclipse.wst.sse.core.internal.util.Debug.perfTestAdapterClassLoading) {
startPerfTime = System.currentTimeMillis();
}
Object result = null;
// text editor
IStructuredModel internalModel = getInternalModel();
if (ITextEditor.class.equals(required) || ITextEditorExtension5.class.equals(required) || ITextEditorExtension4.class.equals(required) || ITextEditorExtension3.class.equals(required) || ITextEditorExtension2.class.equals(required) || ITextEditorExtension.class.equals(required)) {
result = this;
} else if (IWorkbenchSiteProgressService.class.equals(required)) {
return getEditorPart().getSite().getAdapter(IWorkbenchSiteProgressService.class);
} else // content outline page
if (IContentOutlinePage.class.equals(required)) {
if (fOutlinePage == null && !fEditorDisposed) {
ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
if (cfg != null) {
ConfigurableContentOutlinePage outlinePage = new ConfigurableContentOutlinePage();
outlinePage.setConfiguration(cfg);
if (internalModel != null) {
outlinePage.setInputContentTypeIdentifier(internalModel.getContentTypeIdentifier());
outlinePage.setInput(internalModel);
}
if (fOutlinePageListener == null) {
fOutlinePageListener = new OutlinePageListener();
}
outlinePage.addSelectionChangedListener(fOutlinePageListener);
outlinePage.addDoubleClickListener(fOutlinePageListener);
fOutlinePage = outlinePage;
}
}
result = fOutlinePage;
} else // property sheet page, but only if the input's editable
if (IPropertySheetPage.class.equals(required) && isEditable()) {
if (fPropertySheetPage == null || fPropertySheetPage.getControl() == null || fPropertySheetPage.getControl().isDisposed()) {
PropertySheetConfiguration cfg = createPropertySheetConfiguration();
if (cfg != null) {
ConfigurablePropertySheetPage propertySheetPage = new ConfigurablePropertySheetPage();
propertySheetPage.setConfiguration(cfg);
fPropertySheetPage = propertySheetPage;
}
}
result = fPropertySheetPage;
} else if (IDocument.class.equals(required)) {
result = getDocumentProvider().getDocument(getEditorInput());
} else if (ISourceEditingTextTools.class.equals(required)) {
result = createSourceEditingTextTools();
} else if (IToggleBreakpointsTarget.class.equals(required)) {
result = ToggleBreakpointsTarget.getInstance();
} else if (ITextEditorExtension4.class.equals(required)) {
result = this;
} else if (IShowInTargetList.class.equals(required)) {
result = new ShowInTargetListAdapter();
} else if (IVerticalRuler.class.equals(required)) {
return getVerticalRuler();
} else if (SelectionHistory.class.equals(required)) {
if (fSelectionHistory == null)
fSelectionHistory = new SelectionHistory(this);
result = fSelectionHistory;
} else if (IResource.class.equals(required)) {
IEditorInput input = getEditorInput();
if (input != null) {
result = input.getAdapter(required);
}
} else {
if (result == null && internalModel != null) {
result = internalModel.getAdapter(required);
}
// others
if (result == null)
result = super.getAdapter(required);
}
if (result == null) {
// Logger.log(Logger.INFO_DEBUG, "StructuredTextEditor.getAdapter returning null for " + required); //$NON-NLS-1$
}
if (org.eclipse.wst.sse.core.internal.util.Debug.perfTestAdapterClassLoading) {
long stop = System.currentTimeMillis();
adapterRequests++;
adapterTime += (stop - startPerfTime);
}
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));
}
return result;
}
Aggregations