use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class AddTableFileDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
Label lblImportFile = new Label(composite, SWT.NONE);
lblImportFile.setText(Messages.importFileNameLBL);
lblImportFile.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
fileNameTxt = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
fileNameTxt.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Button btnOpen = new Button(composite, SWT.NONE);
btnOpen.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
btnOpen.setText(Messages.btnBrowse);
btnOpen.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String fileName = openFileDialog(fileNameTxt.getText());
fileNameTxt.setText(fileName);
openFile();
fillInFromList();
validate();
}
});
Composite mappingComposite = new Composite(composite, SWT.None);
mappingComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
mappingComposite.setLayout(new GridLayout());
Label lblMappingMessage = new Label(mappingComposite, SWT.NONE);
{
lblMappingMessage.setText(Messages.lblImportMapping);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
lblMappingMessage.setLayoutData(gridData);
}
firstRowAsColumnBtn = new Button(mappingComposite, SWT.CHECK);
{
firstRowAsColumnBtn.setText(Messages.btnFirstAsColumn);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 10;
firstRowAsColumnBtn.setLayoutData(gridData);
firstRowAsColumnBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleSelectEventForFirstRowAsColBtn();
}
});
}
sashForm = new SashForm(mappingComposite, SWT.NONE);
{
sashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
createFromComposite();
createToComposte();
}
init();
return composite;
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class DBAuthComparator method createPartControl.
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, false));
ToolBar toolBar = new ToolBar(parent, SWT.LEFT_TO_RIGHT | SWT.FLAT);
toolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
refreshItem.setText(Messages.btnRefresh);
refreshItem.setToolTipText(Messages.btnRefresh);
refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
refreshItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
refresh();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem addUserItem = new ToolItem(toolBar, SWT.NONE);
addUserItem.setText(Messages.btnAddUser);
addUserItem.setImage(CommonUIPlugin.getImage("icons/action/user_add.png"));
addUserItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addUser();
}
});
ToolItem editUserItem = new ToolItem(toolBar, SWT.NONE);
editUserItem.setText(Messages.btnEditUser);
editUserItem.setImage(CommonUIPlugin.getImage("icons/action/user_edit.png"));
editUserItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
editUser();
}
});
ToolItem dropUserItem = new ToolItem(toolBar, SWT.NONE);
dropUserItem.setText(Messages.btnDropUser);
dropUserItem.setImage(CommonUIPlugin.getImage("icons/action/user_delete.png"));
dropUserItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
dropUser();
}
});
SashForm form = new SashForm(parent, SWT.HORIZONTAL);
form.setLayout(new FillLayout());
form.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
createUsersTable(form);
createAuthTable(form);
form.setWeights(new int[] { 150, 850 });
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class MultiDBQueryComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
Composite toolBarComposite = new Composite(this, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 10;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
toolBarComposite.setLayout(gridLayout);
toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar toolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
toolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
ToolItem refreshToolItem = new ToolItem(toolBar, SWT.PUSH);
refreshToolItem.setText(Messages.lblItemRefreshMulti);
refreshToolItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
refreshToolItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
refreshToolItem.setToolTipText(Messages.refresh);
refreshToolItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//refresh may set tree to group type or not
//so mark the select db then set it to checked after set input
// Object[] checkedObject = ctv.getCheckedElements();
setInput();
// for (Object o : checkedObject) {
// if (o instanceof CubridDatabase) {
// ctv.setChecked(o, true);
// }
// }
// refresh(editor.getSelectedDatabase());
}
});
runItem = new ToolItem(toolBar, SWT.PUSH);
runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
runItem.setText(Messages.lblItemRunMulti);
runItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editor.runMultiQuery();
}
});
Label lblNotice = new Label(toolBarComposite, SWT.None);
lblNotice.setText(Messages.qedit_multiDBQueryComp_noticeToolbarMsg);
lblNotice.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
// create the query result tab folder
multiDBQueryCompTabFolder = new CTabFolder(this, SWT.BOTTOM);
multiDBQueryCompTabFolder.setSimple(false);
multiDBQueryCompTabFolder.setUnselectedImageVisible(true);
multiDBQueryCompTabFolder.setUnselectedCloseVisible(true);
multiDBQueryCompTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
multiDBQueryCompTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
multiDBQueryCompTabFolder.setLayout(new GridLayout(1, true));
multiDBQueryCompTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(multiDBQueryCompTabFolder);
//tabContextMenuManager.createContextMenu();
multiDBQueryCompTabItem = new CTabItem(resultTabFolder, SWT.NONE);
multiDBQueryCompTabItem.setText(Messages.qedit_multiDBQueryComp_folder);
multiDBQueryCompTabItem.setControl(this);
multiDBQueryCompTabItem.setShowClose(false);
SashForm bottomSash = new SashForm(multiDBQueryCompTabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = SASH_WIDTH;
bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
Composite treeComp = new Composite(tailSash, SWT.NONE);
{
treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
treeComp.setLayout(new GridLayout());
}
ctv = new ContainerCheckedTreeViewer(treeComp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ctv.getControl().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
ctv.setContentProvider(new MultiDBQueryTreeContentProvider());
ctv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (lastSelectedTime != 0 && lastSelectedTime > System.currentTimeMillis()) {
ctv.setChecked(event.getElement(), true);
return;
}
ctv.setChecked(event.getElement(), false);
lastSelectedTime = System.currentTimeMillis() + 100;
if (getQueryDatabaseList().size() > 0 && editor.getAllQueries().trim().length() != 0) {
editor.setMultiQueryRunItemStatus(true);
} else if (getQueryDatabaseList().size() == 0) {
editor.setMultiQueryRunItemStatus(false);
}
//if (!event.getChecked()) {
selectedNodes.remove(event.getElement());
if (event.getElement() instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) event.getElement();
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
//ctv.setChecked(event.getElement(), false);
selectedNodes.remove(database);
} else {
if (database.getData(INDEXKEY) == null) {
database.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
}
} else if (event.getElement() instanceof CubridServer) {
CubridServer serverNode = (CubridServer) event.getElement();
for (ICubridNode dbFolderNode : serverNode.getChildren()) {
for (ICubridNode dbNode : dbFolderNode.getChildren()) {
if (dbNode instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) dbNode;
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
//ctv.setChecked(dbNode, false);
selectedNodes.remove(database);
} else if (ctv.getChecked(dbNode)) {
ctv.setChecked(dbNode, true);
if (dbNode.getData(INDEXKEY) == null) {
dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
} else {
ctv.setChecked(dbNode, true);
}
}
}
//only has one db folder so first time break it
break;
}
} else if (event.getElement() instanceof ICubridNode) {
ICubridNode node = (ICubridNode) event.getElement();
if (node.getType().equals(NodeType.DATABASE_FOLDER)) {
for (ICubridNode dbNode : node.getChildren()) {
if (dbNode instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) dbNode;
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
ctv.setChecked(dbNode, false);
} else if (ctv.getChecked(dbNode)) {
ctv.setChecked(dbNode, true);
if (dbNode.getData(INDEXKEY) == null) {
dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
} else {
ctv.setChecked(dbNode, false);
}
}
}
}
// else if (node.getType().equals(NodeType.GROUP)) {
// for (ICubridNode childNode : node.getChildren()) {
// //CQB tree
// if(childNode instanceof CubridDatabase) {
// CubridDatabase database = (CubridDatabase) childNode;
// if (database.getRunningType() == DbRunningType.STANDALONE
// || !database.isLogined()) {
// if (childNode.getData(INDEXKEY) == null) {
// childNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
// }
// }
// continue;
// }
// //CM tree
// for (ICubridNode dbFolderNode : childNode.getChildren()) {
// for (ICubridNode dbNode : dbFolderNode.getChildren()) {
// if(dbNode instanceof CubridDatabase) {
// CubridDatabase database = (CubridDatabase) dbNode;
// if (database.getRunningType() == DbRunningType.STANDALONE
// || !database.isLogined()) {
// ctv.setChecked(dbNode, false);
// } else if (ctv.getChecked(dbNode)) {
// ctv.setChecked(dbNode, true);
// if (dbNode.getData(INDEXKEY) == null) {
// dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
// }
// } else {
// ctv.setChecked(dbNode, false);
// }
// }
// }
// }
// //only has one db folder so first time break it
// break;
// }
// }
}
ctv.refresh();
}
});
ctv.getTree().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent event) {
//mac can't drag and drop,so support copy and paste db node
if (((event.stateMask & SWT.CTRL) != 0) || ((event.stateMask & SWT.COMMAND) != 0) && event.keyCode == 'v') {
final Clipboard cb = new Clipboard(getShell().getDisplay());
String plainText = (String) cb.getContents(TextTransfer.getInstance());
String[] databaseNameArray = plainText.split(",");
selectedNodes.addAll(getDatabaseNode(databaseNameArray));
setInput();
}
}
});
// ctv.addDoubleClickListener(LayoutManager.getInstance());
// ctv.addTreeListener(new ITreeViewerListener() {
// public void treeCollapsed(TreeExpansionEvent event) {
// CommonTool.clearExpandedElements(ctv);
// }
//
// public void treeExpanded(TreeExpansionEvent event) {
// CommonTool.clearExpandedElements(ctv);
// }
// });
final Tree tableTree = ctv.getTree();
tableTree.setHeaderVisible(true);
tableTree.setLinesVisible(true);
final TreeViewerColumn dbCol = new TreeViewerColumn(ctv, SWT.NONE);
dbCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
dbCol.getColumn().setWidth(250);
dbCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_dbCol);
final TreeViewerColumn indexCol = new TreeViewerColumn(ctv, SWT.NONE);
indexCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
indexCol.getColumn().setWidth(50);
indexCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_indexCol);
indexCol.setEditingSupport(new EditingSupport(ctv) {
TextCellEditor textCellEditor;
protected boolean canEdit(Object element) {
if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
if (node.getType() == NodeType.DATABASE) {
CubridDatabase database = (CubridDatabase) element;
if ((database.getRunningType() == DbRunningType.CS && database.isLogined())) {
return true;
}
}
}
return false;
}
protected CellEditor getCellEditor(Object element) {
if (textCellEditor == null) {
textCellEditor = new TextCellEditor(ctv.getTree());
textCellEditor.setValidator(new IndexCellEditorValidator());
textCellEditor.addListener(new ICellEditorListener() {
public void applyEditorValue() {
}
public void cancelEditor() {
}
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
}
});
}
return textCellEditor;
}
protected Object getValue(Object element) {
final ICubridNode node = (ICubridNode) element;
String index = (String) node.getData(INDEXKEY);
if (index == null) {
return "";
} else {
return index;
}
}
protected void setValue(Object element, Object value) {
if (value == null) {
return;
}
try {
Integer.valueOf((String) value);
} catch (Exception e) {
return;
}
final ICubridNode node = (ICubridNode) element;
node.setData(INDEXKEY, value);
// setAllParentExpandOrCollapse(node.getParent(), true);
ctv.refresh();
}
/**
* MyCellEditorValidator
*
* @author fulei
*
*/
class IndexCellEditorValidator implements ICellEditorValidator {
/**
* isValid
*
* @param value Object
* @return String
*/
public String isValid(Object value) {
try {
Integer.valueOf((String) value);
} catch (Exception e) {
CommonUITool.openErrorBox(Messages.qedit_multiDBQueryComp_tree_indexErr);
return Messages.qedit_multiDBQueryComp_tree_indexErr;
}
return null;
}
}
});
final TreeViewerColumn commentCol = new TreeViewerColumn(ctv, SWT.NONE);
commentCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
commentCol.getColumn().setWidth(200);
commentCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_commentCol);
CTabItem tabItem = new CTabItem(multiDBQueryCompTabFolder, SWT.NONE);
tabItem.setText(Messages.qedit_multiDBQueryComp_tabItem);
tabItem.setControl(bottomSash);
tabItem.setShowClose(false);
setInput();
// HostNodePersistManager.getInstance().getAllServer();
multiDBQueryCompTabFolder.setSelection(tabItem);
dragController = new MultiDBQueryDNDController(this, ctv);
dragController.registerDropTarget();
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class ObjectInfoComposite method initIndexTabItem.
/**
* Initial index tab index
*
*/
private void initIndexTabItem() {
CubridDatabase database = schemaNode.getDatabase();
CTabItem indexTabItem = new CTabItem(objInfoFolder, SWT.NONE);
indexTabItem.setText(Messages.titleIndex);
indexTabItem.setShowClose(false);
Composite composite = new Composite(objInfoFolder, SWT.None);
indexTabItem.setControl(composite);
composite.setLayout(new FillLayout());
final SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
sashForm.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
/*Index table composite*/
Composite indexComposite = new Composite(sashForm, SWT.None);
indexComposite.setLayout(new GridLayout());
/*FK table composite*/
Composite fkComposite = new Composite(sashForm, SWT.None);
fkComposite.setLayout(new GridLayout());
/*Set the sashform*/
sashForm.setWeights(new int[] { 1, 1 });
// create index table view
final Label indexLabel = new Label(indexComposite, SWT.NONE);
indexLabel.setText(Messages.lblIndexes);
indexTableViewer = new TableViewer(indexComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
Table indexTable = indexTableViewer.getTable();
indexTable.setLinesVisible(true);
indexTable.setHeaderVisible(true);
indexTable.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
TableColumn tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(150);
tblCol.setText(Messages.tblColumnIndexName);
TableColumn indexNameColumn = new TableColumn(indexTable, SWT.NONE);
indexNameColumn.setWidth(78);
indexNameColumn.setText(Messages.tblColumnIndexType);
TableColumn indexTypeColumn = new TableColumn(indexTable, SWT.NONE);
indexTypeColumn.setWidth(218);
indexTypeColumn.setText(Messages.tblColumnOnColumns);
TableColumn ruleColumn = new TableColumn(indexTable, SWT.NONE);
ruleColumn.setWidth(282);
ruleColumn.setText(Messages.tblColumnIndexRule);
IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
indexTableViewer.setContentProvider(indexContentProvider);
indexTableViewer.setLabelProvider(indexLabelProvider);
// create the fk table viewer
final Label fkLabel = new Label(fkComposite, SWT.NONE);
fkLabel.setText(Messages.lblFK);
fkTableViewer = new TableViewer(fkComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
Table fkTable = fkTableViewer.getTable();
fkTable.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
fkTable.setLinesVisible(true);
fkTable.setHeaderVisible(true);
TableColumn fkNameColumn = new TableColumn(fkTable, SWT.NONE);
fkNameColumn.setWidth(100);
fkNameColumn.setText(Messages.tblColumnFK);
TableColumn fkColumnName = new TableColumn(fkTable, SWT.NONE);
fkColumnName.setWidth(119);
fkColumnName.setText(Messages.tblColumnColumnName);
TableColumn fTableColumn = new TableColumn(fkTable, SWT.NONE);
fTableColumn.setWidth(93);
fTableColumn.setText(Messages.tblColumnForeignTable);
TableColumn fkColumnNameColumn = new TableColumn(fkTable, SWT.NONE);
fkColumnNameColumn.setWidth(143);
fkColumnNameColumn.setText(Messages.tblColumnForeignColumnName);
TableColumn updateRuletblColumn = new TableColumn(fkTable, SWT.NONE);
updateRuletblColumn.setWidth(84);
updateRuletblColumn.setText(Messages.tblColumnUpdateRule);
TableColumn deleteRuleColumn = new TableColumn(fkTable, SWT.NONE);
deleteRuleColumn.setWidth(86);
deleteRuleColumn.setText(Messages.tblColumnDeleteRule);
TableColumn cacheColumn = new TableColumn(fkTable, SWT.NONE);
cacheColumn.setWidth(100);
cacheColumn.setText(Messages.tblColumnCacheColumn);
fkTableViewer.setContentProvider(new FKTableViewerContentProvider());
fkTableViewer.setLabelProvider(new FKTableViewerLabelProvider(database.getDatabaseInfo()));
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class CombinedQueryEditorComposite method createTopSash.
/**
* Create the top sash for SQL editor and query result
*/
private void createTopSash() {
Composite topComp = new Composite(this, SWT.NONE);
topComp.setLayout(new FillLayout());
topSash = new SashForm(topComp, SWT.VERTICAL);
topSash.setBackground(SASH_COLOR);
topSash.setLayout(new FillLayout());
/* set top sash width to 0, the black line (topSash's background) won't be display
* set the normal width when change the editor database(there's no better way to set width)
* for TOOLS-2375
*/
topSash.setSashWidth(0);
Composite sqlEditorParentComp = createSQLEditor(topSash);
createResultFolder(topSash, sqlEditorParentComp);
topSash.setWeights(new int[] { QUERY_EDITOR_TOP_PCT, QUERY_EDITOR_BOTTOM_PCT });
}
Aggregations