Search in sources :

Example 1 with CobiGenEclipseRuntimeException

use of com.devonfw.cobigen.eclipse.common.exceptions.CobiGenEclipseRuntimeException in project cobigen by devonfw.

the class CobiGenWrapper method setInputs.

/**
 * Sets the given input objects for generation
 *
 * @param inputs input objects for generation
 */
private void setInputs(List<Object> inputs) {
    this.inputs = inputs;
    LOG.info("Set new generator inputs: {}", inputs);
    this.matchingTemplates = Lists.newLinkedList();
    LOG.debug("Calculating matching templates...");
    PlatformUIUtil.getWorkbench().getDisplay().syncExec(() -> {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
        AnalyzeInputJob job = new AnalyzeInputJob(this.cobiGen, inputs);
        try {
            dialog.run(true, false, job);
        } catch (InvocationTargetException e) {
            LOG.error("An internal error occured while invoking input analyzer job.", e);
            throw new CobiGenEclipseRuntimeException("An internal error occured while invoking input analyzer job", e);
        } catch (InterruptedException e) {
            LOG.warn("The working thread doing the input analyzer job has been interrupted.", e);
            throw new CobiGenEclipseRuntimeException("The working thread doing the input analyzer job has been interrupted", e);
        }
        // forward exception thrown in the processing thread if an exception occurred
        if (job.isExceptionOccurred()) {
            throw job.getOccurredException();
        }
        this.matchingTemplates = job.getResultMatchingTemplates();
        LOG.debug("Matching templates: {}", this.matchingTemplates);
        this.singleNonContainerInput = job.isResultSingleNonContainerInput();
        LOG.debug("SingleNonContainerInput: {}", this.singleNonContainerInput);
        LOG.debug("Finished analyzing generation input.");
    });
}
Also used : CobiGenEclipseRuntimeException(com.devonfw.cobigen.eclipse.common.exceptions.CobiGenEclipseRuntimeException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with CobiGenEclipseRuntimeException

use of com.devonfw.cobigen.eclipse.common.exceptions.CobiGenEclipseRuntimeException in project cobigen by devonfw.

the class SelectFileLabelProvider method checkStateChanged.

@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    synchronized (this.selectedIncrements) {
        // Increments selection has been changed
        if (event.getSource() instanceof CheckboxTreeViewer) {
            CheckboxTreeViewer incrementSelector = (CheckboxTreeViewer) event.getSource();
            CheckStateListener listener = new CheckStateListener(this.cobigenWrapper, null, this.batch);
            listener.performCheckLogic(event, incrementSelector);
            Set<Object> selectedElements = new HashSet<>(Arrays.asList(((CheckboxTreeViewer) event.getSource()).getCheckedElements()));
            this.selectedIncrements.clear();
            for (Object o : selectedElements) {
                if (o instanceof IncrementTo) {
                    this.selectedIncrements.add((IncrementTo) o);
                } else {
                    throw new CobiGenEclipseRuntimeException("Unexpected increment type '" + o.getClass().getCanonicalName() + "' !");
                }
            }
        }
    }
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) IncrementTo(com.devonfw.cobigen.api.to.IncrementTo) CobiGenEclipseRuntimeException(com.devonfw.cobigen.eclipse.common.exceptions.CobiGenEclipseRuntimeException) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateListener(com.devonfw.cobigen.eclipse.wizard.common.control.CheckStateListener) HashSet(java.util.HashSet)

Aggregations

CobiGenEclipseRuntimeException (com.devonfw.cobigen.eclipse.common.exceptions.CobiGenEclipseRuntimeException)2 IncrementTo (com.devonfw.cobigen.api.to.IncrementTo)1 CheckStateListener (com.devonfw.cobigen.eclipse.wizard.common.control.CheckStateListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1