Search in sources :

Example 61 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class ArtifactsGeneratorTest method testGenerateArtifacts.

@Test
public void testGenerateArtifacts() {
    IBindingManager env = BindingManagerFactory.instance.createArguments();
    IEntity artifact = getMetadataPattern();
    IBindingScope args = BindingManagerFactory.instance.createSimpleScope();
    args.wDefValue("packageName", "artifact.test");
    Matcher.substitute(artifact, args, false);
    args.wClear();
    args.wDefValue("templateManagerName", "MyTM");
    Matcher.substitute(artifact, args, false);
    ArtifactsGeneratorOperation.generate(artifact, env);
// String pn = env.wStringValue("packageName");
// String fn = env.wStringValue("fileName");
// String l = env.wStringValue("location");
// String n = env.wStringValue("name");
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingScope(org.whole.lang.bindings.IBindingScope) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 62 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class AbstractLinkableSelectionListener method isRelevant.

protected boolean isRelevant(Object selection) {
    if (!(selection instanceof IBindingManager))
        return false;
    IBindingManager actualSelection = (IBindingManager) selection;
    IEntityPartViewer selectedViewer = (IEntityPartViewer) actualSelection.wGetValue("viewer");
    if (viewer == selectedViewer)
        return false;
    lastSelection = actualSelection.clone();
    return linkType.isLinkedToActivePart() || (linkType.isLinkedToFixedPart() && selectedViewer == linkedViewer);
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 63 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class ModelInputFunction method compute.

@Override
public Object compute(IEclipseContext context) {
    final IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    bm.wDefValue("eclipse#eclipseContext", context);
    final IEditorPart editorPart = context.get(IEditorPart.class);
    final IEditorInput input = context.get(IEditorInput.class);
    if (input instanceof IFileEditorInput) {
        IFile file = ((IFileEditorInput) input).getFile();
        IFilePersistenceProvider pp = new IFilePersistenceProvider(file, bm);
        ModelInput modelInput = new ModelInput(context, pp, calculateBasePersistenceKitId(file));
        if (editorPart != null) {
            String editorId = editorPart.getSite().getId();
            String overridePersistenceKitId = ReflectionFactory.getPersistenceKitFromEditorId(editorId).getId();
            modelInput.setOverridePersistenceKitId(overridePersistenceKitId);
        }
        return modelInput;
    } else if (input instanceof IURIEditorInput) {
        File file = new File(((IURIEditorInput) input).getURI());
        FilePersistenceProvider pp = new FilePersistenceProvider(file, bm);
        ModelInput modelInput = new ModelInput(context, pp, ReflectionFactory.getDefaultPersistenceKit().getId());
        if (editorPart != null) {
            String editorId = editorPart.getSite().getId();
            String overridePersistenceKitId = ReflectionFactory.getPersistenceKitFromEditorId(editorId).getId();
            modelInput.setOverridePersistenceKitId(overridePersistenceKitId);
        }
        return modelInput;
    } else
        return null;
}
Also used : ModelInput(org.whole.lang.e4.ui.input.ModelInput) IURIEditorInput(org.eclipse.ui.IURIEditorInput) IFile(org.eclipse.core.resources.IFile) FilePersistenceProvider(org.whole.lang.codebase.FilePersistenceProvider) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IBindingManager(org.whole.lang.bindings.IBindingManager) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IEditorPart(org.eclipse.ui.IEditorPart) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IEditorInput(org.eclipse.ui.IEditorInput) IURIEditorInput(org.eclipse.ui.IURIEditorInput)

Example 64 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class AbstractSelectionConstrainedVisibleWhen method evaluate.

@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
    ESelectionService selectionService = (ESelectionService) context.getVariable(ESelectionService.class.getName());
    Object selection = selectionService.getSelection();
    if (selection instanceof IBindingManager) {
        if (isVisible((IBindingManager) selection))
            return EvaluationResult.TRUE;
    }
    return EvaluationResult.FALSE;
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService)

Example 65 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class ActivateToolAction method update.

@Override
public void update() {
    setEnabled(false);
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    if (selectionService.getSelection() instanceof IBindingManager) {
        IBindingManager bm = (IBindingManager) selectionService.getSelection();
        if (bm.wIsSet("viewer"))
            setEnabled(!tool.isActive((IEntityPartViewer) bm.wGetValue("viewer")));
    }
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)223 IEntity (org.whole.lang.model.IEntity)141 Test (org.junit.Test)91 PathExpression (org.whole.lang.queries.model.PathExpression)49 ITemplateManager (org.whole.lang.templates.ITemplateManager)40 Grammar (org.whole.lang.grammars.model.Grammar)28 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)27 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)17 Model (org.whole.lang.models.model.Model)15 Production (org.whole.lang.grammars.model.Production)14 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)14 File (java.io.File)12 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)12 XmlModel (org.whole.lang.models.codebase.XmlModel)11 SimpleEntity (org.whole.lang.models.model.SimpleEntity)10 VisitException (org.whole.lang.visitors.VisitException)9 IBindingScope (org.whole.lang.bindings.IBindingScope)6 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)5