Skip to main content



      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 03:31 Go to next message
Eclipse UserFriend
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 04:06] by Moderator

Re: How to add a search bar on top of IPaletteCompartmentEntries [message #1016799 is a reply to message #1016635] Thu, 07 March 2013 12:46 Go to previous messageGo to next message
Eclipse UserFriend
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 00:24 Go to previous messageGo to next message
Eclipse UserFriend
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 04:17 Go to previous messageGo to next message
Eclipse UserFriend
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 03:04 Go to previous messageGo to next message
Eclipse UserFriend
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 08:06 Go to previous messageGo to next message
Eclipse UserFriend
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 10:22 Go to previous messageGo to next message
Eclipse UserFriend
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 10:08 Go to previous messageGo to next message
Eclipse UserFriend
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 08:24 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 07:49:06 EDT 2025

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

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

Back to the top