Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to add a search bar on top of IPaletteCompartmentEntries
How to add a search bar on top of IPaletteCompartmentEntries [message #1016635] Thu, 07 March 2013 08:31 Go to next message
sakop qq is currently offline sakop qqFriend
Messages: 29
Registered: January 2013
Junior Member
Since there are so many options to choose from, does Graphiti provide any methods to override to realize this feature?

package com.tutorial.graphiti.editor;

import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.graphiti.ui.internal.config.IConfigurationProvider;
import org.eclipse.graphiti.ui.internal.editor.GFPaletteRoot;

public class CalculatorEditor extends DiagramEditor{
	
	public static final String ID = "calculator_editor";
	
	protected PaletteRoot createPaletteRoot() {
		System.out.println("here  aaa");
		return new MyPaletteRoot(getConfigurationProvider());
	}
}

class MyPaletteRoot extends GFPaletteRoot{

	public MyPaletteRoot(IConfigurationProvider configurationProvider) {
		super(configurationProvider);
	}
	
	//should I override this method to add a bar on top of other compartment entries?
	//if so ,how to do it?
	public void updatePaletteEntries() {
		super.updatePaletteEntries();
	}
	
}



Thanks.

[Updated on: Thu, 07 March 2013 09:06]

Report message to a moderator

Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1016799 is a reply to message #1016635] Thu, 07 March 2013 17:46 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sakop,

an idea would be to hook yourself into the DiagramEditor.createPartControl
method and add your control there. That would be outside the palette, maybe
just above it.

Michael
Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1016890 is a reply to message #1016799] Fri, 08 March 2013 05:24 Go to previous messageGo to next message
sakop qq is currently offline sakop qqFriend
Messages: 29
Registered: January 2013
Junior Member
Sounds reasoable! I will give it a shot,thanks!
Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1017099 is a reply to message #1016890] Sat, 09 March 2013 09:17 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 157
Registered: July 2009
Senior Member
Hi Sakop,

if you succeed, could you post how you did it?

Thanks,

Andreas
Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1018600 is a reply to message #1017099] Thu, 14 March 2013 07:04 Go to previous messageGo to next message
sakop qq is currently offline sakop qqFriend
Messages: 29
Registered: January 2013
Junior Member
Very ugly code,just to verify that it is feasible

package com.tutorial.graphiti.editor;

import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.graphiti.ui.internal.editor.GFPaletteRoot;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import com.tutorial.graphiti.util.CalculatorUtil;

public class CalculatorEditor extends DiagramEditor {

	public static final String ID = "calculator_editor";

	public void createPartControl(Composite parent) {
		Composite composite = new Composite(parent, SWT.None);
		// composite.setLayoutData()
		composite.setLayout(new GridLayout());
		composite.setLayout(new GridLayout(1, false));

		Composite c1 = new Composite(composite, SWT.NONE);
		c1.setLayout(new GridLayout(1, false));
		c1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
		createSearchText(c1);

		Composite c2 = new Composite(composite, SWT.NONE);
		c2.setLayoutData(new GridData(GridData.FILL_BOTH));
		c2.setLayout(new FillLayout());
		// composite.setLayout(new GridLayout(2, false));
		super.createPartControl(c2);
	}

	private void createHeadLabel(Composite parent) {
		Label headLabel = new Label(parent, SWT.NONE);
		headLabel.setText("No Connection");
		headLabel.setForeground(new Color(null, 0, 0, 102));
		GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER)
				.applyTo(headLabel);
	}

	private void createSearchText(Composite parent) {
		final Text text = new Text(parent, SWT.BORDER);
		text.setText("                                      ");
		text.setTextLimit(100);
		text.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				String value = text.getText().trim();
				GFPaletteRoot pr = (GFPaletteRoot) getPaletteRoot();
				CalculatorUtil.globalMap.put(CalculatorUtil.SEARCH_PREFIX, value);
				pr.updatePaletteEntries();
			}
		});
		
		text.addFocusListener(new FocusListener() {
			@Override
			public void focusLost(FocusEvent e) {
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				text.setText(text.getText().trim());
			}
		});
		GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(text);
	}

}

Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1041679 is a reply to message #1016635] Mon, 15 April 2013 12:06 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 30
Registered: August 2012
Member
I was able to add the SWT widgets above the Pallet area as suggested in above post.

Is it possible to add such kind of SWT widgets in the diagram editor area where actually the pictograms are added?
Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1042516 is a reply to message #1041679] Tue, 16 April 2013 14:22 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Unfortunatly not by adding SWT widgets, that is currently not supported.

Of course you might simulate something similar with Graphiti shapes, but
that would get quiet cumbersome I would guess...

Michael
Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1482182 is a reply to message #1042516] Fri, 21 November 2014 15:08 Go to previous messageGo to next message
Lars Heinemann is currently offline Lars HeinemannFriend
Messages: 20
Registered: January 2011
Junior Member

Michael, are there any plans for implementing a filter text field for the palette? It seems impossible to do that using Graphiti only as the palette code comes from GEF framework. Would really love to know if there is a way to do it or at least a nicer workaround than the one above.

Thanks
Lars

Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1490823 is a reply to message #1482182] Fri, 28 November 2014 13:24 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Lars,

sorry, there are currently no plans in that direction.

Feel free to create an enhancement bugzilla for this. The main issue I see
with this is the dynamic adding/removing of palette entries which is
something that might not be possible, but inside Graphiti's classes that
wrap or use the GEF palette one can surely filter stuff out.

Michael

PS Also feel free to provide any code snippets to implement this feature...
;-)
Previous Topic:Features code no more executed after Diagram Reopened
Next Topic:SelectionInfo in ToolBehaviorProvider is null
Goto Forum:
  


Current Time: Sat Dec 20 18:04:52 GMT 2014

Powered by FUDForum. Page generated in 0.02940 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software