PageRenderTime 86ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/org.svenk.redmine.ui/src/org/svenk/redmine/ui/wizard/RedmineContentProvider.java

https://github.com/farukcank/redmin-mylyncon
Java | 57 lines | 30 code | 7 blank | 20 comment | 3 complexity | bdc358aacdee2f5c99540039ecb4bebb MD5 | raw file
  1. /*******************************************************************************
  2. * Copyright (c) 2004, 2007 Mylyn project committers and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Mylyn project committers
  10. *******************************************************************************/
  11. /*******************************************************************************
  12. * Copyright (c) 2008 Sven Krzyzak
  13. * All rights reserved. This program and the accompanying materials
  14. * are made available under the terms of the Eclipse Public License v1.0
  15. * which accompanies this distribution, and is available at
  16. * http://www.eclipse.org/legal/epl-v10.html
  17. *
  18. * Contributors:
  19. * Sven Krzyzak - adapted Trac implementation for Redmine
  20. *******************************************************************************/
  21. package org.svenk.redmine.ui.wizard;
  22. import java.util.Collection;
  23. import org.eclipse.jface.viewers.ISelection;
  24. import org.eclipse.jface.viewers.IStructuredContentProvider;
  25. import org.eclipse.jface.viewers.Viewer;
  26. import org.eclipse.swt.widgets.Display;
  27. public class RedmineContentProvider implements IStructuredContentProvider {
  28. public Object[] getElements(Object inputElement) {
  29. if (inputElement instanceof Collection<?>) {
  30. Collection<?> collection = (Collection<?>)inputElement;
  31. return collection.toArray(new Object[collection.size()]);
  32. }
  33. return null;
  34. }
  35. public void dispose() {
  36. }
  37. public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) {
  38. if (oldInput==null || newInput==null) {
  39. return;
  40. }
  41. reselect(viewer, viewer.getSelection());
  42. }
  43. private void reselect(final Viewer viewer, final ISelection selection) {
  44. Display.getCurrent().asyncExec(new Runnable() {
  45. public void run() {
  46. viewer.setSelection(selection, true);
  47. }
  48. });
  49. }
  50. }