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 03:31 Go to next message
sakop qq is currently offline sakop qq
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 04: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 12:46 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
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 00:24 Go to previous messageGo to next message
sakop qq is currently offline sakop qq
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 04:17 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
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 03:04 Go to previous messageGo to next message
sakop qq is currently offline sakop qq
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 08:06 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya Mirajkar
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 10:22 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
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
Previous Topic:Shared editing domains and dispose
Next Topic:Problems using our own Meta-Model
Goto Forum:
  


Current Time: Wed Jul 30 15:15:59 EDT 2014

Powered by FUDForum. Page generated in 0.02923 seconds