コード例 #1
0
  PasteBeanLinkEnabledChecker(
      final ILinkCreatorService linkCreatorService,
      final IProvider<Collection<ILinkCreation>> linkProvider,
      final IBeanSelectionProvider<SOURCE_BEAN_TYPE> source,
      final IBeanListModel<LINKABLE_BEAN_TYPE> linkedModel,
      final Object expectedBeanTypeId,
      final Class<?> expectedBeanType,
      final boolean serviceBasedEnabledChecking) {

    Assert.paramNotNull(linkCreatorService, "linkCreatorService");
    Assert.paramNotNull(linkProvider, "linkProvider");
    Assert.paramNotNull(source, "source");
    Assert.paramNotNull(expectedBeanTypeId, "expectedBeanTypeId");
    Assert.paramNotNull(expectedBeanType, "expectedBeanType");

    this.linkCreatorService = linkCreatorService;
    this.linkProvider = linkProvider;
    this.source = source;
    this.linkedModel = linkedModel;
    this.serviceBasedEnabledChecking = serviceBasedEnabledChecking;
    this.disposed = false;
    this.conditionsChanged = true;

    this.sourceListener =
        new IBeanSelectionListener<SOURCE_BEAN_TYPE>() {
          @Override
          public void selectionChanged(final IBeanSelectionEvent<SOURCE_BEAN_TYPE> selectionEvent) {
            onConditionsChanged();
          }
        };
    source.addBeanSelectionListener(sourceListener);

    this.linkedModelListener =
        new BeanListModelListenerAdapter<LINKABLE_BEAN_TYPE>() {
          @Override
          public void beansChanged() {
            onConditionsChanged();
          }
        };
    if (linkedModel != null) {
      linkedModel.addBeanListModelListener(linkedModelListener);
    }

    this.clipboardEnabledChecker =
        new ClipboardSelectionEnabledChecker(expectedBeanTypeId, expectedBeanType);
    clipboardEnabledChecker.addChangeListener(
        new IChangeListener() {
          @Override
          public void changed() {
            onConditionsChanged();
          }
        });
  }
コード例 #2
0
 @Override
 public void dispose() {
   disposed = true;
   if (executionTask != null && !executionTask.isCanceled()) {
     executionTask.cancel();
   }
   clipboardEnabledChecker.dispose();
   source.removeBeanSelectionListener(sourceListener);
   if (linkedModel != null) {
     linkedModel.removeBeanListModelListener(linkedModelListener);
   }
   super.dispose();
 }