private void createControls() {
setLayout(new GridLayout(2, false));
setLayoutData(new GridData(GridData.FILL_BOTH));
ViewForm viewerPane = new ViewForm(this, SWT.BORDER | SWT.FLAT);
viewerPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
CLabel toolbarLabel = new CLabel(viewerPane, SWT.NONE) {
public Point computeSize(int wHint, int hHint, boolean changed) {
return super.computeSize(wHint, Math.max(24, hHint), changed);
}
};
if (label != null) {
toolbarLabel.setText(label);
}
viewerPane.setTopLeft(toolbarLabel);
int buttonGroupColumns = 1;
if (toolbarControlCreator != null) {
buttonGroupColumns = buttonGroupColumns + toolbarControlCreator.getControlCount();
}
ToolBar toolbar = new ToolBar(viewerPane, SWT.FLAT);
viewerPane.setTopCenter(toolbar);
ToolBarManager toolbarManager = new ToolBarManager(toolbar);
if (toolbarControlCreator != null) {
toolbarControlCreator.createToolbarControls(toolbarManager);
toolbarManager.add(new Separator());
}
flatAction = new Action(Policy.bind("ResourceSelectionTree.flat"), Action.AS_RADIO_BUTTON) { //$NON-NLS-1$
public void run() {
mode = MODE_FLAT;
settings.put(MODE_SETTING, MODE_FLAT);
treeAction.setChecked(false);
compressedAction.setChecked(false);
refresh();
}
};
flatAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_AFFECTED_PATHS_FLAT_MODE));
toolbarManager.add(flatAction);
treeAction = new Action(Policy.bind("ResourceSelectionTree.tree"), Action.AS_RADIO_BUTTON) { //$NON-NLS-1$
public void run() {
mode = MODE_TREE;
settings.put(MODE_SETTING, MODE_TREE);
flatAction.setChecked(false);
compressedAction.setChecked(false);
refresh();
}
};
treeAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_AFFECTED_PATHS_TREE_MODE));
toolbarManager.add(treeAction);
compressedAction = new Action(Policy.bind("ResourceSelectionTree.compressedFolders"), Action.AS_RADIO_BUTTON) { //$NON-NLS-1$
public void run() {
mode = MODE_COMPRESSED_FOLDERS;
settings.put(MODE_SETTING, MODE_COMPRESSED_FOLDERS);
treeAction.setChecked(false);
flatAction.setChecked(false);
refresh();
}
};
compressedAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_AFFECTED_PATHS_COMPRESSED_MODE));
toolbarManager.add(compressedAction);
toolbarManager.update(true);
mode = MODE_COMPRESSED_FOLDERS;
try {
mode = settings.getInt(MODE_SETTING);
} catch (Exception e) {}
switch (mode) {
case MODE_COMPRESSED_FOLDERS:
compressedAction.setChecked(true);
break;
case MODE_FLAT:
flatAction.setChecked(true);
break;
case MODE_TREE:
treeAction.setChecked(true);
break;
default:
break;
}
if (checkbox) {
treeViewer = new CheckboxTreeViewer(viewerPane, SWT.MULTI);
// Override the spacebar behavior to toggle checked state for all selected items.
treeViewer.getControl().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (event.keyCode == SPACEBAR) {
Tree tree = (Tree)treeViewer.getControl();
TreeItem[] items = tree.getSelection();
for (int i = 0; i < items.length; i++) {
if (i > 0) items[i].setChecked(!items[i].getChecked());
}
}
}
});
} else {
treeViewer = new TreeViewer(viewerPane, SWT.MULTI);
}
tree = treeViewer.getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewerPane.setContent(tree);
if (labelProvider == null) {
labelProvider = new ResourceSelectionLabelProvider();
}