use of org.eclipse.core.runtime.PlatformObject in project statecharts by Yakindu.
the class AbstractDebugTargetView method debugContextChanged.
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
PlatformObject object = (PlatformObject) ((IStructuredSelection) event.getContext()).getFirstElement();
if (object == null)
return;
IDebugTarget newTarget = null;
if (object instanceof Launch) {
newTarget = ((Launch) object).getDebugTarget();
} else {
newTarget = (IDebugTarget) object.getAdapter(IDebugTarget.class);
}
changeTarget(newTarget);
}
}
use of org.eclipse.core.runtime.PlatformObject in project statecharts by Yakindu.
the class HighlightingSubmachineDecorationProvider method debugContextChanged.
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
PlatformObject object = (PlatformObject) ((IStructuredSelection) event.getContext()).getFirstElement();
if (object == null)
return;
IDebugTarget newTarget = (IDebugTarget) object.getAdapter(IDebugTarget.class);
if (newTarget != debugTarget && newTarget != null && !newTarget.isTerminated()) {
debugTarget = newTarget;
}
}
}
use of org.eclipse.core.runtime.PlatformObject in project ecf by eclipse.
the class WorkbenchLabelProvider method getAdapterUtil.
protected static final Object getAdapterUtil(Object sourceObject, Class adapterType) {
Assert.isNotNull(adapterType);
if (sourceObject == null)
return null;
if (adapterType.isInstance(sourceObject))
return sourceObject;
if (sourceObject instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) sourceObject;
Object result = adaptable.getAdapter(adapterType);
if (result != null) {
// Sanity-check
Assert.isTrue(adapterType.isInstance(result));
return result;
}
}
if (!(sourceObject instanceof PlatformObject)) {
Object result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
if (result != null)
return result;
}
return null;
}
use of org.eclipse.core.runtime.PlatformObject in project polymap4-core by Polymap4.
the class AdaptabilityUtility method getAdapter.
/**
* <p>
* Returns an adapter of the requested type (anAdapterType)
*
* @param anElement
* The element to adapt, which may or may not implement
* {@link IAdaptable}, or null
* @param anAdapterType
* The class type to return
* @return An adapter of the requested type or null
*/
public static Object getAdapter(Object anElement, Class anAdapterType) {
Assert.isNotNull(anAdapterType);
if (anElement == null) {
return null;
}
if (anAdapterType.isInstance(anElement)) {
return anElement;
}
if (anElement instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) anElement;
Object result = adaptable.getAdapter(anAdapterType);
if (result != null) {
// Sanity-check
Assert.isTrue(anAdapterType.isInstance(result));
return result;
}
}
if (!(anElement instanceof PlatformObject)) {
Object result = Platform.getAdapterManager().getAdapter(anElement, anAdapterType);
if (result != null) {
return result;
}
}
return null;
}
use of org.eclipse.core.runtime.PlatformObject in project egit by eclipse.
the class CommitEditorPage method createMessageArea.
private void createMessageArea(Composite parent, FormToolkit toolkit, int span) {
Section messageSection = createSection(parent, toolkit, UIText.CommitEditorPage_SectionMessage, span, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
Composite messageArea = createSectionClient(messageSection, toolkit);
RevCommit commit = getCommit().getRevCommit();
String message = commit.getFullMessage();
SpellcheckableMessageArea textContent = new SpellcheckableMessageArea(messageArea, message, true, toolkit.getBorderStyle()) {
@Override
protected IAdaptable getDefaultTarget() {
return new PlatformObject() {
@Override
public Object getAdapter(Class adapter) {
return Platform.getAdapterManager().getAdapter(getEditorInput(), adapter);
}
};
}
@Override
protected void createMarginPainter() {
// Disabled intentionally
}
};
if ((toolkit.getBorderStyle() & SWT.BORDER) == 0)
textContent.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
StyledText textWidget = textContent.getTextWidget();
Point size = textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int yHint = size.y > 80 ? 80 : SWT.DEFAULT;
GridDataFactory.fillDefaults().hint(SWT.DEFAULT, yHint).minSize(1, 20).grab(true, true).applyTo(textContent);
addToFocusTracking(textWidget);
updateSectionClient(messageSection, messageArea, toolkit);
}
Aggregations