Search in sources :

Example 1 with SelectFileLabelProvider

use of com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileLabelProvider in project cobigen by devonfw.

the class CheckStateListener method checkStateChanged.

@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    MDC.put(InfrastructureConstants.CORRELATION_ID, UUID.randomUUID().toString());
    LOG.info("Increment selection changed. Calculating generation preview file tree...");
    try {
        CheckboxTreeViewer resourcesTree = this.page.getResourcesTree();
        CheckboxTreeViewer incrementSelector = this.page.getPackageSelector();
        if (event.getSource().equals(resourcesTree)) {
            resourcesTree.setSubtreeChecked(event.getElement(), event.getChecked());
            ((SelectFileLabelProvider) resourcesTree.getLabelProvider()).setSelectedResources(resourcesTree.getCheckedElements());
            refreshNodes(event);
        } else if (event.getSource().equals(incrementSelector)) {
            performCheckLogic(event, incrementSelector);
            Set<Object> checkedElements = new HashSet<>(Arrays.asList(incrementSelector.getCheckedElements()));
            performCheckLogicForALLIncrement(incrementSelector, checkedElements);
            Map<String, Set<TemplateTo>> paths = this.cobigenWrapper.getTemplateDestinationPaths(this.selectedIncrements);
            Set<String> workspaceExternalPaths = Sets.newHashSet();
            for (String path : paths.keySet()) {
                if (this.cobigenWrapper.isWorkspaceExternalPath(path)) {
                    workspaceExternalPaths.add(path);
                }
            }
            List<OffWorkspaceResourceTreeNode> offScopeResourceTree = buildOffScopeResourceTree(workspaceExternalPaths);
            ((SelectFileContentProvider) resourcesTree.getContentProvider()).filter(paths.keySet(), offScopeResourceTree);
            this.page.setDisplayedfilePathToTemplateMapping(paths);
            resourcesTree.setCheckedElements(new Object[0]);
            resourcesTree.refresh();
            resourcesTree.expandAll();
            if (!this.batch) {
                selectNewResources();
                selectMergeableResources();
                selectOverridingResources();
            } else {
                selectAllResources(paths.keySet());
            }
        }
        checkPageComplete();
    } catch (Throwable e) {
        ExceptionHandler.handle(e, null);
    }
    LOG.info("Calculating of changed preview file tree finished.");
    MDC.remove(InfrastructureConstants.CORRELATION_ID);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) HashSet(java.util.HashSet) Set(java.util.Set) SelectFileLabelProvider(com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileLabelProvider) LinkedList(java.util.LinkedList) List(java.util.List) Map(java.util.Map) TemplateTo(com.devonfw.cobigen.api.to.TemplateTo)

Example 2 with SelectFileLabelProvider

use of com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileLabelProvider in project cobigen by devonfw.

the class SelectFilesPage method buildResourceTreeViewer.

/**
 * Builds the {@link TreeViewer} providing the tree of resources to be generated
 *
 * @param customizable states whether the checkboxes of the tree should be displayed or not
 */
public void buildResourceTreeViewer(boolean customizable) {
    IContentProvider cp;
    IBaseLabelProvider lp;
    Object[] checkedElements;
    if (this.resourcesTree != null) {
        cp = this.resourcesTree.getContentProvider();
        lp = this.resourcesTree.getLabelProvider();
        checkedElements = this.resourcesTree.getCheckedElements();
    } else {
        cp = new SelectFileContentProvider();
        lp = new SelectFileLabelProvider(this.cobigenWrapper, this.batch);
        this.incrementSelector.addCheckStateListener((SelectFileLabelProvider) lp);
        checkedElements = new Object[0];
    }
    disposeContainerRightChildren();
    Label label = new Label(this.containerRight, SWT.NONE);
    label.setText("Resources to be generated (selected):");
    if (customizable) {
        this.resourcesTree = new CustomizedCheckboxTreeViewer(this.containerRight);
    } else {
        this.resourcesTree = new SimulatedCheckboxTreeViewer(this.containerRight);
    }
    this.resourcesTree.setContentProvider(cp);
    this.resourcesTree.setLabelProvider(lp);
    this.resourcesTree.setInput(ResourcesPlugin.getWorkspace().getRoot().getProjects());
    this.resourcesTree.expandToLevel(AbstractTreeViewer.ALL_LEVELS);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    this.resourcesTree.getTree().setLayoutData(gd);
    CheckStateListener listener = new CheckStateListener(this.cobigenWrapper, this, this.batch);
    this.resourcesTree.addCheckStateListener(listener);
    this.resourcesTree.setCheckedElements(checkedElements);
    this.containerRight.layout();
}
Also used : SelectFileContentProvider(com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileContentProvider) IContentProvider(org.eclipse.jface.viewers.IContentProvider) SimulatedCheckboxTreeViewer(com.devonfw.cobigen.eclipse.wizard.common.widget.SimulatedCheckboxTreeViewer) CheckStateListener(com.devonfw.cobigen.eclipse.wizard.common.control.CheckStateListener) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectFileLabelProvider(com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileLabelProvider) CustomizedCheckboxTreeViewer(com.devonfw.cobigen.eclipse.wizard.common.widget.CustomizedCheckboxTreeViewer)

Aggregations

SelectFileLabelProvider (com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileLabelProvider)2 TemplateTo (com.devonfw.cobigen.api.to.TemplateTo)1 CheckStateListener (com.devonfw.cobigen.eclipse.wizard.common.control.CheckStateListener)1 SelectFileContentProvider (com.devonfw.cobigen.eclipse.wizard.common.model.SelectFileContentProvider)1 CustomizedCheckboxTreeViewer (com.devonfw.cobigen.eclipse.wizard.common.widget.CustomizedCheckboxTreeViewer)1 SimulatedCheckboxTreeViewer (com.devonfw.cobigen.eclipse.wizard.common.widget.SimulatedCheckboxTreeViewer)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 IBaseLabelProvider (org.eclipse.jface.viewers.IBaseLabelProvider)1 IContentProvider (org.eclipse.jface.viewers.IContentProvider)1 GridData (org.eclipse.swt.layout.GridData)1 Label (org.eclipse.swt.widgets.Label)1