@Override
  protected IPropertySource createPropertySource(Object object) {
    if (object instanceof CDORepository) {
      CDORepository repository = (CDORepository) object;
      CDOSession session = repository.getSession();

      return new DefaultPropertySource.Augmented<CDORepository, CDOSession>(
          repository, CDORepositoryProperties.INSTANCE, session) {
        @Override
        protected IPropertySource createAugmentingPropertySource(CDOSession session) {
          return new DefaultPropertySource<CDOSession>(session, SessionProperties.INSTANCE);
        }
      };
    }

    if (object instanceof CDOCheckout) {
      CDOCheckout checkout = (CDOCheckout) object;
      CDOView view = checkout.getView();

      return new DefaultPropertySource.Augmented<CDOCheckout, CDOView>(
          checkout, CDOCheckoutProperties.INSTANCE, view) {
        @Override
        protected IPropertySource createAugmentingPropertySource(CDOView view) {
          return new DefaultPropertySource<CDOView>(view, ViewProperties.INSTANCE);
        }
      };
    }

    return null;
  }
Exemplo n.º 2
0
  private void updateSelectedObject(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ssel = (IStructuredSelection) selection;
      if (ssel.size() == 1) {
        selectedObject = ssel.getFirstElement();
        if (selectedObject instanceof CDOCheckout) {
          CDOCheckout checkout = (CDOCheckout) selectedObject;
          selectedObject = checkout.getRootObject();
        }

        return;
      }
    }

    selectedObject = null;
  }
Exemplo n.º 3
0
    @Override
    protected CDOTransaction openTransaction(CDOObject AbstractNewAction) {
      if (checkout != null) {
        return checkout.openTransaction();
      }

      return null;
    }
Exemplo n.º 4
0
  @Override
  public void fillContextMenu(IMenuManager menu) {
    if (viewer == null) {
      return;
    }

    CDOCheckout checkout = CDOExplorerUtil.getCheckout(selectedObject);
    if (checkout == null || checkout.isReadOnly()) {
      return;
    }

    IMenuManager submenu = new MenuManager("&New", NEW_MENU_NAME);

    fillNewWizardActions(submenu);

    if (selectedObject instanceof CDOResource) {
      CDOResource resource = (CDOResource) selectedObject;
      if (!resource.isRoot()) {
        fillNewRootActions(submenu, checkout, resource);

        submenu.add(new Separator());
        submenu.add(new NewRootOtherAction(resource, checkout));
        submenu.add(new Separator());
      }
    } else if (selectedObject instanceof CDOResourceNode) {
      // Do nothing. CDOResourceFolder contributions have already been added by
      // newWizardActionGroup.
    } else if (selectedObject instanceof EObject) {
      fillNewChildActions(submenu, checkout, (EObject) selectedObject);
    }

    submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));

    // Append the submenu after the GROUP_NEW group.
    menu.insertAfter(ICommonMenuConstants.GROUP_NEW, submenu);
  }
Exemplo n.º 5
0
  private void fillNewChildActions(IMenuManager menu, CDOCheckout checkout, EObject object) {
    ResourceSet resourceSet = checkout.getView().getResourceSet();

    ComposedAdapterFactory adapterFactory = getAdapterFactory(checkout);

    EditingDomain editingDomain =
        new AdapterFactoryEditingDomain(adapterFactory, new BasicCommandStack(), resourceSet);
    IStructuredSelection selection = new StructuredSelection(object);
    CDOObject cdoObject = CDOUtil.getCDOObject(object);

    Collection<?> childDescriptors = editingDomain.getNewChildDescriptors(object, null);
    for (Object childDescriptor : childDescriptors) {
      CreateChildAction delegate = new CreateChildAction(editingDomain, selection, childDescriptor);
      String text = delegate.getText();
      String toolTipText = delegate.getToolTipText();
      ImageDescriptor imageDescriptor = delegate.getImageDescriptor();

      NewChildAction action =
          new NewChildAction(
              text, toolTipText, imageDescriptor, checkout, cdoObject, childDescriptor);
      menu.add(action);
    }
  }