Search in sources :

Example 1 with ListenerList

use of org.eclipse.core.runtime.ListenerList in project che by eclipse.

the class UndoManager2 method addListener.

public void addListener(IUndoManagerListener listener) {
    if (fListeners == null) {
        fListeners = new ListenerList(ListenerList.IDENTITY);
        fOperationHistoryListener = new OperationHistoryListener();
        fOperationHistory.addOperationHistoryListener(fOperationHistoryListener);
    }
    fListeners.add(listener);
}
Also used : ListenerList(org.eclipse.core.runtime.ListenerList) IOperationHistoryListener(org.eclipse.core.commands.operations.IOperationHistoryListener)

Example 2 with ListenerList

use of org.eclipse.core.runtime.ListenerList in project yamcs-studio by yamcs.

the class SpreadSheetTable method addSelectionChangedListener.

/**
 *Add a selection changed listener. Call whenever selection of the table changes.
 * @param listener the listener
 */
public void addSelectionChangedListener(ITableSelectionChangedListener listener) {
    if (selectionChangedListeners == null) {
        selectionChangedListeners = new ListenerList();
        tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
                String[][] selection = getSelection();
                for (Object listener : selectionChangedListeners.getListeners()) {
                    ((ITableSelectionChangedListener) listener).selectionChanged(selection);
                }
            }
        });
    }
    selectionChangedListeners.add(listener);
}
Also used : ListenerList(org.eclipse.core.runtime.ListenerList) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 3 with ListenerList

use of org.eclipse.core.runtime.ListenerList in project tmdm-studio-se by Talend.

the class MDMProblemView method findListener.

private Object findListener(TreeViewer treeViewer) {
    try {
        // $NON-NLS-1$
        Field doubleListenersField = StructuredViewer.class.getDeclaredField("doubleClickListeners");
        if (doubleListenersField != null) {
            doubleListenersField.setAccessible(true);
            ListenerList list = (ListenerList) doubleListenersField.get(treeViewer);
            for (Object listenerObj : list.getListeners()) {
                if (listenerObj.getClass().getEnclosingClass() == OpenAndLinkWithEditorHelper.class) {
                    return listenerObj;
                }
            }
        }
    } catch (SecurityException e) {
        log.error(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
        log.error(e.getMessage(), e);
    } catch (NoSuchFieldException e) {
        log.error(e.getMessage(), e);
    } catch (IllegalAccessException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}
Also used : ListenerList(org.eclipse.core.runtime.ListenerList) Field(java.lang.reflect.Field) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 4 with ListenerList

use of org.eclipse.core.runtime.ListenerList in project eclipse-integration-commons by spring-projects.

the class LiveExpression method addListener.

public void addListener(ValueListener<V> l) {
    ListenerList fListeners = this.fListeners;
    if (fListeners != null) {
        fListeners.add(l);
        l.gotValue(this, value);
    }
}
Also used : ListenerList(org.eclipse.core.runtime.ListenerList)

Example 5 with ListenerList

use of org.eclipse.core.runtime.ListenerList in project liferay-ide by liferay.

the class AlloyContentDescriberForJSP method describe.

@Override
public int describe(Reader contents, IContentDescription description) throws IOException {
    int retval = new ContentDescriberForJSP().describe(contents, description);
    try {
        Class<?> reader = contents.getClass();
        Field documentReaderField = reader.getDeclaredField("in");
        documentReaderField.setAccessible(true);
        Object documentReader = documentReaderField.get(contents);
        Class<?> docReader = documentReader.getClass();
        Field fDocumentField = docReader.getDeclaredField("fDocument");
        fDocumentField.setAccessible(true);
        Object fDocument = fDocumentField.get(documentReader);
        Class<?> documentClass = fDocument.getClass();
        Class<?> superDocument = documentClass.getSuperclass().getSuperclass();
        Field fDocumentListenersField = superDocument.getDeclaredField("fDocumentListeners");
        fDocumentListenersField.setAccessible(true);
        ListenerList<?> fDocumentListeners = (ListenerList<?>) fDocumentListenersField.get(fDocument);
        Object[] listeners = fDocumentListeners.getListeners();
        for (Object listener : listeners) {
            try {
                Class<?> listenerClass = listener.getClass();
                Class<?> enclosingClass = listenerClass.getEnclosingClass();
                Class<?> superClass = enclosingClass.getSuperclass();
                Field fFileField = superClass.getDeclaredField("fFile");
                fFileField.setAccessible(true);
                // get enclosing instance of listener
                Field thisField = listenerClass.getDeclaredField("this$0");
                thisField.setAccessible(true);
                Object enclosingObject = thisField.get(listener);
                Object fFile = fFileField.get(enclosingObject);
                if (fFile instanceof IFile) {
                    IFile file = (IFile) fFile;
                    if (ProjectUtil.isPortletProject(file.getProject()) || LiferayNature.hasNature(file.getProject())) {
                        return VALID;
                    }
                }
            } catch (Exception e) {
            }
        }
    } catch (Exception e) {
    }
    return retval;
}
Also used : ListenerList(org.eclipse.core.runtime.ListenerList) Field(java.lang.reflect.Field) IFile(org.eclipse.core.resources.IFile) ContentDescriberForJSP(org.eclipse.jst.jsp.core.internal.contenttype.ContentDescriberForJSP) IOException(java.io.IOException)

Aggregations

ListenerList (org.eclipse.core.runtime.ListenerList)7 Field (java.lang.reflect.Field)3 IOException (java.io.IOException)2 IFile (org.eclipse.core.resources.IFile)2 IOperationHistoryListener (org.eclipse.core.commands.operations.IOperationHistoryListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ContentDescriberForJSP (org.eclipse.jst.jsp.core.internal.contenttype.ContentDescriberForJSP)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1