How to add a search bar on top of IPaletteCompartmentEntries [message #1016635] |
Thu, 07 March 2013 08:31 |
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 09:06] Report message to a moderator
|
|
|
|
|
|
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 |
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);
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.26381 seconds