in source/com.microsoft.tfs.client.common.ui/src/com/microsoft/tfs/client/common/ui/prefs/ExternalToolPreferencePage.java [156:376]
protected Control createContents(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
final FormLayout containerLayout = new FormLayout();
containerLayout.spacing = 10;
container.setLayout(containerLayout);
final Group toolGroup = new Group(container, SWT.NONE);
final String messageFormat = Messages.getString("ExternalToolPreferencePage.ToolGroupTextFormat"); //$NON-NLS-1$
final String message = MessageFormat.format(messageFormat, getName());
toolGroup.setText(message);
final FormLayout toolGroupLayout = new FormLayout();
toolGroupLayout.marginHeight = 5;
toolGroupLayout.marginWidth = 5;
toolGroupLayout.spacing = 5;
toolGroup.setLayout(toolGroupLayout);
final FormData mergeGroupData = new FormData();
mergeGroupData.top = new FormAttachment(0, 0);
mergeGroupData.left = new FormAttachment(0, 0);
mergeGroupData.right = new FormAttachment(100, 0);
mergeGroupData.bottom = new FormAttachment(100, 0);
toolGroup.setLayoutData(mergeGroupData);
toolTable = new Table(toolGroup, SWT.FULL_SELECTION);
AutomationIDHelper.setWidgetID(toolTable, TOOL_TABLE_ID);
toolTableViewer = new TableViewer(toolTable);
toolAddButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(toolAddButton, ADD_BUTTON_ID);
toolEditButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(toolEditButton, EDIT_BUTTON_ID);
toolRemoveButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(toolRemoveButton, REMOVE_BUTTON_ID);
toolDuplicateButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(toolDuplicateButton, DUPLICATE_BUTTON_ID);
dirToolSeparator = new Label(toolGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
dirToolLabel = new Label(toolGroup, SWT.NONE);
dirToolRemoveButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(dirToolRemoveButton, DIR_REMOVE_BUTTON_ID);
dirToolEditButton = new Button(toolGroup, SWT.NONE);
AutomationIDHelper.setWidgetID(dirToolEditButton, DIR_EDIT_BUTTON_ID);
// external compare checkbox
final FormData toolTableData = new FormData();
toolTableData.top = new FormAttachment(0, 0);
toolTableData.left = new FormAttachment(0, 0);
toolTableData.right = new FormAttachment(100, 0);
toolTableData.bottom = new FormAttachment(toolAddButton, 0, SWT.TOP);
toolTable.setLayoutData(toolTableData);
toolTable.setLinesVisible(true);
toolTable.setHeaderVisible(true);
final TableLayout mergeTableLayout = new TableLayout();
toolTable.setLayout(mergeTableLayout);
mergeTableLayout.addColumnData(new ColumnWeightData(20, 40, true));
final TableColumn typeColumn = new TableColumn(toolTable, SWT.NONE);
typeColumn.setText(Messages.getString("ExternalToolPreferencePage.ColumnNameType")); //$NON-NLS-1$
mergeTableLayout.addColumnData(new ColumnWeightData(80, 160, true));
final TableColumn commandColumn = new TableColumn(toolTable, SWT.NONE);
commandColumn.setText(Messages.getString("ExternalToolPreferencePage.ColumnNameCommand")); //$NON-NLS-1$
toolTableViewer.setLabelProvider(new ExternalToolLabelProvider());
toolTableViewer.setContentProvider(new ExternalContentProvider());
toolTableViewer.setInput(new Object());
final TableViewerSorter sorter = new TableViewerSorter(toolTableViewer);
toolTableViewer.setSorter(sorter);
sorter.sort(0);
toolTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
setEnabled();
}
});
// external tool add
final FormData toolAddData = new FormData();
toolAddData.right = new FormAttachment(100, 0);
toolAddData.bottom =
supportsDirectories() ? new FormAttachment(dirToolSeparator, -1, SWT.TOP) : new FormAttachment(100, 0);
toolAddButton.setLayoutData(toolAddData);
toolAddButton.setText(Messages.getString("ExternalToolPreferencePage.AddButtonText")); //$NON-NLS-1$
toolAddButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (addPressed()) {
refresh();
}
}
});
// external tool edit
final FormData toolEditData = new FormData();
toolEditData.right = new FormAttachment(toolAddButton, 0, SWT.LEFT);
toolEditData.bottom = new FormAttachment(toolAddButton, 0, SWT.BOTTOM);
toolEditButton.setLayoutData(toolEditData);
toolEditButton.setText(Messages.getString("ExternalToolPreferencePage.EditButtonText")); //$NON-NLS-1$
toolEditButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (editPressed()) {
refresh();
}
}
});
// external tool remove
final FormData toolRemoveData = new FormData();
toolRemoveData.right = new FormAttachment(toolEditButton, 0, SWT.LEFT);
toolRemoveData.bottom = new FormAttachment(toolEditButton, 0, SWT.BOTTOM);
toolRemoveButton.setLayoutData(toolRemoveData);
toolRemoveButton.setText(Messages.getString("ExternalToolPreferencePage.RemoveButtonText")); //$NON-NLS-1$
toolRemoveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (removePressed()) {
refresh();
}
}
});
// duplicate tool settings
final FormData toolDuplicateData = new FormData();
toolDuplicateData.right = new FormAttachment(toolRemoveButton, 0, SWT.LEFT);
toolDuplicateData.bottom = new FormAttachment(toolRemoveButton, 0, SWT.BOTTOM);
toolDuplicateButton.setLayoutData(toolDuplicateData);
toolDuplicateButton.setText(Messages.getString("ExternalToolPreferencePage.DuplicateButtonText")); //$NON-NLS-1$
toolDuplicateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (duplicatePressed()) {
refresh();
}
}
});
// external tools for directories
if (supportsDirectories()) {
final FormData dirToolSeparatorData = new FormData();
dirToolSeparatorData.left = new FormAttachment(0, 0);
dirToolSeparatorData.right = new FormAttachment(100, 0);
dirToolSeparatorData.bottom = new FormAttachment(dirToolEditButton, -1, SWT.TOP);
dirToolSeparator.setLayoutData(dirToolSeparatorData);
final FormData dirToolData = new FormData();
dirToolData.left = new FormAttachment(0, 0);
dirToolData.right = new FormAttachment(dirToolRemoveButton, -10, SWT.LEFT);
dirToolData.top = new FormAttachment(
dirToolEditButton,
FormHelper.VerticalOffset(dirToolLabel, dirToolEditButton),
SWT.TOP);
dirToolLabel.setLayoutData(dirToolData);
dirToolLabel.setAlignment(SWT.RIGHT);
// remove directory tool
final FormData dirToolRemoveData = new FormData();
dirToolRemoveData.right = new FormAttachment(dirToolEditButton, 0, SWT.LEFT);
dirToolRemoveData.top = new FormAttachment(dirToolEditButton, 0, SWT.TOP);
dirToolRemoveButton.setLayoutData(dirToolRemoveData);
dirToolRemoveButton.setText(Messages.getString("ExternalToolPreferencePage.DirRemoveButtonText")); //$NON-NLS-1$
dirToolRemoveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
dirRemovePressed();
refresh();
}
});
// change/add directory tool
final FormData dirToolEditData = new FormData();
dirToolEditData.right = new FormAttachment(100, 0);
dirToolEditData.bottom = new FormAttachment(100, 0);
dirToolEditButton.setLayoutData(dirToolEditData);
dirToolEditButton.setText(Messages.getString("ExternalToolPreferencePage.DirChangeButtonText")); //$NON-NLS-1$
dirToolEditButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (getToolset().findToolForDirectory() != null) {
dirChangePressed();
} else {
dirAddPressed();
}
refresh();
}
});
}
/* Resize button sizes */
ButtonHelper.resizeButtons(new Button[] {
toolAddButton,
toolEditButton,
toolRemoveButton,
toolDuplicateButton,
dirToolRemoveButton,
dirToolEditButton
});
if (toolTable.getItemCount() > 0) {
toolTable.setSelection(0);
}
setEnabled();
refresh();
return container;
}