use of org.eclipse.swt.layout.FormData in project cubrid-manager by CUBRID.
the class TableConfigCellEditor method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(1, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(55, 0);
leftComposite.setLayoutData(leftData);
Group grpButtons = new Group(leftComposite, SWT.NONE);
{
grpButtons.setLayout(new GridLayout(4, false));
grpButtons.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
grpButtons.setText(Messages.grpAddRemove);
}
Button sqlSchemaFileButton = new Button(grpButtons, SWT.NONE);
sqlSchemaFileButton.setText(Messages.btnAddSchemaFile);
sqlSchemaFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlSchemaFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_SCHEMA);
}
});
Button sqlDataFileButton = new Button(grpButtons, SWT.NONE);
sqlDataFileButton.setText(Messages.btnAddDataFile);
sqlDataFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlDataFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_DATA);
}
});
Button sqlIndexFileButton = new Button(grpButtons, SWT.NONE);
sqlIndexFileButton.setText(Messages.btnAddIndexFile);
sqlIndexFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlIndexFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_INDEX);
}
});
delFileButton = new Button(grpButtons, SWT.NONE);
delFileButton.setText(Messages.btnDelFiles);
delFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
delFileButton.setEnabled(false);
delFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
deleteSelectedFile();
}
});
sqlFileTableViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
sqlFileTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
sqlFileTableViewer.getTable().setLinesVisible(true);
sqlFileTableViewer.getTable().setHeaderVisible(true);
final TableViewerColumn fileNameCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileNameCol.getColumn().setWidth(300);
fileNameCol.getColumn().setText(Messages.columnImportFileName);
final TableViewerColumn fileTypeCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileTypeCol.getColumn().setWidth(100);
fileTypeCol.getColumn().setText(Messages.columnImportFileType);
CellEditor[] editors = new CellEditor[4];
editors[0] = new TextCellEditor(sqlFileTableViewer.getTable());
editors[1] = new ComboBoxCellEditor(sqlFileTableViewer.getTable(), TYPE_ITEMS, SWT.READ_ONLY);
sqlFileTableViewer.setColumnProperties(PROPS);
sqlFileTableViewer.setContentProvider(new SQLFileTableContentProvider());
sqlFileTableViewer.setLabelProvider(new SQLFileTableLabelProvider());
sqlFileTableViewer.setCellModifier(new TableConfigCellEditor(sqlFileTableViewer, this));
sqlFileTableViewer.setCellEditors(editors);
sqlFileTableViewer.getTable().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
delFileButton.setEnabled(delCanEnable());
}
});
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(55, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
enCodingOptionGroup.setText(Messages.grpEncodingOption);
enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
enCodingOptionGroup.setLayout(new GridLayout(4, false));
Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblDBCharset);
dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
fileCharsetCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
getImportDataWizard().getImportConfig().setFilesCharset(fileCharsetCombo.getText());
}
});
Group importOptionGroup = new Group(rightComposite, SWT.None);
importOptionGroup.setText(Messages.grpImportOptions);
importOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
importOptionGroup.setLayout(new GridLayout(2, false));
Label threadCountLabel = new Label(importOptionGroup, SWT.None);
threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
threadCountLabel.setText(Messages.lblThreadNum);
threadCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
threadCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_THREAD_COUNT);
threadCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_THREAD_COUNT);
threadCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_THREAD_COUNT);
threadCountSpinner.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
Label commitCountLabel = new Label(importOptionGroup, SWT.None);
commitCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
commitCountLabel.setText(Messages.lblCommitCount);
commitCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
commitCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
commitCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_COMMIT_COUNT);
commitCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_COMMIT_COUNT);
commitCountSpinner.setIncrement(ImportConfig.IMPORT_COMMIT_STEP);
commitCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_COMMIT_COUNT);
final Button haModeButton = new Button(rightComposite, SWT.CHECK);
haModeButton.setText(Messages.btnInHaMode);
haModeButton.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
haModeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ImportConfig importConfig = getImportDataWizard().getImportConfig();
importConfig.setHaMode(haModeButton.getSelection());
Collections.sort(fileList, new TableConfigComparator(getImportDataWizard().getImportConfig()));
sqlFileTableViewer.refresh();
}
});
registerContextMenu();
}
use of org.eclipse.swt.layout.FormData in project cubrid-manager by CUBRID.
the class ImportTypePage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
Composite leftComposite = new Composite(container, SWT.NONE);
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, 0);
GridLayout leftLayout = new GridLayout();
leftLayout.verticalSpacing = 0;
leftComposite.setLayout(leftLayout);
leftComposite.setLayoutData(leftData);
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 0);
rightData.right = new FormAttachment(100, -5);
GridLayout rightLayout = new GridLayout();
rightLayout.verticalSpacing = 0;
rightComposite.setLayout(rightLayout);
rightComposite.setLayoutData(rightData);
sqlButton = new Button(leftComposite, SWT.RADIO);
sqlButton.setText(Messages.btnImportSQL);
sqlButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
excelButton.setSelection(!sqlButton.getSelection());
txtButton.setSelection(!sqlButton.getSelection());
historyButton.setSelection(!sqlButton.getSelection());
historyCombo.setEnabled(false);
deleteButton.setEnabled(false);
renameButton.setEnabled(false);
validate();
}
});
Group sqlLabelGroup = new Group(leftComposite, SWT.None);
sqlLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 80));
sqlLabelGroup.setLayout(new FillLayout());
Label sqlLabel = new Label(sqlLabelGroup, SWT.WRAP);
sqlLabel.setText(Messages.lblImportSQL);
Label separator1Label = new Label(leftComposite, SWT.None);
separator1Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 15));
{
Label separator4Label = new Label(leftComposite, SWT.None);
separator4Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 15));
excelButton = new Button(leftComposite, SWT.RADIO);
excelButton.setText(Messages.btnImportExcel);
excelButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
excelButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
sqlButton.setSelection(!excelButton.getSelection());
txtButton.setSelection(!excelButton.getSelection());
historyButton.setSelection(!excelButton.getSelection());
historyCombo.setEnabled(false);
deleteButton.setEnabled(false);
renameButton.setEnabled(false);
validate();
}
});
Group excelLabelGroup = new Group(leftComposite, SWT.None);
excelLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 80));
excelLabelGroup.setLayout(new FillLayout());
Label excelLabel = new Label(excelLabelGroup, SWT.WRAP);
excelLabel.setText(Messages.lblImportExcel);
Label separator2Label = new Label(leftComposite, SWT.None);
separator2Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 15));
}
// Txt
{
txtButton = new Button(rightComposite, SWT.RADIO);
txtButton.setText(Messages.btnImportTxt);
txtButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
txtButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
sqlButton.setSelection(!txtButton.getSelection());
excelButton.setSelection(!txtButton.getSelection());
historyButton.setSelection(!txtButton.getSelection());
historyCombo.setEnabled(false);
deleteButton.setEnabled(false);
renameButton.setEnabled(false);
validate();
}
});
Group txtLabelGroup = new Group(rightComposite, SWT.None);
txtLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 80));
txtLabelGroup.setLayout(new FillLayout());
Label txtLabel = new Label(txtLabelGroup, SWT.WRAP);
txtLabel.setText(Messages.lblImportTxt);
Label separator3Label = new Label(rightComposite, SWT.None);
separator3Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 15));
}
// History Button
{
Label separator4Label = new Label(rightComposite, SWT.None);
separator4Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 15));
historyButton = new Button(rightComposite, SWT.RADIO);
historyButton.setText(Messages.btnImportHistory);
historyButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
historyButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
sqlButton.setSelection(!historyButton.getSelection());
excelButton.setSelection(!historyButton.getSelection());
txtButton.setSelection(!historyButton.getSelection());
historyCombo.setEnabled(historyButton.getSelection());
if (historyButton.getSelection()) {
loadHistory();
}
validate();
}
});
Group historyLabelGroup = new Group(rightComposite, SWT.None);
historyLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 80));
historyLabelGroup.setLayout(new FillLayout());
Label historyLabel = new Label(historyLabelGroup, SWT.WRAP);
historyLabel.setText(Messages.lblImportHistory);
Composite historyComposite = new Composite(rightComposite, SWT.None);
historyComposite.setLayout(new GridLayout(3, false));
historyComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
historyCombo = new Combo(historyComposite, SWT.READ_ONLY);
historyCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
historyCombo.setEnabled(false);
historyCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
loadHistory();
final ImportConfigManager configManager = ImportConfigManager.getInstance();
renameButton = new Button(historyComposite, SWT.None);
renameButton.setText(Messages.btnRenameHistory);
renameButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
renameButton.setEnabled(false);
renameButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
String historyName = historyCombo.getText();
if (historyName == null || historyName.trim().length() == 0) {
return;
}
ImportConfig model = configManager.getConfig(historyName);
if (model == null) {
return;
}
InputDialog dialog = new InputDialog(getShell(), Messages.titleRenameDialog, Messages.descRenameDialog, historyName, new IInputValidator() {
public String isValid(String newText) {
if (newText == null || newText.trim().length() == 0) {
return Messages.msgRenamePleaseInputNewName;
}
if (configManager.getConfig(newText) != null) {
return Messages.msgRenameAlreadyExists;
}
return null;
}
});
if (dialog.open() == IDialogConstants.OK_ID) {
String newName = dialog.getValue();
model.setName(newName);
configManager.saveConfigs();
historyCombo.remove(historyName);
historyCombo.add(newName);
historyCombo.setText(newName);
}
}
});
deleteButton = new Button(historyComposite, SWT.None);
deleteButton.setText(Messages.btnDeleteHistory);
deleteButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (!CommonUITool.openConfirmBox(Messages.confirmDeleteImportHistory)) {
return;
}
boolean result = ImportConfigManager.getInstance().removeConfig(historyCombo.getText());
if (result) {
historyCombo.remove(historyCombo.getText());
validate();
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
});
}
}
use of org.eclipse.swt.layout.FormData in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method createQueryCompareTab.
private void createQueryCompareTab(CTabFolder tabFolder) {
CTabItem item = new CTabItem(tabFolder, SWT.None | SWT.MULTI | SWT.V_SCROLL);
item.setText(Messages.tabItemQueryCompare);
Composite composite = new Composite(tabFolder, SWT.None);
composite.setLayout(new GridLayout());
item.setControl(composite);
Composite topComposite = new Composite(composite, SWT.None);
topComposite.setLayout(new FormLayout());
topComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 25));
Composite leftTopComposite = new Composite(topComposite, SWT.None);
FormData leftTopData = new FormData();
leftTopData.top = new FormAttachment(0, 0);
leftTopData.bottom = new FormAttachment(100, 0);
leftTopData.left = new FormAttachment(0, 0);
leftTopData.right = new FormAttachment(50, 0);
leftTopComposite.setLayoutData(leftTopData);
leftTopComposite.setLayout(new GridLayout(2, false));
Composite rightTopComposite = new Composite(topComposite, SWT.None);
FormData rightTopData = new FormData();
rightTopData.top = new FormAttachment(0, 0);
rightTopData.bottom = new FormAttachment(100, 0);
rightTopData.left = new FormAttachment(50, 0);
rightTopData.right = new FormAttachment(100, 0);
rightTopComposite.setLayoutData(rightTopData);
rightTopComposite.setLayout(new GridLayout(5, false));
Label leftLabel = new Label(leftTopComposite, SWT.None);
leftLabel.setText(Messages.lblQuery);
leftLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
queryRecordLeftCombo = new Combo(leftTopComposite, SWT.READ_ONLY);
queryRecordLeftCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
queryRecordLeftCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Label rightLabel = new Label(rightTopComposite, SWT.None);
rightLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
rightLabel.setText(Messages.lblQuery);
queryRecordRightCombo = new Combo(rightTopComposite, SWT.READ_ONLY);
queryRecordRightCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
queryRecordRightCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
ToolBar leftToolBar = new ToolBar(rightTopComposite, SWT.None);
leftToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
compareItem = new ToolItem(leftToolBar, SWT.None);
compareItem.setImage(CommonUIPlugin.getImage("icons/action/refresh_tuning.png"));
compareItem.setToolTipText(Messages.itemTooltipCompare);
compareItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
});
delQueryRecordItem = new ToolItem(leftToolBar, SWT.None);
delQueryRecordItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
delQueryRecordItem.setToolTipText(Messages.itemTooltipRemoveQuery);
delQueryRecordItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (CommonUITool.openConfirmBox(Messages.confirmDeleteQueryPlanOnTuner)) {
removeQueryRecord();
}
}
});
Composite folderPlaceComposite = new Composite(rightTopComposite, SWT.None);
folderPlaceComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
ToolBar rightToolBar = new ToolBar(rightTopComposite, SWT.None);
rightToolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
multiRunItem = new ToolItem(rightToolBar, SWT.None);
multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
multiRunItem.setToolTipText(Messages.itemTooltipRunAgain);
multiRunItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
QueryRecord leftRecord = getSelectedLeftQueryRecord();
QueryRecord rightRecord = getSelectedRightQueryRecord();
if (leftRecord == null || rightRecord == null) {
CommonUITool.openErrorBox(Messages.errCompareQueryEmpty);
return;
}
runQueryPlanAgain(leftRecord.getQuery(), rightRecord.getQuery());
}
});
sqlModeItem = new ToolItem(rightToolBar, SWT.CHECK);
sqlModeItem.setImage(CommonUIPlugin.getImage("icons/queryplan/sql_compare.gif"));
sqlModeItem.setToolTipText(Messages.itemTooltipQuery);
sqlModeItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_SQL);
}
});
textModelItem = new ToolItem(rightToolBar, SWT.CHECK);
textModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
textModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
textModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TEXT);
}
});
treeModelItem = new ToolItem(rightToolBar, SWT.CHECK);
treeModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
treeModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
treeModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TREE);
}
});
graphModelItem = new ToolItem(rightToolBar, SWT.CHECK);
graphModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
graphModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
graphModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_GRAPH);
}
});
Composite tablesComposite = new Composite(composite, SWT.None);
tablesComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 60));
tablesComposite.setLayout(new FormLayout());
/*Left composite*/
Composite leftTableComposite = new Composite(tablesComposite, SWT.BORDER);
leftTableComposite.setLayout(new GridLayout());
FormData leftTableData = new FormData();
leftTableData.top = new FormAttachment(0, 0);
leftTableData.bottom = new FormAttachment(100, 0);
leftTableData.left = new FormAttachment(0, 0);
leftTableData.right = new FormAttachment(50, -2);
leftTableComposite.setLayoutData(leftTableData);
/*Right composite*/
Composite rightTableComposite = new Composite(tablesComposite, SWT.BORDER);
rightTableComposite.setLayout(new GridLayout());
FormData rightTabelData = new FormData();
rightTabelData.top = new FormAttachment(0, 0);
rightTabelData.bottom = new FormAttachment(100, 0);
rightTabelData.left = new FormAttachment(50, 2);
rightTabelData.right = new FormAttachment(100, 0);
rightTableComposite.setLayoutData(rightTabelData);
compareLeftTableViewer = new TableViewer(leftTableComposite, SWT.FULL_SELECTION);
compareLeftTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareLeftTableViewer.getTable().setHeaderVisible(true);
compareLeftTableViewer.getTable().setLinesVisible(false);
compareLeftTableViewer.setContentProvider(new QueryPlanContentProvider());
compareLeftTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareLeftTableViewer, false));
TableColumn fetchColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
fetchColumnLeft.setText(Messages.columnFetches);
fetchColumnLeft.setWidth(60);
TableColumn dirtyColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
dirtyColumnLeft.setText(Messages.columnDirties);
dirtyColumnLeft.setWidth(60);
TableColumn ioReadColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioReadColumnLeft.setText(Messages.columnIORead);
ioReadColumnLeft.setWidth(80);
TableColumn ioWriteColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioWriteColumnLeft.setText(Messages.columnIOWrite);
ioWriteColumnLeft.setWidth(80);
TableColumn costColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
costColumnLeft.setText(Messages.columnCost);
costColumnLeft.setWidth(60);
compareRightTableViewer = new TableViewer(rightTableComposite, SWT.FULL_SELECTION);
compareRightTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareRightTableViewer.getTable().setHeaderVisible(true);
compareRightTableViewer.getTable().setLinesVisible(false);
compareRightTableViewer.setContentProvider(new QueryPlanContentProvider());
compareRightTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareRightTableViewer, false));
TableColumn fetchColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
fetchColumnRight.setText(Messages.columnFetches);
fetchColumnRight.setWidth(60);
TableColumn dirtyColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
dirtyColumnRight.setText(Messages.columnDirties);
dirtyColumnRight.setWidth(60);
TableColumn ioReadColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioReadColumnRight.setText(Messages.columnIORead);
ioReadColumnRight.setWidth(80);
TableColumn ioWriteColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioWriteColumnRight.setText(Messages.columnIOWrite);
ioWriteColumnRight.setWidth(80);
TableColumn costColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
costColumnRight.setText(Messages.columnCost);
costColumnRight.setWidth(60);
queryPlanCompareSashForm = new SashForm(composite, SWT.VERTICAL);
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
queryPlanCompareSashForm.setBackground(SASH_COLOR);
queryPlanCompareSashForm.setLayout(new GridLayout());
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
Composite textMergeComposite = new Composite(queryPlanCompareSashForm, SWT.None);
textMergeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
textMergeComposite.setLayout(new FillLayout());
textMergeConfig = new CompareConfiguration();
textMergeConfig.setProperty(CompareConfiguration.SHOW_PSEUDO_CONFLICTS, Boolean.FALSE);
textMergeConfig.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.TRUE);
textMergeConfig.setLeftEditable(false);
textMergeConfig.setRightEditable(false);
textMergeViewer = new TextMergeViewer(textMergeComposite, SWT.BORDER, textMergeConfig);
DiffNode queryDiffNode = new DiffNode(null, Differencer.CHANGE, null, new TextCompareInput(""), new TextCompareInput(""));
textMergeViewer.setInput(queryDiffNode);
Composite compareQueryPlanComposite = new Composite(queryPlanCompareSashForm, SWT.None);
compareQueryPlanComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareQueryPlanComposite.setLayout(new FormLayout());
DatabaseInfo databaseInfo = database == null ? null : database.getDatabaseInfo();
leftComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 0);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 0);
leftData.right = new FormAttachment(50, 0);
leftComparePlanComposite.setLayoutData(leftData);
rightComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 0);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 0);
rightData.right = new FormAttachment(100, 0);
rightComparePlanComposite.setLayoutData(rightData);
queryPlanCompareSashForm.setWeights(new int[] { 100, 0 });
}
use of org.eclipse.swt.layout.FormData in project translationstudio8 by heartsome.
the class TSTitleAreaDialog method setLayoutsForNormalMessage.
/**
* Set the layout values for the messageLabel, messageImageLabel and
* fillerLabel for the case where there is a normal message.
*
* @param verticalSpacing
* int The spacing between widgets on the vertical axis.
* @param horizontalSpacing
* int The spacing between widgets on the horizontal axis.
*/
private void setLayoutsForNormalMessage(int verticalSpacing, int horizontalSpacing) {
FormData messageImageData = new FormData();
messageImageData.top = new FormAttachment(titleLabel, verticalSpacing);
messageImageData.left = new FormAttachment(0, H_GAP_IMAGE);
messageImageLabel.setLayoutData(messageImageData);
FormData messageLabelData = new FormData();
messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing);
messageLabelData.right = new FormAttachment(titleImageLabel);
messageLabelData.left = new FormAttachment(messageImageLabel, horizontalSpacing);
messageLabelData.height = messageLabelHeight;
if (titleImageLargest)
messageLabelData.bottom = new FormAttachment(titleImageLabel, 0, SWT.BOTTOM);
messageLabel.setLayoutData(messageLabelData);
FormData fillerData = new FormData();
fillerData.left = new FormAttachment(0, horizontalSpacing);
fillerData.top = new FormAttachment(messageImageLabel, 0);
fillerData.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM);
bottomFillerLabel.setLayoutData(fillerData);
FormData data = new FormData();
data.top = new FormAttachment(messageImageLabel, 0, SWT.TOP);
data.left = new FormAttachment(0, 0);
data.bottom = new FormAttachment(messageImageLabel, 0, SWT.BOTTOM);
data.right = new FormAttachment(messageImageLabel, 0);
leftFillerLabel.setLayoutData(data);
}
use of org.eclipse.swt.layout.FormData in project eclipse.platform.swt by eclipse.
the class BrowserExample method show.
void show(boolean owned, Point location, Point size, boolean addressBar, boolean menuBar, boolean statusBar, boolean toolBar) {
final Shell shell = browser.getShell();
if (owned) {
if (location != null)
shell.setLocation(location);
if (size != null)
shell.setSize(shell.computeSize(size.x, size.y));
}
FormData data = null;
if (toolBar) {
toolbar = new ToolBar(parent, SWT.NONE);
data = new FormData();
data.top = new FormAttachment(0, 5);
toolbar.setLayoutData(data);
itemBack = new ToolItem(toolbar, SWT.PUSH);
itemBack.setText(getResourceString("Back"));
itemForward = new ToolItem(toolbar, SWT.PUSH);
itemForward.setText(getResourceString("Forward"));
final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
itemStop.setText(getResourceString("Stop"));
final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
itemRefresh.setText(getResourceString("Refresh"));
final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
itemGo.setText(getResourceString("Go"));
itemBack.setEnabled(browser.isBackEnabled());
itemForward.setEnabled(browser.isForwardEnabled());
Listener listener = event -> {
ToolItem item = (ToolItem) event.widget;
if (item == itemBack)
browser.back();
else if (item == itemForward)
browser.forward();
else if (item == itemStop)
browser.stop();
else if (item == itemRefresh)
browser.refresh();
else if (item == itemGo)
browser.setUrl(locationBar.getText());
};
itemBack.addListener(SWT.Selection, listener);
itemForward.addListener(SWT.Selection, listener);
itemStop.addListener(SWT.Selection, listener);
itemRefresh.addListener(SWT.Selection, listener);
itemGo.addListener(SWT.Selection, listener);
canvas = new Canvas(parent, SWT.NO_BACKGROUND);
data = new FormData();
data.width = 24;
data.height = 24;
data.top = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
canvas.setLayoutData(data);
final Rectangle rect = images[0].getBounds();
canvas.addListener(SWT.Paint, e -> {
Point pt = ((Canvas) e.widget).getSize();
e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
});
canvas.addListener(SWT.MouseDown, e -> browser.setUrl(getResourceString("Startup")));
final Display display = parent.getDisplay();
display.asyncExec(new Runnable() {
@Override
public void run() {
if (canvas.isDisposed())
return;
if (busy) {
index++;
if (index == images.length)
index = 0;
canvas.redraw();
}
display.timerExec(150, this);
}
});
}
if (addressBar) {
locationBar = new Text(parent, SWT.BORDER);
data = new FormData();
if (toolbar != null) {
data.top = new FormAttachment(toolbar, 0, SWT.TOP);
data.left = new FormAttachment(toolbar, 5, SWT.RIGHT);
data.right = new FormAttachment(canvas, -5, SWT.DEFAULT);
} else {
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
}
locationBar.setLayoutData(data);
locationBar.addListener(SWT.DefaultSelection, e -> browser.setUrl(locationBar.getText()));
}
if (statusBar) {
status = new Label(parent, SWT.NONE);
progressBar = new ProgressBar(parent, SWT.NONE);
data = new FormData();
data.left = new FormAttachment(0, 5);
data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT);
data.bottom = new FormAttachment(100, -5);
status.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(100, -5);
data.bottom = new FormAttachment(100, -5);
progressBar.setLayoutData(data);
browser.addStatusTextListener(event -> status.setText(event.text));
}
parent.setLayout(new FormLayout());
Control aboveBrowser = toolBar ? (Control) canvas : (addressBar ? (Control) locationBar : null);
data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = aboveBrowser != null ? new FormAttachment(aboveBrowser, 5, SWT.DEFAULT) : new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = status != null ? new FormAttachment(status, -5, SWT.DEFAULT) : new FormAttachment(100, 0);
browser.setLayoutData(data);
if (statusBar || toolBar) {
browser.addProgressListener(new ProgressListener() {
@Override
public void changed(ProgressEvent event) {
if (event.total == 0)
return;
int ratio = event.current * 100 / event.total;
if (progressBar != null)
progressBar.setSelection(ratio);
busy = event.current != event.total;
if (!busy) {
index = 0;
if (canvas != null)
canvas.redraw();
}
}
@Override
public void completed(ProgressEvent event) {
if (progressBar != null)
progressBar.setSelection(0);
busy = false;
index = 0;
if (canvas != null) {
itemBack.setEnabled(browser.isBackEnabled());
itemForward.setEnabled(browser.isForwardEnabled());
canvas.redraw();
}
}
});
}
if (addressBar || statusBar || toolBar) {
browser.addLocationListener(LocationListener.changedAdapter(event -> {
busy = true;
if (event.top && locationBar != null)
locationBar.setText(event.location);
}));
}
if (title) {
browser.addTitleListener(event -> shell.setText(event.title + " - " + getResourceString("window.title")));
}
parent.layout(true);
if (owned)
shell.open();
}
Aggregations