ユーザーが列ヘッダーをドラッグして列を並べ替えることができるマルチ列 SWT Tree
( JFace 経由)を設定しようとしています。TreeViewer
ただし、最初の列は固定して移動できないようにする必要があります。setMoveable(true)
最初のメソッドを除いて、それぞれでメソッドを使用しTreeColumn
て実際に近づけることができますが、ユーザーが別の列をその左側にドラッグすることを妨げません。これを解決する方法はありますか?
問題を説明するための簡略化された作業スニペット (JFace なし) を次に示します。
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
public class TreeTableColumnMove {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout(SWT.HORIZONTAL));
Tree tree = new Tree(shell, SWT.BORDER | SWT.CHECK);
tree.setLayoutData(new RowData(-1, 100));
tree.setHeaderVisible(true);
for (int i = 0; i < 5; i++) {
TreeColumn column = new TreeColumn(tree, SWT.CENTER);
column.setText("Col " + i);
column.setWidth(60);
if (i > 0) column.setMoveable(true);
}
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText(new String[] { "c0", "c1", "c2", "c3", "c4" });
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}