use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class TableDashboardComposite method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
columnTableView.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(columnTableView.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(columnTableView.getTable());
columnTableView.getTable().setMenu(contextMenu);
Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
final MenuItem itemShowMuchValue = new MenuItem(menu, SWT.PUSH);
itemShowMuchValue.setText(com.cubrid.common.ui.cubrid.table.Messages.tablesDetailInfoPartMenuCopy);
itemShowMuchValue.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copyTablesDetailToClipboard();
}
});
columnTableView.getTable().setMenu(menu);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class FocusAction method setFocusProvider.
/**
*
* Set focus provider
*
* @param focusProvider the focus provider
*/
public final void setFocusProvider(Control focusProvider) {
if (focusProvider != null && !focusProvider.isDisposed()) {
if (control != null && !control.isDisposed()) {
control.removeFocusListener(this);
}
control = focusProvider;
control.addFocusListener(this);
if (control.isFocusControl()) {
Event event = new Event();
event.widget = control;
focusGained(new FocusEvent(event));
}
}
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class FocusAction method changeActionStatus.
/**
*
* Change the focus provider and change action status
*
* @param action FocusAction
* @param focusProvider Control
*/
public static void changeActionStatus(IAction action, Control focusProvider) {
if (action instanceof IFocusAction) {
IFocusAction focusAction = (IFocusAction) action;
focusAction.setFocusProvider(focusProvider);
if (!focusProvider.isFocusControl()) {
Event event = new Event();
event.widget = focusProvider;
focusAction.focusGained(new FocusEvent(event));
}
}
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method displayQuery.
/**
* Display the query data
*
* @param queryRecord
*/
private void displayQuery(final QueryRecord queryRecord) {
if (queryResultComposite != null && !queryResultComposite.isDisposed()) {
queryResultComposite.dispose();
}
queryResultComposite = new Composite(queryResultContainer, SWT.None);
queryResultComposite.setLayout(new FillLayout());
ViewForm viewForm = new ViewForm(queryResultComposite, SWT.NONE);
viewForm.setLayout(new FillLayout());
final SashForm tableLogSash = new SashForm(viewForm, SWT.VERTICAL);
tableLogSash.SASH_WIDTH = SASH_WIDTH;
tableLogSash.setBackground(BACK_COLOR);
/*Create table view*/
final TableViewer resultTableViewer = new TableViewer(tableLogSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
TableCursor cursor = new TableCursor(resultTableViewer.getTable(), SWT.NONE);
TableSelectSupport tableSelectSupport = new TableSelectSupport(resultTableViewer.getTable(), cursor);
String fontString = QueryOptions.getFontString(database.getDatabaseInfo().getServerInfo());
Font tmpFont = ResourceManager.getFont(fontString);
if (tmpFont == null) {
String[] fontData = QueryOptions.getDefaultFont();
tmpFont = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
Font font = tmpFont;
resultTableViewer.getTable().setFont(font);
int[] fontColor = QueryOptions.getFontColor(database.getDatabaseInfo().getServerInfo());
Color color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
resultTableViewer.getTable().setForeground(color);
/*Set font and foreground*/
tableSelectSupport.getTableCursor().setFont(font);
tableSelectSupport.getTableCursor().setForeground(color);
final SashForm logSash = new SashForm(tableLogSash, SWT.HORIZONTAL);
logSash.SASH_WIDTH = SASH_WIDTH;
logSash.setBackground(BACK_COLOR);
logSash.setLayout(new FillLayout());
StyledText messagesArea = new StyledText(logSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
messagesArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
messagesArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
tableLogSash.setWeights(new int[] { 8, 2 });
}
public void focusGained(FocusEvent e) {
tableLogSash.setWeights(new int[] { 2, 8 });
}
});
tableLogSash.setWeights(new int[] { 8, 2 });
viewForm.setContent(tableLogSash);
resultTableViewer.getTable().setHeaderVisible(true);
resultTableViewer.getTable().setLinesVisible(true);
if (queryRecord != null) {
QueryResultLabelProvider labelProvider = new QueryResultLabelProvider(queryRecord);
QueryResultContentProvider contentProvider = new QueryResultContentProvider();
resultTableViewer.setLabelProvider(labelProvider);
resultTableViewer.setContentProvider(contentProvider);
createResultColumn(resultTableViewer, queryRecord);
resultTableViewer.setInput(queryRecord.getPageData());
setQueryMessage(messagesArea, queryRecord);
}
CommonUITool.packTable(resultTableViewer.getTable(), 10, 150);
queryResultContainer.layout();
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class TableConfigCellEditor method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
sqlFileTableViewer.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(sqlFileTableViewer.getTable());
}
});
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem addSchemaItem = new MenuItem(menu, SWT.PUSH);
addSchemaItem.setText(Messages.btnAddSchemaFile);
addSchemaItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addFile(TableConfig.TYPE_SCHEMA);
}
});
final MenuItem addDataItem = new MenuItem(menu, SWT.PUSH);
addDataItem.setText(Messages.btnAddDataFile);
addDataItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addFile(TableConfig.TYPE_DATA);
}
});
final MenuItem addIndexItem = new MenuItem(menu, SWT.PUSH);
addIndexItem.setText(Messages.btnAddIndexFile);
addIndexItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addFile(TableConfig.TYPE_INDEX);
}
});
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem delItem = new MenuItem(menu, SWT.PUSH);
delItem.setText(Messages.btnDelFiles);
delItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteSelectedFile();
}
});
menu.addMenuListener(new MenuListener() {
public void menuHidden(org.eclipse.swt.events.MenuEvent e) {
}
public void menuShown(org.eclipse.swt.events.MenuEvent e) {
delItem.setEnabled(delCanEnable());
}
});
sqlFileTableViewer.getTable().setMenu(menu);
}
Aggregations