Ejemplo n.º 1
0
 protected void setScopes(IDataModel dataModel) {
   if (dataModel != null) {
     setScopes(dataManager.getScopes(dataModel));
   }
 }
Ejemplo n.º 2
0
 private void initInputs() {
   dataModels.clear();
   scopes.clear();
   dataModels.addAll(dataManager.getAllDataModels());
 }
Ejemplo n.º 3
0
 protected void refresh() {
   setDataModels(dataManager.getAllDataModels());
   refreshDataModelSelection();
   setScopes(dataModel);
   setRequirements(scope != null ? scope.getRequirements() : null);
 }
Ejemplo n.º 4
0
  @Override
  public void createPartControl(Composite parent) {

    initInputs();

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    Label lblDataModel = new Label(composite, SWT.NONE);
    lblDataModel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDataModel.setText("Data Model :");

    cvDataModel = new ComboViewer(composite, SWT.NONE);
    cvDataModel.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cvDataModel.setContentProvider(ArrayContentProvider.getInstance());

    // TODO : use scope generated label provider
    cvDataModel.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            if (element instanceof IDataModel) {
              return ((IDataModel) element).getName();
            }
            return "";
          }
        });

    cvDataModel.setInput(dataManager.getAllDataModels());

    //		refreshBtn = new Button(composite, SWT.PUSH);
    //		refreshBtn.setImage(Activator.getImageDescriptor("icons/refresh.gif").createImage());
    //
    //		refreshBtn.setToolTipText("Refresh View");

    Label lblScope = new Label(composite, SWT.NONE);
    lblScope.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblScope.setText("Scope :");

    cvScope = new ComboViewer(composite, SWT.NONE);
    cvScope.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cvScope.setContentProvider(ArrayContentProvider.getInstance());

    // TODO : use scope generated label provider
    cvScope.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            if (element instanceof Scope) {
              return ((Scope) element).getName();
            }
            return "";
          }
        });

    cvScope.setInput(scopes);

    viewer = new TreeViewer(composite, SWT.BORDER);
    viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    viewer.setContentProvider(
        new ITreeContentProvider() {

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          @Override
          public void dispose() {}

          @Override
          public boolean hasChildren(Object element) {
            //				if (element instanceof AbstractElement) {
            //					 EList<EAttribute> eAllAttributes = ((AbstractElement)
            // element).eClass().getEAllAttributes();
            //					for (EAttribute eAttribute : eAllAttributes) {
            //						if	(((AbstractElement) element).eGet(eAttribute, true) != null) {
            //							return true;
            //						}
            //					}
            //				}
            return false;
          }

          @Override
          public Object getParent(Object element) {
            return null;
          }

          @Override
          public Object[] getElements(Object inputElement) {
            return ArrayContentProvider.getInstance().getElements(inputElement);
          }

          @Override
          public Object[] getChildren(Object parentElement) {
            //				Collection<Object> result = new ArrayList<Object>();
            //				if (parentElement instanceof AbstractElement) {
            //					EList<EAttribute> eAllAttributes = ((AbstractElement)
            // parentElement).eClass().getEAllAttributes();
            //					for (EAttribute eAttribute : eAllAttributes) {
            //						value = ((AbstractElement) parentElement).eGet(eAttribute, true);
            //					}
            //				}
            return null;
          }
        });
    viewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            return DataUtil.getLabel(element);
          }
        });
    viewer.setInput(requirements);

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;

    Transfer[] transfers;
    transfers = new Transfer[] {PluginTransfer.getInstance()};

    DragRequirementSourceAdapter listener = new DragRequirementSourceAdapter(viewer);
    ZigguratInject.inject(listener);
    viewer.addDragSupport(dndOperations, transfers, listener);
    getViewSite().setSelectionProvider(viewer);

    makeActions();
    contributeToActionBars();
    hookListeners();
  }