org.eclipse.gef.EditPartFactory Java Examples

The following examples show how to use org.eclipse.gef.EditPartFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridEditorTools.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a basic GEF viewer in the specified container and with the
 * specified EditPartFactory.
 * 
 * @param container
 *            The Composite that will contain the viewer.
 * @param factory
 *            The factory used to create the viewer's EditParts.
 */
public static GraphicalViewer createViewer(Composite container,
		EditPartFactory factory) {
	// Create the GraphicalViewer. This is fairly standard procedure for
	// GEF.

	// Use this to test re-sizing of window (this viewer does not create
	// scroll bars).
	GraphicalViewer viewer = new GraphicalViewerImpl();
	viewer.setRootEditPart(new SimpleRootEditPart());
	viewer.createControl(container);

	// Pass the custom EditPartFactory and the Grid model to the
	// GraphicalViewer.
	viewer.setEditPartFactory(factory);

	// Set the GraphicalViewer's EditDomain to a default.
	viewer.setEditDomain(new DefaultEditDomain(null));

	return viewer;
}
 
Example #2
Source File: BonitaTreeOutlinePage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return
 */
private EditPartFactory getOutlineViewEditPartFactory() {
    return new EditPartFactory() {

        @Override
        public EditPart createEditPart(final EditPart context, final Object model) {
            if (model instanceof Diagram) {
                return new TreeDiagramEditPart(model);
            } else if (model instanceof View
                    && ViewType.GROUP.equals(((View) model).getType())) {
                return new TreeContainerEditPart(model);
            } else {
                return new TreeEditPart(model);
            }
        }
    };
}
 
Example #3
Source File: ReportEditorWithPalette.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets default edit part factory.
 */
protected EditPartFactory getEditPartFactory( )
{
	if ( editPartFactoy == null )
	{
		editPartFactoy = new GraphicalPartFactory( );
	}
	return editPartFactoy;
}
 
Example #4
Source File: LibraryMasterPageEditorFormPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected EditPartFactory getEditPartFactory( )
{
	return new LibraryMasterPageGraphicalPartFactory();
}
 
Example #5
Source File: LibraryLayoutEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected EditPartFactory getEditPartFactory( )
{
	return new LibraryGraphicalPartFactory( );
}
 
Example #6
Source File: GridViewerLauncher.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a GEF Viewer with the specified model and factory.
 * 
 * @param container
 *            The Composite that will contain the viewer.
 * @param model
 *            The model for the viewer.
 * @param factory
 *            The factory used to create the viewer's EditParts.
 */
public static GraphicalViewer createViewer(Composite container, Grid model,
		EditPartFactory factory) {
	// Create the GraphicalViewer. This is fairly standard procedure for
	// GEF.
	// GraphicalViewer viewer = new ScrollingGraphicalViewer();
	// Use this to test re-sizing of window (this viewer does not create
	// scroll bars).
	GraphicalViewer viewer = new GraphicalViewerImpl();
	viewer.setRootEditPart(new SimpleRootEditPart());
	viewer.createControl(container);
	// Pass the custom EditPartFactory and the Grid model to the
	// GraphicalViewer.
	viewer.setEditPartFactory(factory);
	viewer.setContents(model);
	// Set the GraphicalViewer's EditDomain to a default.
	viewer.setEditDomain(new DefaultEditDomain(null));

	/* -- Set the viewer's current selection of cells. -- */
	// Here, we need to set the viewer's current selection of EditParts to
	// the currently-selected Cells in the Grid model. This allows us to
	// show the user the Cells that were previously selected. To do this, we
	// need to add all of the EditParts for selected Cells to the viewer's
	// StructuredSelection.

	// Create the object array needed to create the StructuredSelection.
	List<Object> selectionList = new ArrayList<Object>();

	// Add the EditParts for all selected Cells to the ArrayList.
	for (Cell cell : model.getCells()) {
		if (cell.getSelected()) {
			// Get the Cell's EditPart.
			CellEditPart editPart = (CellEditPart) viewer
					.getEditPartRegistry().get(cell);

			// Add the CellEditPart to the array.
			selectionList.add(editPart);
		}
	}

	// Create the StructuredSelection from the array and pass it to viewer.
	viewer.setSelection(new StructuredSelection(selectionList.toArray()));
	/* -------------------------------------------------- */

	return viewer;
}