use of org.eclipse.swt.custom.SashForm in project MonjaDB by Kanatoko.
the class MActionView method init2.
//--------------------------------------------------------------------------------
public void init2() {
parent.setLayout(new FormLayout());
sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
FormData fd_sashForm1 = new FormData();
fd_sashForm1.top = new FormAttachment(0, 1);
fd_sashForm1.left = new FormAttachment(0, 1);
fd_sashForm1.right = new FormAttachment(100, -1);
fd_sashForm1.bottom = new FormAttachment(100, -1);
sashForm.setLayoutData(fd_sashForm1);
table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
onTableStateChange();
}
});
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == 13) {
e.doit = false;
if (//Shift + Enter
(e.stateMask & SWT.SHIFT) != 0) {
repeatActionsOnTable();
} else {
editActions();
}
}
}
});
FormData fd_table = new FormData();
fd_table.top = new FormAttachment(0, 0);
fd_table.bottom = new FormAttachment(100, 0);
fd_table.left = new FormAttachment(0, 0);
fd_table.right = new FormAttachment(100, 0);
table.setLayoutData(fd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn actionColumn = new TableColumn(table, SWT.NONE);
actionColumn.setWidth(100);
actionColumn.setText("Action");
TableColumn dateColumn = new TableColumn(table, SWT.NONE);
dateColumn.setWidth(100);
dateColumn.setText("Date");
editorComposite = new Composite(sashForm, SWT.BORDER);
editorComposite.setLayout(new FormLayout());
text = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
onTextStateChange();
}
});
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(100, -40);
fd_text.right = new FormAttachment(100);
fd_text.top = new FormAttachment(0);
fd_text.left = new FormAttachment(0);
text.setLayoutData(fd_text);
executeButton = new Button(editorComposite, SWT.NONE);
executeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
executeActionsOnText();
}
});
executeButton.setEnabled(false);
FormData fd_executeButton = new FormData();
fd_executeButton.top = new FormAttachment(text, 6);
fd_executeButton.left = new FormAttachment(text, -120, SWT.RIGHT);
fd_executeButton.right = new FormAttachment(100, -10);
executeButton.setLayoutData(fd_executeButton);
executeButton.setText("Execute");
editorComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
onSashResize();
}
});
MSwtUtil.getTableColumnWidthFromProperties("actionListTable", table, prop, new int[] { 200, 100 });
MSwtUtil.addListenerToTableColumns2(table, this);
//table.addListener( SWT.KeyDown, this );
table.addListener(SWT.MouseDoubleClick, this);
menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(table);
table.setMenu(contextMenu);
//executeTableAction
{
redoAction = new Action() {
public void run() {
//------------
repeatActionsOnTable();
}
};
//------------
redoAction.setToolTipText("Redo Selected Actions");
redoAction.setText("Redo\tShift+Enter");
initAction(redoAction, "table_go.png", menuManager);
redoAction.setEnabled(false);
}
//editAction
{
editAction = new Action() {
public void run() {
//------------
editActions();
}
};
//------------
editAction.setToolTipText("Edit Actions on The Text Editor");
editAction.setText("Edit\tEnter");
initAction(editAction, "pencil.png", menuManager);
editAction.setEnabled(false);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//executeAction
{
executeAction = new Action() {
public void run() {
//------------
executeActionsOnText();
}
};
//------------
executeAction.setToolTipText("Execute Actions on the Textarea");
executeAction.setText("Execute");
setActionImage(executeAction, "bullet_go.png");
addActionToToolBar(executeAction);
executeAction.setEnabled(false);
dropDownMenu.add(executeAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//copyAction
{
copyAction = new Action() {
public void run() {
//------------
copyActions();
}
};
//------------
copyAction.setToolTipText("Copy Actions to Clipboard");
copyAction.setText("Copy");
setActionImage(copyAction, "page_copy.png");
addActionToToolBar(copyAction);
copyAction.setEnabled(false);
dropDownMenu.add(copyAction);
menuManager.add(copyAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//clearAction
{
clearAction = new Action() {
public void run() {
//------------
clearActions();
}
};
//------------
clearAction.setToolTipText("Clear All");
clearAction.setText("Clear All");
initAction(clearAction, "table_delete.png", menuManager);
clearAction.setEnabled(false);
}
//saveAction
{
saveAction = new Action() {
public void run() {
//------------
saveActions();
}
};
//------------
saveAction.setToolTipText("Save Action");
saveAction.setText("Save");
initAction(saveAction, "cog_add.png", menuManager);
saveAction.setEnabled(false);
}
//load actionLogList
if (prop.containsKey(ACTION_LOG_LIST)) {
String savedStr = prop.getProperty(ACTION_LOG_LIST);
actionLogList = (java.util.List) JSON.parse(savedStr);
for (int i = 0; i < actionLogList.size(); ++i) {
Map actionLog = (Map) actionLogList.get(i);
addActionToTable(actionLog);
}
} else {
actionLogList = new LinkedList();
}
if (prop.containsKey(ACTIONLOG_COMPOSITE_WEIGHT)) {
(new Thread() {
public void run() {
MSystemUtil.sleep(0);
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
//----
sashForm.setWeights(prop.getIntArrayProperty(ACTIONLOG_COMPOSITE_WEIGHT));
}
});
//----
}
}).start();
} else {
sashForm.setWeights(new int[] { 70, 30 });
}
initializedTime = System.currentTimeMillis();
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class ColumnViewerSorter 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.tablesDetailInfoPartRefreshBtn);
refreshItem.setToolTipText(Messages.tablesDetailInfoPartBtnRefreshTip);
refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
refreshItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
refresh();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem countItem = new ToolItem(toolBar, SWT.PUSH);
countItem.setText(Messages.tablesDetailInfoPartBtnEsitmateRecord);
countItem.setToolTipText(Messages.tablesDetailInfoPartBtnEsitmateRecordTip);
countItem.setImage(CommonUIPlugin.getImage("icons/action/count.gif"));
countItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
List<TableDetailInfo> list = new ArrayList<TableDetailInfo>();
TableItem[] items = tableListView.getTable().getSelection();
for (TableItem item : items) {
list.add((TableDetailInfo) item.getData());
}
// Check selected size and confirm
if (list.size() == 0) {
CommonUITool.openWarningBox(Messages.tablesDetailInfoPartAlertNotSelected);
return;
}
if (CommonUITool.openConfirmBox(Messages.tablesDetailInfoPartBtnEsitmateRecordAlert)) {
LoadTableRecordCountsProgress progress = new LoadTableRecordCountsProgress(database, list);
progress.getTableCounts();
tableListView.refresh();
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem viewDataItem = new ToolItem(toolBar, SWT.PUSH);
viewDataItem.setText(Messages.tablesDetailInfoPartBtnViewData);
viewDataItem.setToolTipText(Messages.tablesDetailInfoPartBtnViewDataTip);
viewDataItem.setImage(CommonUIPlugin.getImage("icons/action/table_select_all.png"));
viewDataItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = tableListView.getTable().getSelection();
if (items.length == 1) {
TableDetailInfo tableDetailInfo = (TableDetailInfo) items[0].getData();
String query = SQLGenerateUtils.getSelectSQLWithLimit(tableDetailInfo.getTableName(), 1, 100);
QueryEditorUtil.openQueryEditorAndRunQuery(database, query, true, true);
} else {
CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnViewDataSelectOne);
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem copyTableNamesItem = new ToolItem(toolBar, SWT.PUSH);
copyTableNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyTableNames);
copyTableNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyTableNamesTip);
copyTableNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_table_name.gif"));
copyTableNamesItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
List<String> nameList = new ArrayList<String>();
for (TableDetailInfo tablesDetailInfoPOJO : tableList) {
nameList.add(tablesDetailInfoPOJO.getTableName());
}
if (nameList.size() == 0) {
CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
return;
}
copyNamesToClipboard(nameList);
CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem copyColumnNamesItem = new ToolItem(toolBar, SWT.PUSH);
copyColumnNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyColumnNames);
copyColumnNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyColumnNamesTip);
copyColumnNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_column_name.gif"));
copyColumnNamesItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TablesDetailInfoCTabItem tabItem = (TablesDetailInfoCTabItem) tabFolder.getSelection();
schemaInfo = tabItem.getTableInfoComposite().getData();
if (schemaInfo == null) {
CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
return;
}
List<String> nameList = new ArrayList<String>();
for (DBAttribute att : schemaInfo.getAttributes()) {
nameList.add(att.getName());
}
copyNamesToClipboard(nameList);
CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
final NewTableAction newTableAction = (NewTableAction) ActionManager.getInstance().getAction(NewTableAction.ID);
ToolItem newTableItem = new ToolItem(toolBar, SWT.PUSH);
newTableItem.setText(newTableAction.getText());
newTableItem.setImage(CommonUITool.getImage(newTableAction.getImageDescriptor()));
newTableItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
newTableAction.run(database);
}
});
ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComp.setLayout(new FillLayout());
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
topSash = new SashForm(scrolledComp, SWT.VERTICAL);
topSash.setBackground(ResourceManager.getColor(136, 161, 227));
GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
topSash.setLayout(gridLayout);
topSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
topSash.SASH_WIDTH = 1;
scrolledComp.setContent(topSash);
createTablesDetailInfoTable(topSash);
createTabFolder(topSash);
topSash.setWeights(new int[] { 70, 30 });
this.setInputs();
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class TableDashboardComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
SashForm bottomSash = new SashForm(tabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = 2;
bottomSash.setBackground(BACK_COLOR);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = 2;
tailSash.setBackground(BACK_COLOR);
Composite tableComp = new Composite(tailSash, SWT.NONE);
tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
tableComp.setLayout(new GridLayout());
createColumnsTable(tableComp);
tabItem = new TablesDetailInfoCTabItem(tabFolder, SWT.NONE, this);
tabItem.setControl(bottomSash);
tabItem.setShowClose(true);
tabFolder.setSelection(tabItem);
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method initialize.
/**
* Initializing a Plan Tab
*/
private void initialize() {
createPlanToolbar();
//create the plan tab folder and history sash
plansHistorySash = new SashForm(this, SWT.HORIZONTAL);
plansHistorySash.setLayout(new GridLayout(2, true));
plansHistorySash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
//create left plan tab folder
plansTabFolder = new CTabFolder(plansHistorySash, SWT.BOTTOM | SWT.CLOSE);
plansTabFolder.setSimple(false);
plansTabFolder.setUnselectedImageVisible(true);
plansTabFolder.setUnselectedCloseVisible(true);
plansTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
plansTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
plansTabFolder.setLayout(new GridLayout(1, true));
plansTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(plansTabFolder);
tabContextMenuManager.createContextMenu();
//create the right plan history table
planHistoryTable = new Table(plansHistorySash, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
planHistoryTable.setLayout(new GridLayout(1, true));
planHistoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
planHistoryTable.setHeaderVisible(true);
planHistoryTable.setLinesVisible(true);
planHistoryTable.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent event) {
int selectionIndex = planHistoryTable.getSelectionIndex();
if (selectionIndex < 0) {
return;
}
TableItem tableItem = planHistoryTable.getItem(planHistoryTable.getSelectionIndex());
if (tableItem == null) {
return;
}
int uid = Integer.valueOf(tableItem.getText(0));
StructQueryPlan sq = planHistoryList.get(uid - 1);
PlanTabItem tabItem = findPlanTab(uid);
if (tabItem == null) {
tabItem = newPlanTab(uid);
}
plansTabFolder.setSelection(tabItem);
printPlan(tabItem, sq);
}
public void mouseDown(MouseEvent event) {
}
public void mouseUp(MouseEvent event) {
}
});
int i = 0;
planHistoryTblCols[i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// No
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col1);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(20);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Date
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col2);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(100);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col4);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(90);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col3);
planHistoryTblCols[i].setMoveable(false);
planHistoryTblCols[i].setWidth(90);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
sashPlanWeight = new int[] { 80, 20 };
plansHistorySash.setWeights(sashPlanWeight);
newPlanTab(1);
plansTabFolder.setSelection(0);
hideHistoryPane();
refreshToolbarStatus(QueryOptions.getQueryPlanDisplayType());
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
Composite toolBarComposite = new Composite(this, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 10;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.numColumns = 2;
toolBarComposite.setLayout(gridLayout);
toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
delHistory.setText(Messages.btn_qedit_sql_history_delete);
delHistory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
return;
}
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
messageBox.setMessage(Messages.sql_history_delete_message);
// remove data ,both view and model
int buttonID = messageBox.open();
if (buttonID == SWT.YES) {
deleteHistory();
}
}
});
// help messages
Label helpMsg = new Label(toolBarComposite, SWT.None);
helpMsg.setText(Messages.recentlyUsedSQLHelp);
helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
// create the query result tab folder
recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
recentlyUsedSQLTabFolder.setSimple(false);
recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
//tabContextMenuManager.createContextMenu();
recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
recentlyUsedSQLTabItem.setControl(this);
recentlyUsedSQLTabItem.setShowClose(false);
final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = SASH_WIDTH;
bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
createHistoryTable(bottomSash);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
bottomSash.setWeights(new int[] { 80, 20 });
logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
logMessageArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
bottomSash.setWeights(new int[] { 80, 20 });
}
public void focusGained(FocusEvent e) {
bottomSash.setWeights(new int[] { 20, 80 });
}
});
CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
tabItem.setText(Messages.qedit_sql_history);
tabItem.setControl(bottomSash);
tabItem.setShowClose(false);
recentlyUsedSQLTabFolder.setSelection(tabItem);
}
Aggregations