I am writing a application for manipulating a custom sqlite DB.
DB is quite complicated, it has tree like structure.
main
--->operator1
------>name
------>address
--->operator2
------>name
------>address
------>tariffs
---------->name
---------->price
I need to have something like a ‘path’ in order to easily browse through the table and edit stuff… My data is organized as SWT Table. I have SWT.MouseDoubleClick listener attached to it. I intent to ‘step into’ my operator data by double clicking on a particular table row. The problem is, how to get back to the ‘main view’, I need some sort of navigation for that purpose.
My current idea is to create a container and add necessary buttons into it. Similar to
Notice, the path is created as consecutive buttons, aligned horizontally:
mentis -> Dropbox -> Photos
The big question is how to do that 😉
I am able to create a button and add it to may container, however this works only when application starts. I don’t know how to add buttons to my container when the app is running.
In my main class I have sth like this:
Composite pathBarContainer = new Composite(shell, SWT.BORDER);
pathBarContainer.setSize(shell.getBounds().width, 20);
pathBarContainer.setLayout(new FillLayout(SWT.HORIZONTAL));
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 3;
pathBarContainer.setLayoutData(gridData);
pathBar = new PathBar(pathBarContainer, shell, contentProvider);
pathBar.getPathBar();
this is my PathBar class:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
public class PathBar {
Composite parent;
Composite pathBar;
Shell mainShell;
ContentProvider contentProvider;
Button mainButton;
Button nextButton;
public PathBar(Composite parent_in, Shell mainShell_in, ContentProvider cp) {
parent = parent_in;
mainShell = mainShell_in;
contentProvider = cp;
pathBar = new Composite(parent, SWT.BORDER_DOT);
//pathBar.setSize(100, 300);
pathBar.setLayout(new GridLayout(10, true));
mainButton = new Button(pathBar, SWT.PUSH);
mainButton.setText("main");
}
public Composite getPathBar() {
return pathBar;
}
public void addMainButton() {
mainButton = new Button(pathBar, SWT.PUSH);
mainButton.setText("main");
pathBar.redraw();
//parent.redraw();
//mainShell.redraw();
}
public void addButton() {
nextButton = new Button(pathBar, SWT.PUSH);
nextButton.setText("sth");
pathBar.redraw();
parent.redraw();
System.out.println("addButton");
}
}
Methods addMainButton() and addButton() are supposed to be run from eventHandler… attached to my SWT table…
How to solve this ?
Pls help 🙂
You need to tell it to redo your layout after you add buttons.