How to add a search bar on top of IPaletteCompartmentEntries [message #1016635] |
Thu, 07 March 2013 03:31  |
Eclipse User |
|
|
|
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 #1018600 is a reply to message #1017099] |
Thu, 14 March 2013 03:04   |
Eclipse User |
|
|
|
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 #1490823 is a reply to message #1482182] |
Fri, 28 November 2014 08:24  |
Eclipse User |
|
|
|
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...
;-)
|
|
|
Powered by
FUDForum. Page generated in 0.04183 seconds