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);
}
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);
}
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;
}
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);
}
}
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;
}
Aggregations