Search in sources :

Example 1 with RootFragment

use of org.whole.lang.commons.model.RootFragment in project whole by wholeplatform.

the class RootFragmentPart method createFigure.

protected IFigure createFigure() {
    // Figure f = new FreeformLayer() {
    IEntityFigure f = new EntityFigure() {

        {
            setOpaque(false);
        }

        @Override
        public void paint(Graphics graphics) {
            graphics.setAdvanced(true);
            graphics.setAntialias(SWT.ON);
            super.paint(graphics);
        }

        protected void paintFigure(Graphics graphics) {
            super.paintFigure(graphics);
            Rectangle r2 = ((IFigure) getChildren().get(0)).getBounds();
            translateToParent(r2 = r2.getCopy());
            Rectangle clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
            graphics.fillRectangle(clipArea);
            graphics.setBackgroundColor(FigureConstants.hostLanguageColor);
            graphics.fillRectangle(clipArea.intersect(r2));
            graphics.setLineWidth(1);
            graphics.setLineStyle(Graphics.LINE_SOLID);
            graphics.setXORMode(false);
            IEntity rootEntity = ((RootFragment) getModelEntity()).getRootEntity().wGetAdaptee(false);
            if (rootEntity.wGetParent() instanceof RootFragment) {
                clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
                int oldAlpha = graphics.getAlpha();
                graphics.setAlpha(60);
                graphics.setForegroundColor(ColorConstants.darkGray);
                graphics.setLineWidth(1);
                graphics.drawRectangle(r2.getTranslated(-1, -1).resize(1, 1));
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.setLineWidth(5);
                graphics.drawRoundRectangle(r2.getTranslated(-4, -4).resize(7, 7), 10, 10);
                graphics.setAlpha(oldAlpha);
            } else {
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.drawRectangle(r2.x - 1, r2.y - 1, r2.width + 1, r2.height + 1);
            }
        }

        public void validate() {
            super.validate();
            repaint();
        }
    };
    f.setLayoutManager(new StackLayout().withMargin(5).withMinorAlignment(Alignment.CENTER));
    f.setBackgroundColor(FigureUtilities.lighter(ColorConstants.gray));
    f.setOpaque(false);
    f.addLayoutListener(LayoutAnimator.getDefault());
    return f;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) StackLayout(org.whole.lang.ui.layout.StackLayout) RootFragment(org.whole.lang.commons.model.RootFragment) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with RootFragment

use of org.whole.lang.commons.model.RootFragment in project whole by wholeplatform.

the class E4GraphicalViewer method rebuildNotation.

public void rebuildNotation() {
    RootFragment rootFragment = (RootFragment) getContents().getModel();
    rebuildNotation(rootFragment);
}
Also used : RootFragment(org.whole.lang.commons.model.RootFragment)

Example 3 with RootFragment

use of org.whole.lang.commons.model.RootFragment in project whole by wholeplatform.

the class E4TreeViewer method rebuildNotation.

public void rebuildNotation() {
    RootFragment rootFragment = (RootFragment) getContents().getModel();
    // FIXME should be rebuildNotation(rootFragment)
    rebuildNotation(rootFragment.getRootEntity().wGetAdaptee(true));
}
Also used : RootFragment(org.whole.lang.commons.model.RootFragment)

Example 4 with RootFragment

use of org.whole.lang.commons.model.RootFragment in project whole by wholeplatform.

the class AbstractE4Part method save.

@Persist
public void save() {
    if (modelInput != null) {
        workspace.removeResourceChangeListener(resourceListener);
        IPersistenceProvider pp = modelInput.getPersistenceProvider();
        try {
            RootFragment rootFragment = (RootFragment) viewer.getContents().getModel();
            modelInput.getPersistenceKit().writeModel(rootFragment.wGetRoot(), pp);
            viewer.getCommandStack().markSaveLocation();
            part.setDirty(false);
        } catch (Exception e) {
        } finally {
            workspace.addResourceChangeListener(resourceListener);
        }
    }
}
Also used : IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) RootFragment(org.whole.lang.commons.model.RootFragment) Persist(org.eclipse.e4.ui.di.Persist)

Example 5 with RootFragment

use of org.whole.lang.commons.model.RootFragment in project whole by wholeplatform.

the class E4FindReplaceDialog method doReplace.

protected void doReplace(boolean updateSelection) {
    if (!hasFoundEntity())
        return;
    final RootFragment replacementWrapper = CommonsEntityFactory.instance.createRootFragment(EntityUtils.clone(replaceViewer.getEntityContents()).wGetAdapter(CommonsEntityDescriptorEnum.Any));
    Matcher.substitute(replacementWrapper.getRootEntity(), bindings, false);
    ModelTransactionCommand command = new ModelTransactionCommand();
    try {
        command.setModel(getFoundEntity());
        command.begin();
        iterator.set(EntityUtils.remove(replacementWrapper.getRootEntity()));
        command.commit();
    } catch (Exception e) {
        command.rollbackIfNeeded();
    } finally {
        clearFoundEntity();
    }
    IEntityPartViewer viewer = (IEntityPartViewer) selection.wGetValue("viewer");
    viewer.getCommandStack().execute(command);
    if (updateSelection) {
        Control control = viewer.getControl();
        control.getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                boolean state = enableSelectionTracking(false);
                selectAndReveal(replacementWrapper);
                enableSelectionTracking(state);
            }
        });
    }
}
Also used : ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) Control(org.eclipse.swt.widgets.Control) RootFragment(org.whole.lang.commons.model.RootFragment) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Aggregations

RootFragment (org.whole.lang.commons.model.RootFragment)6 Graphics (org.eclipse.draw2d.Graphics)1 IFigure (org.eclipse.draw2d.IFigure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 Persist (org.eclipse.e4.ui.di.Persist)1 EditPart (org.eclipse.gef.EditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 Control (org.eclipse.swt.widgets.Control)1 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)1 IEntity (org.whole.lang.model.IEntity)1 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)1 IGEFEditorKit (org.whole.lang.ui.editor.IGEFEditorKit)1 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)1 StackLayout (org.whole.lang.ui.layout.StackLayout)1 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)1