@Override
  public void dispose() {
    super.dispose();

    modelDirty = true;
    observedVsrcWritable.clear();

    if (changeInputListener != null) observedVsrcWritable.removeChangeListener(changeInputListener);
  }
 @Test
 @UI
 public void inputIsDisposedOnContentChange() throws Exception {
   Shell s = new Shell();
   TreeViewer v = new TreeViewer(s);
   ITreeContentProvider cp = createFixture();
   v.setContentProvider(cp);
   WritableList input = WritableList.withElementType(String.class);
   v.setInput(input);
   v.setInput(null);
   assertTrue(input.isDisposed());
   s.close();
 }
 /**
  * Refreshes the list of Volumes to display in the for the given
  *
  * @param selectedImage
  */
 public void setSelectedImage(final IDockerImage selectedImage) {
   if (this.selectedImage != selectedImage) {
     this.selectedImage = selectedImage;
     final WritableList newDataVolumes = new WritableList();
     if (selectedImage != null) {
       this.imageInfo = selectedImage.getConnection().getImageInfo(selectedImage.id());
       if (this.imageInfo.config() != null && this.imageInfo.config().volumes() != null) {
         for (String volume : this.imageInfo.config().volumes()) {
           newDataVolumes.add(new DataVolumeModel(volume));
         }
       }
     }
     setDataVolumes(newDataVolumes);
   }
 }
Exemple #4
0
 public void moveTask() {
   if (!viewer.getSelection().isEmpty()) {
     IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
     Task p = (Task) selection.getFirstElement();
     input.remove(p);
   }
 }
Exemple #5
0
 private void deleteTODO() {
   if (!viewer.getSelection().isEmpty()) {
     IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
     Task p = (Task) selection.getFirstElement();
     input.remove(p);
   }
 }
  @Override
  public IObservableList getLanguageList() {
    if (myLanguageList == null) {
      myLanguageList = WritableList.withElementType(EcorePackage.Literals.ESTRING);
      myLanguageList.addAll(getEngines().keySet());

      // TODO monitor changes..
    }
    return myLanguageList;
  }
  public WritableList getObservedVsrcWritable() {
    if (observedVsrcWritable == null) {
      observedVsrcWritable = new WritableList(observedVsrc, VoltageSource.class);
      initPinListListener();

      observedVsrcWritable.addAll(PMFindVDomainTools.findAllVoltageSources(pmConfig));
    }

    return observedVsrcWritable;
  }
 private void recompute() {
   if (isDirty) {
     Map newContents = new HashMap();
     for (Iterator it = bindings.iterator(); it.hasNext(); ) {
       Binding binding = (Binding) it.next();
       IObservableValue validationError = binding.getValidationStatus();
       dependencies.add(validationError);
       validationError.addChangeListener(markDirtyChangeListener);
       IStatus validationStatusValue = (IStatus) validationError.getValue();
       newContents.put(binding, validationStatusValue);
     }
     wrappedMap.putAll(newContents);
     isDirty = false;
   }
 }
 private void remove(final MarketDataViewItem item) {
   mItemMap.remove(item.getEquity());
   mItems.remove(item);
   item.dispose();
 }
  @Override
  public void createPartControl(Composite parent) {
    final IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbar = actionBars.getToolBarManager();
    mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$
    toolbar.add(mSymbolEntryText);
    toolbar.add(new AddSymbolAction(mSymbolEntryText, this));

    final Table table =
        new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER);
    table.setHeaderVisible(true);
    mViewer = new TableViewer(table);
    GridDataFactory.defaultsFor(table).applyTo(table);

    final MarketDataItemComparator comparator = new MarketDataItemComparator();
    mViewer.setComparator(comparator);

    SelectionListener listener =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // determine new sort column and direction
            TableColumn sortColumn = table.getSortColumn();
            TableColumn currentColumn = (TableColumn) e.widget;
            final int index = table.indexOf(currentColumn);
            int dir = table.getSortDirection();
            if (sortColumn == currentColumn) {
              dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {
              table.setSortColumn(currentColumn);
              dir = SWT.UP;
            }
            table.setSortDirection(dir);
            comparator.setSort(dir == SWT.UP ? 1 : -1);
            comparator.setIndex(index);
            mViewer.refresh();
          }
        };

    // create columns, using FIXFieldLocalizer to preserve backwards
    // compatibility
    TableViewerColumn symbolColumn =
        new TableViewerColumn(
            mViewer,
            createColumn(
                table,
                FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()),
                SWT.LEFT,
                listener));
    symbolColumn.setEditingSupport(new SymbolEditingSupport());
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);

    // restore table state if it exists
    if (mViewState != null) {
      ColumnState.restore(table, mViewState);
      for (TableColumn column : table.getColumns()) {
        if (column.getWidth() == 0) {
          column.setResizable(false);
        }
      }
    }

    registerContextMenu();
    getSite().setSelectionProvider(mViewer);

    ObservableListContentProvider content = new ObservableListContentProvider();
    mViewer.setContentProvider(content);
    IObservableSet domain = content.getKnownElements();
    IObservableMap[] maps =
        new IObservableMap[] {
          BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$
        };
    mViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
    mViewer.setUseHashlookup(true);
    mItems = WritableList.withElementType(MarketDataViewItem.class);
    mViewer.setInput(mItems);
  }
 /**
  * Removes a trade suggestion from the managed collection.
  *
  * @param suggestion suggestion to remove
  */
 public void removeSuggestion(TradeSuggestion suggestion) {
   mSuggestions.remove(suggestion);
 }
/**
 * Manages trade suggestions.
 *
 * @author <a href="mailto:[email protected]">Will Horn</a>
 * @version $Id: TradeSuggestionManager.java 16154 2012-07-14 16:34:05Z colin $
 * @since 1.0.0
 */
@ClassVersion("$Id: TradeSuggestionManager.java 16154 2012-07-14 16:34:05Z colin $")
public final class TradeSuggestionManager implements ISinkDataHandler {

  /** Sink data manager */
  private final ISinkDataManager mSinkDataManager;

  /**
   * Returns the singleton instance for the currently running plug-in.
   *
   * @return the singleton instance
   */
  public static TradeSuggestionManager getCurrent() {
    return Activator.getCurrent().getTradeSuggestionManager();
  }

  private final WritableList mSuggestions = WritableList.withElementType(TradeSuggestion.class);

  /** This object should only be constructed by {@link Activator}. */
  TradeSuggestionManager() {
    mSinkDataManager = ModuleSupport.getSinkDataManager();
    mSinkDataManager.register(this, OrderSingleSuggestion.class);
  }

  /**
   * Returns the collection of trade suggestions.
   *
   * @return the trade suggestions
   */
  public IObservableList getTradeSuggestions() {
    return Observables.unmodifiableObservableList(mSuggestions);
  }

  /**
   * Adds a trade suggestion to the managed collection.
   *
   * @param suggestion new suggestion to add.
   * @param source the source of the suggestion
   */
  public void addSuggestion(final OrderSingleSuggestion suggestion, final String source) {
    final Date timestamp = new Date();
    // Ensure the update is performed in the main UI thread
    PlatformUI.getWorkbench()
        .getDisplay()
        .asyncExec(
            new Runnable() {

              @Override
              public void run() {
                mSuggestions.add(new TradeSuggestion(suggestion, source, timestamp));
              }
            });
  }

  /**
   * Removes a trade suggestion from the managed collection.
   *
   * @param suggestion suggestion to remove
   */
  public void removeSuggestion(TradeSuggestion suggestion) {
    mSuggestions.remove(suggestion);
  }

  @Override
  public void receivedData(DataFlowID inFlowID, Object inData) {
    OrderSingleSuggestion suggestion = (OrderSingleSuggestion) inData;
    if (suggestion.getOrder() != null) {
      addSuggestion(suggestion, getLabel(inFlowID));
    } else {
      Messages.TRADE_SUGGESTION_MANAGER_INVALID_DATA_NO_ORDER.error(this);
    }
  }

  private String getLabel(DataFlowID dataFlowId) {
    IDataFlowLabelProvider labelProvider = ModuleSupport.getDataFlowLabelProvider();
    if (labelProvider != null) {
      String label = labelProvider.getLabel(dataFlowId);
      if (label != null) {
        return label;
      }
    }
    return dataFlowId.getValue();
  }
}
 /**
  * @param realm
  * @param bindings
  */
 public ValidationStatusMap(Realm realm, WritableList bindings) {
   super(realm, new HashMap());
   this.bindings = bindings;
   bindings.addChangeListener(markDirtyChangeListener);
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.core.databinding.observable.list.ObservableList#dispose()
  */
 public void dispose() {
   bindings.removeChangeListener(markDirtyChangeListener);
   removeElementChangeListener();
   super.dispose();
 }
  @Override
  public IObservableList getChildList(final Object element) {
    final WritableList list = new WritableList();
    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_ADDONS,
            APPLICATION__ADDONS,
            element,
            Messages.ApplicationEditor_Addons) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_ROOT_CONTEXTS,
            BINDING_TABLE_CONTAINER__ROOT_CONTEXT,
            element,
            Messages.ApplicationEditor_RootContexts) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_BINDING_TABLE,
            BINDING_CONTAINER__BINDINGS,
            element,
            Messages.ApplicationEditor_BindingTables) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_HANDLER,
            HANDLER_CONTAINER__HANDLERS,
            element,
            Messages.ApplicationEditor_Handlers) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_COMMAND,
            APPLICATION__COMMANDS,
            element,
            Messages.ApplicationEditor_Commands) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_CATEGORIES,
            APPLICATION__CATEGORIES,
            element,
            Messages.ApplicationEditor_Categories) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_APPLICATION_WINDOWS,
            ELEMENT_CONTAINER__CHILDREN,
            element,
            Messages.ApplicationEditor_Windows) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_PART_DESCRIPTORS,
            PART_DESCRIPTOR_CONTAINER__DESCRIPTORS,
            element,
            Messages.ApplicationEditor_PartDescriptors) {

          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_MENU_CONTRIBUTIONS,
            MENU_CONTRIBUTIONS,
            element,
            Messages.ApplicationEditor_MenuContributions) {
          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_TOOLBAR_CONTRIBUTIONS,
            TOOLBAR_CONTRIBUTIONS,
            element,
            Messages.ApplicationEditor_ToolBarContributions) {
          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });

    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_TRIM_CONTRIBUTIONS,
            TRIM_CONTRIBUTIONS,
            element,
            Messages.ApplicationEditor_TrimContributions) {
          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });
    list.add(
        new VirtualEntry<Object>(
            ModelEditor.VIRTUAL_SNIPPETS,
            APPLICATION__SNIPPETS,
            element,
            Messages.ApplicationEditor_Snippets) {
          @Override
          protected boolean accepted(Object o) {
            return true;
          }
        });
    //
    // MApplication application = (MApplication) element;
    // if (application.getRootContext() != null) {
    // list.add(0, application.getRootContext());
    // }

    // BINDING_TABLE_CONTAINER__ROOT_CONTEXT.observe(element).addValueChangeListener(new
    // IValueChangeListener() {
    //
    // public void handleValueChange(ValueChangeEvent event) {
    // if (event.diff.getOldValue() != null) {
    // list.remove(event.diff.getOldValue());
    // if (getMaster().getValue() == element) {
    // createRemoveRootContext.setSelection(false);
    // }
    // }
    //
    // if (event.diff.getNewValue() != null) {
    // list.add(0, event.diff.getNewValue());
    // if (getMaster().getValue() == element) {
    // createRemoveRootContext.setSelection(true);
    // }
    // }
    // }
    // });

    return list;
  }