Search in sources :

Example 1 with PlatformObject

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);
    }
}
Also used : IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) PlatformObject(org.eclipse.core.runtime.PlatformObject) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch)

Example 2 with PlatformObject

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;
        }
    }
}
Also used : IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) PlatformObject(org.eclipse.core.runtime.PlatformObject)

Example 3 with PlatformObject

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;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) PlatformObject(org.eclipse.core.runtime.PlatformObject) PlatformObject(org.eclipse.core.runtime.PlatformObject)

Example 4 with PlatformObject

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;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) PlatformObject(org.eclipse.core.runtime.PlatformObject) PlatformObject(org.eclipse.core.runtime.PlatformObject)

Example 5 with PlatformObject

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);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SpellcheckableMessageArea(org.eclipse.egit.ui.internal.dialogs.SpellcheckableMessageArea) PlatformObject(org.eclipse.core.runtime.PlatformObject) Point(org.eclipse.swt.graphics.Point) Section(org.eclipse.ui.forms.widgets.Section) Point(org.eclipse.swt.graphics.Point) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

PlatformObject (org.eclipse.core.runtime.PlatformObject)5 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)2 ILaunch (org.eclipse.debug.core.ILaunch)1 Launch (org.eclipse.debug.core.Launch)1 SpellcheckableMessageArea (org.eclipse.egit.ui.internal.dialogs.SpellcheckableMessageArea)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 StyledText (org.eclipse.swt.custom.StyledText)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 Section (org.eclipse.ui.forms.widgets.Section)1