0

カスタム sqlite DB を操作するためのアプリケーションを作成しています。DB は非常に複雑で、ツリーのような構造をしています。

main
--->operator1
------>name
------>address
--->operator2
------>name
------>address
------>tariffs
---------->name
---------->price

テーブルを簡単に参照して編集するために、「パス」のようなものが必要です...私のデータはSWTテーブルとして編成されています。SWT.MouseDoubleClick リスナーが接続されています。特定のテーブル行をダブルクリックして、オペレータ データに「ステップ イン」するつもりです。問題は、「メイン ビュー」に戻る方法です。そのために何らかのナビゲーションが必要です。私の現在のアイデアは、コンテナを作成し、必要なボタンを追加することです。に似ている

オウムガイ

パスは、水平に配置された連続したボタンとして作成されます。

mentis -> Dropbox -> Photos

大きな問題は、それを行う方法です;)

ボタンを作成してコンテナに追加することはできますが、これはアプリケーションの起動時にのみ機能します。アプリの実行中にコンテナーにボタンを追加する方法がわかりません。

私のメインクラスでは、次のような sth があります。

    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();

これは私の PathBar クラスです:

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");
}
}

メソッド addMainButton() および addButton() は、eventHandler から実行されることになっています... SWT テーブルにアタッチされています...

これを解決するには?助けてください:)

4

1 に答える 1

2

ボタンを追加した後、レイアウトをやり直すように指示する必要があります。

pathBar.layout(true);
于 2012-05-14T17:44:13.960 に答える