use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class LogEditorPart method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
* @param parent the parent control
* @see IWorkbenchPart
*/
public void createPartControl(Composite parent) {
final Composite compositeLog = new Composite(parent, SWT.NONE);
{
GridLayout gridLayoutLog = new GridLayout();
gridLayoutLog.verticalSpacing = 0;
gridLayoutLog.marginWidth = 0;
gridLayoutLog.marginHeight = 0;
gridLayoutLog.horizontalSpacing = 5;
gridLayoutLog.numColumns = 8;
compositeLog.setLayout(gridLayoutLog);
}
final String type = this.cubridNode.getType();
table = new Table(compositeLog, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
{
table.setHeaderVisible(true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 8;
gridData.verticalSpan = 10;
gridData.heightHint = 600;
table.setLayoutData(gridData);
table.setLinesVisible(true);
}
// fill in context menu
if (CubridNodeType.BROKER_SQL_LOG.equals(type) || CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
//Create the context menu
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
buildPopupMenu(manager, type);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(table);
table.setMenu(contextMenu);
//Add listener
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
copyDataToClipboard(type);
}
}
});
}
table.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
if (CubridNodeType.BROKER_SQL_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(1);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
} else if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(4);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
} else if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(6);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
}
}
});
// add bottom composite for page
Label labelCharset = new Label(compositeLog, SWT.NONE);
{
labelCharset.setText(Messages.labelCharset);
charsetCombo = new Combo(compositeLog, SWT.BORDER);
final GridData gdCharsetText = CommonUITool.createGridData(1, 1, -1, -1);
charsetCombo.setLayoutData(gdCharsetText);
charsetCombo.setItems(QueryOptions.getAllCharset(null));
charsetCombo.setText(charsetName);
}
Button viewLogBtn = new Button(compositeLog, SWT.NONE);
{
viewLogBtn.setText(Messages.viewLogJobName);
viewLogBtn.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
viewLogBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String charsetName = charsetCombo.getText();
try {
"".getBytes(charsetName);
} catch (UnsupportedEncodingException e) {
CommonUITool.openErrorBox(Messages.errCharset);
charsetCombo.setFocus();
return;
}
setCharsetName(charsetName);
if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
connect(false);
}
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
managerConnect();
updateManagerLogTable();
}
}
});
}
// page button
if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
pageText = new Text(compositeLog, SWT.BORDER);
{
pageText.setVisible(true);
pageText.setEditable(false);
GridData gridData = createPageBtnGridData(150);
gridData.grabExcessHorizontalSpace = true;
pageText.setLayoutData(gridData);
}
buttonFirst = new Button(compositeLog, SWT.NONE);
{
buttonFirst.setVisible(true);
buttonFirst.setText("|<");
buttonFirst.setLayoutData(createPageBtnGridData(60));
buttonFirst.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart = 1;
lineEnd = 100;
connect(false);
}
});
}
buttonPrev = new Button(compositeLog, SWT.NONE);
{
buttonPrev.setVisible(true);
buttonPrev.setText("<");
buttonPrev.setLayoutData(createPageBtnGridData(60));
buttonPrev.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart -= 100;
if (lineStart < 1) {
lineStart = 1;
}
lineEnd = lineStart + 99;
connect(false);
}
});
}
buttonNext = new Button(compositeLog, SWT.NONE);
{
buttonNext.setVisible(true);
buttonNext.setText(">");
buttonNext.setLayoutData(createPageBtnGridData(60));
buttonNext.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart += 100;
if (lineStart > lineTot) {
lineStart = lineTot;
}
lineEnd = lineStart + 99;
if (lineEnd > lineTot) {
lineEnd = lineTot;
}
connect(false);
}
});
}
buttonEnd = new Button(compositeLog, SWT.NONE);
{
buttonEnd.setVisible(true);
buttonEnd.setText(">|");
buttonEnd.setLayoutData(createPageBtnGridData(60));
buttonEnd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineEnd = lineTot;
lineStart = lineEnd - lineTot % 100 + 1;
connect(false);
}
});
}
}
// manager log page button
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
pageText = new Text(compositeLog, SWT.BORDER);
{
pageText.setVisible(true);
pageText.setEditable(false);
GridData gridData = createPageBtnGridData(150);
gridData.grabExcessHorizontalSpace = true;
pageText.setLayoutData(gridData);
}
buttonFirst = new Button(compositeLog, SWT.NONE);
buttonFirst.setVisible(true);
buttonFirst.setText("|<");
buttonFirst.setLayoutData(createPageBtnGridData(60));
buttonFirst.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(1);
updateManagerLogTable();
}
});
buttonPrev = new Button(compositeLog, SWT.NONE);
buttonPrev.setVisible(true);
buttonPrev.setText("<");
buttonPrev.setLayoutData(createPageBtnGridData(60));
buttonPrev.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getCurrentPage() - 1);
updateManagerLogTable();
}
});
buttonNext = new Button(compositeLog, SWT.NONE);
buttonNext.setVisible(true);
buttonNext.setText(">");
buttonNext.setLayoutData(createPageBtnGridData(60));
buttonNext.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getCurrentPage() + 1);
updateManagerLogTable();
}
});
buttonEnd = new Button(compositeLog, SWT.NONE);
buttonEnd.setVisible(true);
buttonEnd.setText(">|");
buttonEnd.setLayoutData(createPageBtnGridData(60));
buttonEnd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getPages());
updateManagerLogTable();
}
});
}
compositeLog.pack();
}
use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class ImportResultDialog method createDialogArea.
/**
* Create the dialog area
*
* @param parent Composite
* @return Control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
{
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
}
TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
table = tableViewer.getTable();
{
GridData gdData = new GridData(GridData.FILL_BOTH);
gdData.heightHint = 400;
gdData.widthHint = 500;
table.setLayoutData(gdData);
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText(Messages.importColumnNO);
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText(Messages.importColumnMessage);
tableViewer.setLabelProvider(new TableLabelProvider(tableViewer, null));
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setInput(errorList);
//Create the context menu
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
//copy action
Action copyAction = new Action(Messages.bind(Messages.contextCopy, "Ctrl+C")) {
public void run() {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
copyDataToClipboard();
}
});
}
};
manager.add(copyAction);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(table);
table.setMenu(contextMenu);
//Add listener
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
copyDataToClipboard();
}
}
});
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn tblColumn = table.getColumn(i);
tblColumn.pack();
if (tblColumn.getWidth() > 400) {
tblColumn.setWidth(400);
}
}
Label label = new Label(composite, SWT.LEFT);
label.setForeground(ResourceManager.getColor(255, 0, 0));
label.setText(message);
return composite;
}
use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class SchemaInfoEditorPart method createContextMenu.
/**
*
* Create the context menu
*
* @param control Control
*/
private void createContextMenu(final Control control) {
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
ISelectionProvider provider = ActionManager.getInstance().getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
TreeViewer viewer = (TreeViewer) provider;
viewer.setSelection(new StructuredSelection(schemaNode), true);
viewer.getTree().setFocus();
MenuProvider menuProvider = new MenuProvider();
String type = schemaNode.getType();
if (NodeType.SYSTEM_TABLE.equals(type)) {
menuProvider.buildSystemTableMenu(manager);
} else if (NodeType.SYSTEM_VIEW.equals(type)) {
menuProvider.buildSystemViewMenu(manager);
} else if (NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
menuProvider.buildUserTableMenu(manager, schemaNode);
} else if (NodeType.USER_PARTITIONED_TABLE.equals(type)) {
menuProvider.buildPartitionedTableMenu(manager);
} else if (NodeType.USER_TABLE.equals(type)) {
menuProvider.buildUserTableMenu(manager, schemaNode);
} else if (NodeType.USER_VIEW.equals(type)) {
menuProvider.buildUserViewMenu(manager);
}
manager.remove(ShowSchemaEditorAction.ID);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(control);
control.setMenu(contextMenu);
}
use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method setupContextMenu.
private void setupContextMenu(final Tree tree) {
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
// IAction showSchemaAction = ActionManager.getInstance().getAction(ShowSchemaAction.ID);
// if (showSchemaAction != null) {
// manager.add(showSchemaAction);
//
// showSchemaAction.setEnabled(false);
// if (DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(editor.getSelectedDatabase().getId())) {
// return;
// }
//
// if (editor.getSelectedDatabase().getDatabaseInfo() == null) {
// return;
// }
//
// if (tree.getSelection() != null && tree.getSelection().length > 0) {
// String tname = tree.getSelection()[0].getText(1);
// if (tname == null || tname.length() == 0) {
// return;
// }
//
// int ep = tname.indexOf(' ');
// if (ep != -1) {
// tname = tname.substring(0, ep);
// }
// editor.setCurrentSchemaName(tname);
// if (tname != null) {
// showSchemaAction.setEnabled(true);
// }
// }
// }
}
});
Menu contextMenu = menuManager.createContextMenu(tree);
tree.setMenu(contextMenu);
}
use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class MenuProvider method buildUserTableMenu.
/**
* Construct user table related actions
*
* @param manager the parent IMenuManager
* @param node The ICubridNode object
*/
public void buildUserTableMenu(IMenuManager manager, ICubridNode node) {
DatabaseInfo dbInfo = ((ISchemaNode) node).getDatabase().getDatabaseInfo();
// SELECT GROUP
IMenuManager selectSqlMenu = new MenuManager(Messages.lblMakeSelectQueryGrp);
manager.add(selectSqlMenu);
// SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectQueryAction.ID));
// Parameterized SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectPstmtQueryAction.ID));
// Parameterized INSERT
addActionToManager(manager, getAction(MakeInsertQueryAction.ID));
// Parameterized UPDATE
addActionToManager(manager, getAction(MakeUpdateQueryAction.ID));
// Parameterized DELETE
addActionToManager(manager, getAction(MakeDeleteQueryAction.ID));
// CREATE GROUP
IMenuManager createSqlMenu = new MenuManager(Messages.lblMakeCreateQueryGrp);
manager.add(createSqlMenu);
addActionToManager(createSqlMenu, getAction(MakeCreateQueryAction.ID));
addActionToManager(createSqlMenu, getAction(MakeCloneQueryAction.ID));
manager.add(new Separator());
// Schema to Code Actions
addActionToManager(manager, getAction(TableToJavaCodeAction.ID));
addActionToManager(manager, getAction(TableToPhpCodeAction.ID));
addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
manager.add(new Separator());
// Install Schema Comment
addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
manager.add(new Separator());
// View data
IMenuManager viewDataMenu = new MenuManager(Messages.viewDataMenuName);
manager.add(viewDataMenu);
addActionToManager(viewDataMenu, getAction(TableSelectAllAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByOnePstmtDataAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByMultiPstmtDataAction.ID));
viewDataMenu.add(new Separator());
addActionToManager(viewDataMenu, getAction(TableSelectCountAction.ID));
// Input data
IMenuManager inputDataMenu = new MenuManager(Messages.inputDataMenuName);
manager.add(inputDataMenu);
addActionToManager(inputDataMenu, getAction(InsertOneByPstmtAction.ID));
addActionToManager(inputDataMenu, getAction(ImportDataFromFileAction.ID));
// addActionToManager(manager, getAction(RunSQLFileAction.ID));
manager.add(new Separator());
// Export & Import Actions
addActionToManager(manager, getAction(ExportWizardAction.ID));
addActionToManager(manager, getAction(ImportWizardAction.ID));
manager.add(new Separator());
// Manage table
addActionToManager(manager, getAction(EditTableAction.ID));
IAction renameTableAction = getAction(RenameTableAction.ID);
renameTableAction.setText(com.cubrid.common.ui.spi.Messages.tableRenameActionName);
renameTableAction.setImageDescriptor(CommonUIPlugin.getImageDescriptor("icons/action/table_rename.png"));
addActionToManager(manager, renameTableAction);
IMenuManager moreMenu = new MenuManager(Messages.tableMoreName);
addActionToManager(moreMenu, getAction(DeleteTableAction.ID));
IAction action = getAction(DeleteTableAction.ID);
if (CompatibleUtil.isSupportTruncateTable(dbInfo)) {
if (action != null) {
action.setText(Messages.deleteAllRecordsActionName);
}
addActionToManager(moreMenu, getAction(TruncateTableAction.ID));
} else {
if (action != null) {
action.setText(Messages.tableDeleteAllActionName);
}
}
IAction tableDropAction = getAction(DropTableAction.ID);
addActionToManager(moreMenu, tableDropAction);
moreMenu.add(new Separator());
if (CompatibleUtil.isSupportCreateTableLike(dbInfo)) {
addActionToManager(moreMenu, getAction(CreateLikeTableAction.ID));
}
manager.add(moreMenu);
}
Aggregations