Pergunta

I have created one small GEF project which contains the GEF editor. Now I want to convert all the functionality to View except the GEF pallette. Is it possible to do? Because when I tried to do the editpolicies and all not working. I am able to draw a rectangle using the GEF Rectangle part and model. it is working fine. But now I want to add the resize,delete,undo functionality to my view. In GEF editor these functionalities are working fine. Are these functionality working only with Editor? Could anybody suggest how to do it?

Foi útil?

Solução

You can add some GEF features to your view.For that your view has to be implemented in the followig way.

// Use a standard Viewer for the Draw2d canvas
    private ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
    // Use standard RootEditPart as holder for all other edit parts
    // private RootEditPart rootEditPart = new ScalableFreeformRootEditPart();

    private ScalableRootEditPart rootEditPart = new ScalableRootEditPart();

// parts for model elements
private EditPartFactory editPartFactory = new MyEditPartFactory();

For example you can add GEF edit policies to your view.

public void createPartControl(Composite parent) {

        // Initialize the viewer, 'parent' is the
        // enclosing RCP windowframe
        viewer.createControl(parent);
        viewer.setRootEditPart(rootEditPart);
        viewer.setEditPartFactory(editPartFactory);

        viewer.setContents(ModelFactory.createRegionLayerModel());

                 viewer.setEditDomain(new DefaultEditDomain(new GraphicalEditor() {



                @Override
                public void doSave(IProgressMonitor monitor) {
                    // TODO Auto-generated method stub

                }

                @Override
                protected void initializeGraphicalViewer() {
                    GraphicalViewer viewer = getGraphicalViewer();

                }

                @Override
                protected void configureGraphicalViewer() {
                    super.configureGraphicalViewer();
                    super.configureGraphicalViewer();
                    GraphicalViewer viewer = getGraphicalViewer();
                }

            }));
}

Hope this helps you!!!

Outras dicas

What you want is not possible in the current GEF implementation. All graphical editors are eclipse editors so I cannot see how you can put them in a view. You could implement this but would require lot of wiring...

If I understand you correctly, you basically just want to get rid of the palette, while preserving full editing functionality?

This can be achieved easily enough. Let your editor class extend org.eclipse.gef.ui.parts.GraphicalEditor (API) rather than org.eclipse.gef.ui.parts.GraphicalEditorWithPalette or org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette, and you are rid of the palette:

This class serves as a quick starting point for clients who are new to GEF. It will create an Editor containing a single GraphicalViewer as its control.

However, note that the Javadoc comment says

IMPORTANT This class should only be used as a reference for creating your own EditorPart implementation. This class will not suit everyone's needs, and may change in the future. Clients may copy the implementation.

Ideally you should set up your own implementation of org.eclipse.ui.part.EditorPart, but I think as a starting point GraphicalEditor will probably do :).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top