org.eclipse.gef.palette.PaletteRoot Java Examples

The following examples show how to use org.eclipse.gef.palette.PaletteRoot. 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: CustomMainPaletteViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setPaletteRoot(PaletteRoot root) {
	if (root == getPaletteRoot())
		return;
	super.setPaletteRoot(root);
	if (getPaletteRoot() != null) {
		final PaletteRoot filteredPalette = filterPaletteRoot(getPaletteRoot());
		for(Object c : filteredPalette.getChildren()){
			if(c instanceof PaletteDrawer){
				((PaletteDrawer)c).setShowDefaultIcon(false);
				((PaletteDrawer)c).setUserModificationPermission(PaletteDrawer.PERMISSION_NO_MODIFICATION);
			}
		}
		getRootEditPart().setContents(getEditPartFactory().createEditPart(
				getRootEditPart(),filteredPalette));
	}
}
 
Example #2
Source File: GraphicalEditorWithFlyoutPalette.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
 */
public Object getAdapter( Class type )
{
	if ( type == PalettePage.class )
	{
		if ( splitter == null )
		{
			page = createPalettePage( );
			return page;
		}
		return createPalettePage( );
	}

	if ( type == PaletteRoot.class )
	{
		return getPaletteRoot( );
	}

	if ( type == ZoomManager.class )
	{
		return getGraphicalViewer( ).getProperty( ZoomManager.class.toString( ) );
	}
	return super.getAdapter( type );
}
 
Example #3
Source File: DesignerPaletteFactory.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the palette and returns the palette
 * 
 * @return the editor palette
 */
public static PaletteRoot createPalette( )
{
	PaletteRoot root = BasePaletteFactory.createPalette( );
	root.addAll( createCategories( ) );

	IExtension extension = new IExtension.Stub( ) {

		public String getExtendsionIdentify( )
		{
			return GuiExtensionManager.PALETTE_DESIGNER;
		}
	};
	GuiExtensionManager.doExtension( extension, root );
	
	root.add( createQuickTools( ) );

	return root;
}
 
Example #4
Source File: MasterPagePaletteFactory.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the palette and returns the palette
 * 
 * @return the editor palette
 */
public static PaletteRoot createPalette( )
{
	PaletteRoot root = BasePaletteFactory.createPalette( );
	root.addAll( createCategories( ) );
	root.add( createAutoTextDrawer( ) );

	IExtension extension = new IExtension.Stub( ) {

		public String getExtendsionIdentify( )
		{
			return GuiExtensionManager.PALETTE_MASTERPAGE;
		}
	};
	GuiExtensionManager.doExtension( extension, root );
	return root;
}
 
Example #5
Source File: BasePaletteFactory.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates default tools category, which include selection and marquee tools
 * 
 * @param root
 *            the root
 * @return PaletteContainer contains default tools
 */
protected static PaletteContainer createControlGroup( PaletteRoot root )
{
	PaletteGroup controlGroup = new PaletteGroup( PALETTE_GROUP_TEXT );

	List<ToolEntry> entries = new ArrayList<ToolEntry>( );

	ToolEntry tool = new PanningSelectionToolEntry( POINTER_SELECT_LABEL,
			TOOL_TIP_POINTER_SELECT );
	entries.add( tool );
	root.setDefaultEntry( tool );

	tool = new MarqueeToolEntry( RECTANGEL_SELECT_LABEL,
			TOOL_TIP_RECTANGLE_SELECT );
	entries.add( tool );

	controlGroup.addAll( entries );
	return controlGroup;
}
 
Example #6
Source File: CustomMainPaletteViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private PaletteRoot filterPaletteRoot(PaletteRoot paletteRoot) {
	PaletteRoot newRoot = new PaletteRoot();
	for(Object child : paletteRoot.getChildren()){
		if(child instanceof PaletteEntry){
			final String id = ((PaletteEntry) child).getId();
			if(onlyDisplayedEntry != null && onlyDisplayedEntry.equals(id)) {
				newRoot.add((PaletteEntry) child);
				break;
			}else if(!filters.contains(id)){
				newRoot.add((PaletteEntry) child);
			}
		}
	}

	return newRoot;
}
 
Example #7
Source File: LibraryLayoutEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected PaletteRoot getPaletteRoot( )
{
	if ( paletteRoot == null )
	{
		paletteRoot = DesignerPaletteFactory.createPalette( );
	}
	return paletteRoot;

}
 
Example #8
Source File: CustomPaletteEditPartFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EditPart createMainPaletteEditPart(EditPart parentEditPart,
		Object model) {
	return new SliderPaletteEditPart((PaletteRoot) model){
		@Override
		public IFigure createFigure() {
			Figure figure = new Figure();
			figure.setOpaque(true);
			figure.setForegroundColor(ColorConstants.listForeground);
			figure.setBackgroundColor(ColorConstants.white);
			return figure;
		}
	};
}
 
Example #9
Source File: ReportLayoutEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected PaletteRoot getPaletteRoot( )
{
	if ( paletteRoot == null )
	{
		paletteRoot = DesignerPaletteFactory.createPalette( );
	}
	return paletteRoot;

}
 
Example #10
Source File: ReportMasterPageEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected PaletteRoot getPaletteRoot( )
{
	if ( paletteRoot == null )
	{
		paletteRoot = MasterPagePaletteFactory.createPalette( );
	}
	return paletteRoot;
}
 
Example #11
Source File: EditorPaletteFactoryTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test for default palette root when the parameter is null
 */
public void testCreateReportGraphicalEditorPalette( )
{

	PaletteRoot root = MasterPagePaletteFactory.createPalette( );
	int size = 3;
	if ( ExtensionPointManager.getInstance( )
			.getExtendedElementPoint( ITestConstants.TEST_EXTENSION_NAME ) != null )
	{
		// extended item is not shown in masterpage.
		//size++;
	}
	assertEquals( size, root.getChildren( ).size( ) );
}
 
Example #12
Source File: EditorPaletteFactoryTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test for default palette root when the parameter is not instance of
 * ReportGraphicalEditor
 */
public void testCreatePalette( )
{
	PaletteRoot root = DesignerPaletteFactory.createPalette( );
	int size = 3;
	if ( ExtensionPointManager.getInstance( )
			.getExtendedElementPoint( ITestConstants.TEST_EXTENSION_NAME ) != null )
	{
		size++;
	}
	assertEquals( size, root.getChildren( ).size( ) );
}
 
Example #13
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated BonitaSoft
 */
protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
	//#### COPY-PASTED from parent
	PaletteRoot paletteRoot;
	if (existingPaletteRoot == null) {
		paletteRoot = CustomPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
	} else {
		CustomPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
		paletteRoot = existingPaletteRoot;
	}
	new ProcessPaletteFactory().fillPalette(paletteRoot);//don't know why we need to add it, the left palette is empty if not.
	applyCustomizationsToPalette(paletteRoot);
	root = paletteRoot;//required because root is used in configurePaletteViewer
	return paletteRoot;
}
 
Example #14
Source File: StatechartPaletteProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void contributeToPalette(IEditorPart editor, Object content, PaletteRoot root,
		@SuppressWarnings("rawtypes") Map predefinedEntries) {
	IFile adapter = (IFile) editor.getEditorInput().getAdapter(IFile.class);
	String domainID = DomainRegistry
			.determineDomainID(URI.createPlatformResourceURI(adapter.getFullPath().toOSString(), true));
	Injector editorInjector = DomainRegistry.getDomain(domainID).getInjector(IDomain.FEATURE_EDITOR);
	ISCTPaletteFactory factory = editorInjector.getInstance(ISCTPaletteFactory.class);
	factory.createPaletteEntries(root);
}
 
Example #15
Source File: ProcessPaletteFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public void fillPalette(PaletteRoot paletteRoot) {
	paletteRoot.add(createSwimlanes1Group());
	paletteRoot.add(createGateways2Group());
	paletteRoot.add(createFlow3Group());
	paletteRoot.add(createTasks4Group());
	paletteRoot.add(createActivities5Group());
	paletteRoot.add(createStartEvents6Group());
	paletteRoot.add(createIntEvents7Group());
	paletteRoot.add(createEndEvents8Group());
	paletteRoot.add(createTextAnnotation9Group());
}
 
Example #16
Source File: DefaultSCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void createPaletteEntries(PaletteRoot root) {
	PaletteContainer container = createToolsCategory(root);
	createTransitionEntry(container);
	createStateEntry(container);
	createCompositeStateEntry(container);
	createOrthogonalStateEntry(container);
	createRegionEntry(container);
	createInitialStateEntry(container);
	createShallowHistoryEntry(container);
	createDeepHistoryEntry(container);
	createFinalStateEntry(container);
	createExitEntry(container);
	createChoiceEntry(container);
	createSynchronizationEntry(container);
}
 
Example #17
Source File: SwitchPaletteMode.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given the rootMemento, gets the memento that already exists for the
 * palette entry or creates a new one in the rootMemento (and the necessary
 * palette container mementos) if one does not exist yet. The root memento's
 * tree structure matches that of the palette root. If a palette entry in
 * stack A, in drawer B is customized, the root memento will have a child
 * memento for drawer B which has a child memento for stack A which has a
 * child memento for the entry. The memento's use the palette entry's id.
 * 
 * @param rootMemento
 *            the root memento representing the palette root
 * @param paletteEntry
 *            the palette entry for which a memento should be retrieved or
 *            created
 * @return returns the memento that already exists for the palette entry or
 *         creates a new one in the rootMemento if one does not exist yet or
 *         null if the memento could not be created (most likely because the
 *         palete id is not acceptable).
 */
private IMemento getMementoForEntry(IMemento rootMemento, PaletteEntry paletteEntry) {

	ArrayList<String> idList = new ArrayList<String>();
	idList.add(paletteEntry.getId());

	PaletteContainer parent = paletteEntry.getParent();
	while (parent != null && !PaletteRoot.PALETTE_TYPE_ROOT.equals(parent.getType())) {
		idList.add(parent.getId());
		parent = parent.getParent();
	}

	// go through ids in reverse order and create the mementos as necessary
	IMemento containerMemento = rootMemento;
	for (int i = idList.size() - 1; i >= 0; i--) {
		String id = idList.get(i);
		IMemento memento = containerMemento.getChild(id);
		if (memento == null) {
			try {
				memento = containerMemento.createChild(id);
			} catch (Exception e) {
				Trace.catching(GefPlugin.getInstance(), GefDebugOptions.EXCEPTIONS_CATCHING, getClass(),
						"Invalid palette id encountered when saving the palette customizations.", //$NON-NLS-1$
						e);
				Log.warning(GefPlugin.getInstance(), GefStatusCodes.IGNORED_EXCEPTION_WARNING,
						"Invalid palette id encountered when saving the palette customizations.", //$NON-NLS-1$
						e);
				return null;
			}
		}
		containerMemento = memento;
	}

	return containerMemento;
}
 
Example #18
Source File: ERDiagramEditor.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected PaletteRoot getPaletteRoot() {
	return new ERDiagramPaletteRoot();
}
 
Example #19
Source File: ProcessEditPolicyEntries.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ProcessEditPolicyEntries(EditDomain domain) {
	ProcessPaletteFactory paletteFactory = new ProcessPaletteFactory();
	paletteRoot = new PaletteRoot();
	paletteFactory.fillPalette(paletteRoot);
	this.domain = domain;
}
 
Example #20
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 *  @generated BonitaSoft
 */
public PaletteRoot getPaletteRoot() {
	return root;
}
 
Example #21
Source File: CrossflowDiagramEditor.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
* @generated
*/
protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
	PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
	new CrossflowPaletteFactory().fillPalette(root);
	return root;
}
 
Example #22
Source File: CustomPaletteService.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public void contributeToPalette(
	IEditorPart editor,
	Object content,
	PaletteRoot root, Map predefinedEntries) {

    PaletteToolbar standardGroup = new PaletteToolbar(GROUP_STANDARD, DiagramUIMessages.StandardGroup_Label);
	standardGroup.setDescription(DiagramUIMessages.StandardGroup_Description);
	root.add(standardGroup);

	PaletteSeparator standardSeparator = new PaletteSeparator(SEPARATOR_STANDARD);
	standardGroup.add(standardSeparator);

	ToolEntry selectTool = new PanningSelectionToolEntry();
	selectTool.setId(TOOL_SELECTION);
	selectTool.setToolClass(SelectionToolEx.class);
	standardGroup.add(selectTool);
	root.setDefaultEntry(selectTool);
	
	ToolEntry hSpace = new ToolEntry(Messages.SpacingHorizontalTitle,
			Messages.SpacingHorizontalDesc,
			Pics.getImageDescriptor(PicsConstants.HorizontalSpacingTool16),
			Pics.getImageDescriptor(PicsConstants.HorizontalSpacingTool24),
			MultipleShapesHorizontalMoveTool.class) {
	};
	hSpace.setId("Messages.SpacingHorizontalTitle");

	ToolEntry vSpave = new ToolEntry(Messages.SpacingVerticalTitle,
			Messages.SpacingVerticalDesc,
			Pics.getImageDescriptor(PicsConstants.VerticalSpacingTool16),
			Pics.getImageDescriptor(PicsConstants.VerticalSpacingTool24),
			MultipleShapesVerticalMoveTool.class) {
	};
	vSpave.setId(Messages.SpacingVerticalTitle);

	final MarqueeToolEntry marqueeToolEntry = new MarqueeToolEntry();
	marqueeToolEntry.setId("Bonita.MarqueeToolEntry");
	standardGroup.add(marqueeToolEntry);
	final ZoomInToolEntry zoomInToolEntry = new ZoomInToolEntry();
	zoomInToolEntry.setId("Bonita.ZoomInToolEntry");
	standardGroup.add(zoomInToolEntry);
	final ZoomOutToolEntry zoomOutToolEntry = new ZoomOutToolEntry();
	zoomOutToolEntry.setId("Bonita.ZoomOutToolEntry");
	standardGroup.add(zoomOutToolEntry);
	standardGroup.add(hSpace);
	standardGroup.add(vSpave);
	final HorizontalAlignToolEntry horizontalAlignToolEntry = new HorizontalAlignToolEntry();
	horizontalAlignToolEntry.setId("Bonita.HorizontalAlignToolEntry");
	standardGroup.add(horizontalAlignToolEntry);
	final VerticalAlignToolEntry verticalAlignToolEntry = new VerticalAlignToolEntry();
	verticalAlignToolEntry.setId("Bonita.VerticalAlignToolEntry");
	standardGroup.add(verticalAlignToolEntry);

	execute(new ContributeToPaletteOperation(editor, content, root, predefinedEntries));       
}
 
Example #23
Source File: BasePaletteFactory.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected static PaletteRoot createPalette( )
{
	PaletteRoot root = new PaletteRoot( );
	root.add( createControlGroup( root ) );
	return root;
}
 
Example #24
Source File: MainDiagramEditor.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected PaletteRoot getPaletteRoot() {
    Activator.debug(this, "getPaletteRoot()", "...Creating palette root: " + diagram);
    return new ERDiagramPaletteRoot(diagram);
}
 
Example #25
Source File: DefaultSCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected PaletteContainer createToolsCategory(PaletteRoot root) {
	PaletteDrawer drawer = new PaletteDrawer("Tools");
	root.add(drawer);
	return drawer;
}
 
Example #26
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected PaletteRoot getPaletteRoot() {
    return palette;
}
 
Example #27
Source File: CrossflowPaletteFactory.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
* @generated
*/
public void fillPalette(PaletteRoot paletteRoot) {
	paletteRoot.add(createObjects1Group());
	paletteRoot.add(createConnections2Group());
}
 
Example #28
Source File: GraphicalEditorWithFlyoutPalette.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the PaletteRoot for the palette viewer.
 * 
 * @return the palette root
 */
protected abstract PaletteRoot getPaletteRoot( );
 
Example #29
Source File: ReportEditorWithPalette.java    From birt with Eclipse Public License 1.0 votes vote down vote up
abstract protected PaletteRoot getPaletteRoot( ); 
Example #30
Source File: ISCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 votes vote down vote up
public void createPaletteEntries(PaletteRoot root);