use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class AddQueryRecordDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area 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 = 3;
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);
Label label1 = new Label(composite, SWT.LEFT);
label1.setText(Messages.lblQueryName);
label1.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
String queryPlanName = Messages.lblQueryTuningName + " ";
if (newFlag) {
queryPlanName += QueryRecord.DATE_FORMAT.format(new Date());
} else {
queryPlanName += queryRecord.getTimeStamp();
}
newText = new Text(composite, SWT.BORDER);
newText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
newText.setText(queryPlanName);
newText.selectAll();
newText.setFocus();
newText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
validate();
}
});
newText.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
if (e.type == SWT.KeyDown && e.character == SWT.CR) {
buttonPressed(IDialogConstants.OK_ID);
}
}
});
if (newFlag) {
setTitle(Messages.subTitleAddQueryRecord);
} else {
String msg = Messages.bind(Messages.subTitleRenameQueryRecord, queryRecord.getName());
setTitle(msg);
}
return parent;
}
use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class ParamDumpResultDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area 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.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.numColumns = 5;
composite.setLayout(layout);
//dynamicHelp end
createdbNameGroup(composite);
table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
table.setHeaderVisible(true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 7;
gridData.verticalSpan = 10;
gridData.heightHint = 300;
table.setLayoutData(gridData);
table.setLinesVisible(true);
CommonUITool.hackForYosemite(table);
/*
* // fill in context menu
*/
Menu menu = new Menu(parent.getShell(), SWT.POP_UP);
table.setMenu(menu);
MenuItem copy = new MenuItem(menu, SWT.PUSH);
copy.setText(Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.contextCopy, "Ctrl+C"));
copy.setAccelerator(SWT.CTRL + 'C');
copy.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
StringBuilder content = new StringBuilder();
TableItem[] items = table.getSelection();
for (int i = 0; i < items.length; i++) {
content.append(items[i].getText(0) + blank + items[i].getText(1) + blank + items[i].getText(2) + blank + System.getProperty("line.separator"));
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
});
table.addKeyListener(new org.eclipse.swt.events.KeyAdapter() {
public void keyPressed(org.eclipse.swt.events.KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
StringBuilder content = new StringBuilder();
TableItem[] items = table.getSelection();
for (int i = 0; i < items.length; i++) {
content.append(items[i].getText(0) + blank + items[i].getText(1) + blank + items[i].getText(2) + blank + System.getProperty("line.separator"));
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
}
});
setTitle(Messages.titleParamDumpDialog);
setMessage(Messages.msgParamDumpDialog);
initial();
return parentComp;
}
use of org.eclipse.swt.widgets.Listener 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.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class ERSchemaToolBar method createDropDownComp.
/**
* create drop down composite
*
* @return comp composite
*/
private Composite createDropDownComp() {
Composite comp = new Composite(this, SWT.LEFT_TO_RIGHT);
final GridLayout gdLayout = new GridLayout(2, false);
gdLayout.marginHeight = 0;
gdLayout.marginWidth = 0;
gdLayout.horizontalSpacing = -1;
gdLayout.verticalSpacing = 0;
comp.setLayout(gdLayout);
comp.setLayoutData(new GridData(SWT.END, SWT.FILL, true, false));
selectModelLabel = new CLabel(comp, SWT.CENTER | SWT.SHADOW_OUT);
selectModelLabel.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
dropDownButton = new Button(comp, SWT.FLAT | SWT.ARROW | SWT.DOWN);
dropDownButton.setLayoutData(CommonUITool.createGridData(1, 1, 20, -1));
dropDownButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
handleSelectionEvent();
}
});
return comp;
}
use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class QueryExecuter method createContextMenuItems.
private void createContextMenuItems() {
Menu menu = new Menu(queryEditor.getEditorSite().getShell(), SWT.POP_UP);
final MenuItem itemInsert = new MenuItem(menu, SWT.PUSH);
itemInsert.setText(Messages.insertRecord);
itemInsert.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!getEditable()) {
CommonUITool.openErrorBox(Display.getDefault().getActiveShell(), Messages.errNotEditable);
return;
}
insertSaveItem.setEnabled(getEditable());
rollbackModifiedItem.setEnabled(getEditable());
addNewItem();
}
});
final MenuItem itemCopy = new MenuItem(menu, SWT.PUSH);
itemCopy.setText(Messages.copyClipBoard);
final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
itemDelete.setText(Messages.delete);
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem itemDetail = new MenuItem(menu, SWT.PUSH);
itemDetail.setText(Messages.detailView);
itemDetail.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<Point> selectedList = selectableSupport.getSelectedLocations();
Point location = selectedList.get(0);
if (location == null) {
CommonUITool.openErrorBox(Messages.errShowDetailFailed);
return;
}
//Bug fixed by Kevin.Qian. FYI. allDataList is a global query result to the current query.
int pageBeginIndex = (queryInfo.getCurrentPage() - 1) * queryInfo.getPageSize();
Map<String, CellValue> map = allDataList.get(pageBeginIndex + location.y);
TableItem item = tblResult.getItem(location.y);
ColumnInfo colInfo = allColumnList.get(location.x - 1);
RowDetailDialog dialog = new RowDetailDialog(tblResult.getShell(), allColumnList, map, item, colInfo.getName(), executer);
dialog.open();
}
});
tblResult.setMenu(menu);
tblResult.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
// Point pt = new Point(event.x, event.y);
// itemOid.setEnabled(false);
int index = tblResult.getSelectionIndex();
int count = tblResult.getItemCount();
if (index < 0 || index >= count) {
return;
}
// final TableItem item = tblResult.getItem(index);
// for (int i = 0; i < tblResult.getColumnCount(); i++) {
// Rectangle rect = item.getBounds(i);
// if (rect.contains(pt)) {
// selColumnName = tblResult.getColumn(i).getText();
//// Object value = item.getData(i + "");
//// String text = item.getText(i);
//// if (!DataType.VALUE_NULL.equals(value) && containsOIDs(tblResult.getColumn(i).getText())
//// && !DataType.VALUE_NONE.equals(text)) {
//// itemOid.setEnabled(true);
//// } else {
//// itemOid.setEnabled(false);
//// }
//
// }
// }
}
});
final MenuItem itemExportAll = new MenuItem(menu, SWT.PUSH);
itemExportAll.setText(Messages.allExport);
final MenuItem itemExportSelection = new MenuItem(menu, SWT.PUSH);
itemExportSelection.setText(Messages.selectExport);
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem itemMakeInsertQuery = new MenuItem(menu, SWT.PUSH);
itemMakeInsertQuery.setText(Messages.makeInsertFromSelectedRecord);
itemMakeInsertQuery.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_insert.png"));
final MenuItem itemMakeUpdateQuery = new MenuItem(menu, SWT.PUSH);
itemMakeUpdateQuery.setText(Messages.makeUpdateFromSelectedRecord);
itemMakeUpdateQuery.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_update.png"));
if (isEmpty()) {
itemExportAll.setEnabled(false);
itemExportSelection.setEnabled(false);
itemDetail.setEnabled(false);
}
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
List<Point> selectedList = selectableSupport.getSelectedLocations();
TableItem[] tblItems = selectableSupport.getSelectedTableItems();
boolean selectedCol = selectableSupport.hasSelected();
boolean enableItemDetail = (selectedList != null && selectedList.size() == 1);
itemExportSelection.setEnabled(selectedCol);
itemCopy.setEnabled(selectedCol);
if (allDataList.size() > 0) {
itemExportAll.setEnabled(true);
} else {
itemExportAll.setEnabled(false);
}
if (executer.getQueryEditor() != null && executer.getQueryEditor().getDatabaseInfo() != null && executer.getQueryEditor().getDatabaseInfo().equals(executer.getDatabaseInfo())) {
itemInsert.setEnabled(isEditMode());
itemDetail.setEnabled(enableItemDetail);
itemDelete.setEnabled(getEditable() && isEditMode());
} else {
itemInsert.setEnabled(false);
itemDetail.setEnabled(false);
itemDelete.setEnabled(false);
}
for (int i = 0; i < tblItems.length; i++) {
if (isEditMode() && getEditable() && tblItems[i].getText(1).equals(DataType.VALUE_NONE)) {
itemDelete.setEnabled(false);
}
}
}
});
itemCopy.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copySelectedItems();
}
});
itemCopy.setAccelerator(SWT.CTRL + 'c');
itemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (isEditMode()) {
deleteRecord(tblResult, null);
}
}
});
itemExportAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ExportResultDialog dialog = new ExportResultDialog(tblResult.getShell(), database, Messages.msgExportAllResults);
if (IDialogConstants.OK_ID == dialog.open()) {
ExportQueryResultTaskExecutor task = new ExportQueryResultTaskExecutor(dialog.getFile(), dialog.getFileCharset(), allColumnList, allDataList, false);
new ExecTaskWithProgress(task).exec();
}
}
});
// itemOid.addSelectionListener(new SelectionAdapter() {
// /**
// * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
// * @param event an event containing information about the
// * selection
// */
// public void widgetSelected(SelectionEvent event) {
// openOidNavigator(button2Position);
// }
//
// });
itemExportSelection.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ExportResultDialog dialog = new ExportResultDialog(tblResult.getShell(), database, Messages.msgExportSelectedResults);
if (IDialogConstants.OK_ID == dialog.open()) {
ExportQueryResultTaskExecutor task = new ExportQueryResultTaskExecutor(dialog.getFile(), dialog.getFileCharset(), tblResult, selectableSupport.getSelectedTableItems(), false);
new ExecTaskWithProgress(task).exec();
}
}
});
itemMakeInsertQuery.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String text = makeInsertQueryWithSelectedRecords();
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
itemMakeUpdateQuery.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String text = makeUpdateQueryWithSelectedRecords();
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
Aggregations