Search in sources :

Example 16 with GroovyService

use of eu.esdihumboldt.util.groovy.sandbox.GroovyService in project hale by halestudio.

the class RestrictionToggleState method dispose.

@Override
public void dispose() {
    GroovyService gs = HaleUI.getServiceProvider().getService(GroovyService.class);
    gs.removeListener(groovyServiceListener);
}
Also used : GroovyService(eu.esdihumboldt.util.groovy.sandbox.GroovyService)

Example 17 with GroovyService

use of eu.esdihumboldt.util.groovy.sandbox.GroovyService in project hale by halestudio.

the class ToggleRestrictionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    GroovyService gs = HaleUI.getServiceProvider().getService(GroovyService.class);
    boolean restrictionActive = gs.isRestrictionActive();
    String warning;
    if (restrictionActive) {
        warning = "Are your sure, that you want to lift restrictions for all Groovy scripts of the current project?";
        warning += "\n\nWARNING: The Groovy scripts can then do \"anything\", so be sure to trust your source!";
    } else {
        warning = "Are you sure, that you want to restrict all Groovy scripts again?\nScripts relying on additional rights will stop working and overall script performance may go down.";
    }
    boolean confirmation = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Groovy script restriction", warning);
    if (confirmation) {
        gs.setRestrictionActive(!gs.isRestrictionActive());
    } else {
        // make sure toggle button reverts
        ICommandService cs = PlatformUI.getWorkbench().getService(ICommandService.class);
        cs.refreshElements(event.getCommand().getId(), null);
    }
    return null;
}
Also used : GroovyService(eu.esdihumboldt.util.groovy.sandbox.GroovyService) ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

GroovyService (eu.esdihumboldt.util.groovy.sandbox.GroovyService)17 Binding (groovy.lang.Binding)11 Script (groovy.lang.Script)10 InstanceBuilder (eu.esdihumboldt.hale.common.instance.groovy.InstanceBuilder)9 NoResultException (eu.esdihumboldt.hale.common.align.transformation.function.impl.NoResultException)6 TransformationException (eu.esdihumboldt.hale.common.align.transformation.function.TransformationException)5 Cell (eu.esdihumboldt.hale.common.align.model.Cell)4 ExecutionContext (eu.esdihumboldt.hale.common.align.transformation.function.ExecutionContext)4 CellLog (eu.esdihumboldt.hale.common.align.transformation.report.impl.CellLog)4 DefaultTransformationReporter (eu.esdihumboldt.hale.common.align.transformation.report.impl.DefaultTransformationReporter)4 Type (eu.esdihumboldt.hale.common.align.model.Type)3 DefaultGroovyService (eu.esdihumboldt.util.groovy.sandbox.DefaultGroovyService)3 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)2 PropertyValue (eu.esdihumboldt.hale.common.align.transformation.function.PropertyValue)2 FamilyInstanceImpl (eu.esdihumboldt.hale.common.align.transformation.function.impl.FamilyInstanceImpl)2 FamilyInstance (eu.esdihumboldt.hale.common.instance.model.FamilyInstance)2 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)2 DefaultInstance (eu.esdihumboldt.hale.common.instance.model.impl.DefaultInstance)2 MissingPropertyException (groovy.lang.MissingPropertyException)2 ScriptException (javax.script.ScriptException)2