Пример #1
0
 protected final DataSourceHandle getSelectedDataSource() {
   if (((IStructuredSelection) dataSourceFilteredTree.getViewer().getSelection()).getFirstElement()
       instanceof DataSourceHandle)
     return (DataSourceHandle)
         ((IStructuredSelection) dataSourceFilteredTree.getViewer().getSelection())
             .getFirstElement();
   else return null;
 }
  private void createTaskTree(Composite parent) {
    PatternFilter filter = new PatternFilter();
    FilteredTree filteredTree =
        new FilteredTree(parent, SWT.CHECK | SWT.BORDER, filter, true) {
          @Override
          protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
            return new ContainerCheckedTreeViewer(parent, style);
          }
        };
    taskSelectionTreeViewer = (CheckboxTreeViewer) filteredTree.getViewer();
    filteredTree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Add multi column support
    Tree tree = taskSelectionTreeViewer.getTree();
    tree.setHeaderVisible(true);
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("Project/Task");
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Description");
    column1.pack();
    column2.pack();

    taskSelectionTreeViewer.setLabelProvider(new GradleTaskTreeLabelProvider());
    taskSelectionTreeViewer.setContentProvider(
        new GradleTaskTreeContentProvider(taskSelectionTreeViewer, true));
    taskSelectionTreeViewer.setCheckStateProvider(tasksChecked);
    taskSelectionTreeViewer.addCheckStateListener(tasksChecked);

    if (project != null) {
      setTreeInput(project);
    }
  }
Пример #3
0
  /** This is a callback that will allow us to create the viewer and initialize it. */
  @Override
  @SuppressWarnings("unused")
  public void createPartControl(Composite parent) {

    parent.setLayout(new GridLayout());
    DatabaseViewerToolBar databaseViewerToolBar = new DatabaseViewerToolBar();
    databaseViewerToolBar.addSelectionChangedListener(this);
    databaseViewerToolBar.createToolBar(parent, getSite().getShell());

    PatternFilter filter = new PatternFilter();
    FilteredTree tree =
        new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
    viewer = tree.getViewer();
    DrillDownAdapter drillDownAdapter = new DrillDownAdapter(viewer);
    viewer.setContentProvider(initContentProvider());
    viewer.setLabelProvider(new DatabaseViewLabelProvider(this));
    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());

    // Create the help context id for the viewer's control
    // PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
    // "org.eclipse.dirigible.ide.db.viewer.views.DatabaseViewer");

    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
  }
Пример #4
0
  private void createSimpleResourcesArea(Composite compContent) {
    // Create a group to show all the discovered resources.
    // Adding the group to the folder.
    Group resourceGroup = new Group(compContent, SWT.NONE);

    Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
    resourceGroup.setBackground(color);

    resourceGroup.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    resourceGroup.setLayoutData(gd);

    PatternFilter filter = new PatternFilter();
    FilteredTree filteredTree =
        new FilteredTree(resourceGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true);
    singleResTreeViewer = filteredTree.getViewer();
    singleResTreeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    singleResTreeViewer.setContentProvider(new SingleResourceContentProvider());
    singleResTreeViewer.setLabelProvider(new TreeLabelProvider());
    singleResTreeViewer.setInput(new Object());

    singleResTreeViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent e) {
            IStructuredSelection selection = (IStructuredSelection) e.getSelection();
            if (null == selection) {
              return;
            }

            Resource res = null;
            int size = selection.size();
            if (size == 1) {
              res = (Resource) selection.getFirstElement();
            }
            resourceManager.resourceSelectionChanged(res);
          }
        });

    addMenuToSimpleResources();
  }
Пример #5
0
  @Override
  public void createPartControl(Composite parent) {
    // Just a little bit layout
    // parent.setLayout(new GridLayout(1, false));
    PatternFilter patternFilter = new PatternFilter();
    final FilteredTree filter =
        new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true);
    viewer = filter.getViewer();

    // viewer = new TreeViewer(parent , SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
    drillDownAdapter = new DrillDownAdapter(viewer);

    getSite().setSelectionProvider(viewer);

    //		OfficeTaxonomiesContentProvider offProvider = new OfficeTaxonomiesContentProvider(
    // getViewSite(), true, true, false);
    //		offProvider.AddOfficesFromManager( Activator.getDefault().getOfficeManager() );
    //		viewer.setContentProvider( offProvider );

    initializeOfferedServicesDomain();

    FontData[] boldFontData =
        getModifiedFontData(viewer.getTree().getFont().getFontData(), SWT.BOLD);
    Font boldFont = new Font(Display.getCurrent(), boldFontData);
    viewer.setLabelProvider(new OfficeTaxonomiesLabelProvider(boldFont));

    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());

    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(viewer.getControl(), "org.panlab.software.fstoolkit.viewer");
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();

    // viewer.expandToLevel(2);
  }
Пример #6
0
 private void setPageStatus() {
   if (dataSourceFilteredTree == null
       || dataSourceFilteredTree.getViewer().getTree().getSelectionCount() <= 0)
     setPageComplete(false);
 }
Пример #7
0
  private void setDataSourceTreeViewer() {

    dataSourceFilteredTree
        .getViewer()
        .setContentProvider(
            new ITreeContentProvider() {

              DataSourceType[] types = null;

              public void dispose() {}

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

              public Object[] getElements(Object inputElement) {
                types = new DataSourceType[((Collection) inputElement).size()];
                Iterator iter = ((Collection) inputElement).iterator();
                int i = 0;
                while (iter.hasNext()) {
                  types[i] = (DataSourceType) iter.next();
                  i++;
                }
                return types;
              }

              public Object[] getChildren(Object parentElement) {
                if (parentElement instanceof DataSourceType) {
                  return ((DataSourceType) parentElement).getDataSourceList().toArray();
                } else {
                  return new Object[0];
                }
              }

              public Object getParent(Object element) {
                if (types != null) {
                  for (int i = 0; i < types.length; i++) {
                    if (types[i].getDataSourceList().contains(element)) return types[i];
                  }
                }
                return null;
              }

              public boolean hasChildren(Object element) {
                if (element instanceof DataSourceType) {
                  return true;
                } else if (element instanceof DataSourceHandle) {
                  return false;
                }
                return false;
              }
            });

    dataSourceFilteredTree
        .getViewer()
        .setLabelProvider(
            new ILabelProvider() {

              public Image getImage(Object element) {
                return null;
              }

              public String getText(Object element) {
                if (element instanceof DataSourceType) {
                  return ((DataSourceType) element).getDataSourceDisplayName();
                } else if (element instanceof DataSourceHandle) {
                  return ((DataSourceHandle) element).getName();
                }
                return element.toString();
              }

              public void addListener(ILabelProviderListener listener) {}

              public void dispose() {}

              public boolean isLabelProperty(Object element, String property) {
                return false;
              }

              public void removeListener(ILabelProviderListener listener) {}
            });

    dataSourceFilteredTree
        .getViewer()
        .addSelectionChangedListener(
            new ISelectionChangedListener() {

              public void selectionChanged(SelectionChangedEvent event) {
                setPageStatus();
              }
            });

    dataSourceFilteredTree
        .getViewer()
        .setComparator(
            new ViewerComparator(
                new Comparator() {

                  public int compare(Object o1, Object o2) {
                    return o1.toString().compareTo(o2.toString());
                  }
                }));

    Map sourceMap = getDataSourceMap();
    dataSourceFilteredTree.getViewer().setInput(sourceMap.values());
    dataSourceFilteredTree.getViewer().expandAll();
    if (dataSourceFilteredTree.getViewer().getTree().getItems().length > 0) {
      dataSourceFilteredTree
          .getViewer()
          .getTree()
          .select(dataSourceFilteredTree.getViewer().getTree().getItem(0).getItem(0));
      doDataSourceSelectionChanged(
          dataSourceFilteredTree.getViewer().getTree().getItem(0).getData());
      dataSetTypeChooser.getCombo().setEnabled(true);
    }
    setPageComplete(!hasWizard() && (getMessageType() != ERROR));
  }
Пример #8
0
  /**
   * Creates the top level control for this dialog page under the given parent composite.
   *
   * <p>Implementors are responsible for ensuring that the created control can be accessed via
   * <code>getControl</code>
   *
   * @param parent the parent composite
   */
  public void createControl(Composite parent) {
    helper = new DataSetBasePageHelper();

    // initialize the dialog layout
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);

    final Group group = new Group(composite, SWT.NONE);
    group.setLayout(new GridLayout());
    group.setText(Messages.getString("DataSetBasePage.Group.DataSourceSelection")); // $NON-NLS-1$
    group.setLayoutData(
        new GridData(SWT.FILL, SWT.FILL, true, true, 1, 8)); // GridData.FILL_BOTH));

    wizardFilter = new WizardFilter();
    dataSourceFilteredTree =
        new FilteredTree(
            group,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL,
            this.wizardFilter,
            true);
    GridData treeData = new GridData(GridData.FILL_BOTH);
    treeData.grabExcessHorizontalSpace = true;
    treeData.grabExcessVerticalSpace = true;
    treeData.heightHint = 300;
    treeData.widthHint = 600;
    dataSourceFilteredTree.setLayoutData(treeData);
    SelectionListener listener =
        new SelectionListener() {
          TreeItem parent = null;

          public void widgetDefaultSelected(SelectionEvent arg0) {}

          public void widgetSelected(SelectionEvent event) {
            if (event.item.getData() instanceof DataSourceHandle) {
              dataSetTypeChooser.getCombo().setEnabled(true);
              if (parent == null || parent != ((TreeItem) event.item).getParentItem()) {
                parent = ((TreeItem) event.item).getParentItem();
                doDataSourceSelectionChanged(parent.getData());
              }
              setPageComplete(!hasWizard() && (getMessageType() != ERROR));
            } else {
              dataSetTypeChooser.getCombo().clearSelection();
              dataSetTypeChooser.getCombo().setEnabled(false);
              setPageComplete(false);
            }
            dataSourceFilteredTree.getViewer().getTree().setFocus();
          }
        };
    dataSourceFilteredTree.getViewer().getTree().addSelectionListener(listener);
    createDataSetTypeViewer(composite);

    setDataSourceTreeViewer();
    setPageStatus();

    // initialize name editor
    new Label(composite, SWT.RIGHT)
        .setText(Messages.getString("dataset.wizard.label.datasetName")); // $NON-NLS-1$
    nameEditor = new Text(composite, SWT.BORDER);
    String name = ReportPlugin.getDefault().getCustomName(ReportDesignConstants.DATA_SET_ELEMENT);
    if (name != null) {
      nameEditor.setText(Utility.getUniqueDataSetName(name));
    } else // can't get defaut name
    {
      nameEditor.setText(
          Utility.getUniqueDataSetName(
              Messages.getString("dataset.new.defaultName"))); // $NON-NLS-1$		
    }

    nameEditor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    nameEditor.setToolTipText(Messages.getString("DataSetBasePage.tooltip")); // $NON-NLS-1$
    nameEditor.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            if (StringUtil.isBlank(nameEditor.getText().trim())) {
              setMessage(EMPTY_NAME, ERROR);
            } else if (isDuplicateName()) { // name is duplicated
              setMessage(DUPLICATE_NAME, ERROR);
            } else if (containInvalidCharactor(
                nameEditor.getText())) { // name contains invalid ".", "/", "\", "!", ";", ","
              // character
              String msg =
                  Messages.getFormattedString(
                      "error.invalidName", //$NON-NLS-1$
                      new Object[] {nameEditor.getText()});
              setMessage(msg, ERROR);
            } else { // everything is OK
              setMessage(CREATE_PROMPT);
            }

            setPageComplete(
                !hasWizard() && (getMessageType() != ERROR) && getSelectedDataSource() != null);

            nameEditor.setFocus();
          }
        });
    setControl(composite);

    Utility.setSystemHelp(getControl(), IHelpConstants.CONEXT_ID_DATASET_NEW);
  }
  /** @see CustomReportDetailsPage#createControls(Composite) */
  @Override
  public Control createControls(Composite parent) {
    // filtered tree sets itself GridData, so set layout to gridlayout
    parent.setLayout(GridLayoutFactory.fillDefaults().create());

    // create pattern filter for FilteredTree
    PatternFilter filter = new TreePathPatternFilter();
    filter.setIncludeLeadingWildcard(true);

    // create FilteredTree
    FilteredTree filteredTree =
        new TreePathFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);

    treeViewer = filteredTree.getViewer();

    // set content provider
    contentProvider = new InstanceValidationReportDetailsContentProvider();
    treeViewer.setContentProvider(contentProvider);

    // set label provider
    treeViewer.setLabelProvider(new InstanceValidationReportDetailsLabelProvider(contentProvider));

    // set comparator
    treeViewer.setComparator(
        new ViewerComparator() {

          /** @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object) */
          @Override
          public int category(Object element) {
            if (element instanceof QName || element instanceof Definition<?>) return 0; // Path
            else if (element instanceof String) return 1; // Category
            else return 2; // InstanceValidationMessage
          }
        });

    // add menu on right-click
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(treeViewer.getTree());

    menuMgr.addMenuListener(
        new IMenuListener() {

          @Override
          public void menuAboutToShow(IMenuManager manager) {
            if (getValidSelection() == null) return;

            // selection is valid, offer link to transformed data view
            manager.add(new ShowExampleAction());
          }
        });

    // remove previous menus
    menuMgr.setRemoveAllWhenShown(true);

    // add menu to tree
    treeViewer.getTree().setMenu(menu);

    treeViewer.addDoubleClickListener(
        new IDoubleClickListener() {

          @Override
          public void doubleClick(DoubleClickEvent event) {
            showSelectionInDataView();
          }
        });

    Image noReportBaseImage =
        InstanceValidationUIPlugin.getDefault()
            .getImageRegistry()
            .get(InstanceValidationUIPlugin.IMG_INSTANCE_VALIDATION);
    reportImage =
        new DecorationOverlayIcon(
                noReportBaseImage,
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING),
                IDecoration.BOTTOM_LEFT)
            .createImage();

    return filteredTree;
  }