use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class RenameHostDialog 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.lblName);
GridData data = new GridData();
data.widthHint = 60;
data.horizontalSpan = 1;
data.verticalSpan = 1;
label1.setLayoutData(data);
newNameText = new Text(composite, SWT.BORDER);
data = new GridData();
data.horizontalSpan = 2;
data.verticalSpan = 1;
data.grabExcessHorizontalSpace = true;
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
newNameText.setLayoutData(data);
newNameText.setText(server.getName());
newNameText.selectAll();
newNameText.setFocus();
newNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(false);
if (!valid()) {
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
newNameText.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
if (e.type == SWT.KeyDown && e.character == SWT.CR) {
buttonPressed(IDialogConstants.OK_ID);
}
}
});
setTitle(Messages.bind(Messages.renameMSGTitle, server.getName()));
setMessage(Messages.bind(Messages.renameDialogMSG, server.getName()));
return parent;
}
use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method createTable.
private void createTable(Composite composite) {
hostListView = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
hostListView.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (isExport) {
valid();
}
}
});
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.horizontalSpan = 3;
gdColumnsTable.heightHint = 189;
hostListView.getTable().setLayoutData(gdColumnsTable);
hostListView.getTable().setLinesVisible(true);
hostListView.getTable().setHeaderVisible(true);
final TableColumn hostName = new TableColumn(hostListView.getTable(), SWT.NONE);
hostName.setAlignment(SWT.LEFT);
hostName.setWidth(WIDTH_NAME);
hostName.setText(Messages.columnHeaderServerInfo);
if (isExport) {
hostName.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
} else {
hostName.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
}
hostName.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
selectAll = !selectAll;
hostListView.setAllChecked(selectAll);
Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
hostName.setImage(image);
hostListView.refresh();
if (isExport) {
valid();
}
}
});
final TableColumn hostAddress = new TableColumn(hostListView.getTable(), SWT.NONE);
hostAddress.setAlignment(SWT.CENTER);
hostAddress.setWidth(WIDTH_ADDRESS);
hostAddress.setText(Messages.columnHeaderServerAddress);
final TableColumn hostPort = new TableColumn(hostListView.getTable(), SWT.NONE);
hostPort.setAlignment(SWT.CENTER);
hostPort.setWidth(WIDTH_PORT);
hostPort.setText(Messages.columnHeaderServerPort);
final TableColumn jdbcVer = new TableColumn(hostListView.getTable(), SWT.NONE);
jdbcVer.setAlignment(SWT.CENTER);
jdbcVer.setWidth(WIDTH_JDBC);
jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
final TableColumn hostUser = new TableColumn(hostListView.getTable(), SWT.NONE);
hostUser.setAlignment(SWT.CENTER);
hostUser.setWidth(WIDTH_USER);
hostUser.setText(Messages.columnHeaderServerUserName);
// final TableColumn savedPass = new TableColumn(hostListView.getTable(), SWT.NONE);
// savedPass.setAlignment(SWT.CENTER);
// savedPass.setWidth(WIDTH_SAVEPASS);
// savedPass.setText(Messages.columnHeaderServerAutoSave);
hostListView.setContentProvider(new ServerInfoTableViewerContentProvider());
hostListView.setLabelProvider(new ServerInfoTableViewerLabelProvider());
if (isExport) {
initExportTableData();
}
}
use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createCubridCMConfTabItem.
/**
* create cubrid CM table
*/
public void createCubridCMConfTabItem() {
Composite comp = new Composite(confTabFolder, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
comp.setLayout(new GridLayout(1, false));
cubridCMConfTableCTabItem = new CTabItem(confTabFolder, SWT.NONE);
cubridCMConfTableCTabItem.setText("cm.conf");
cubridCMConfTabTableViewer = new TableViewer(comp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
cubridCMConfTabTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
cubridCMConfTabTableViewer.getTable().setHeaderVisible(true);
cubridCMConfTabTableViewer.getTable().setLinesVisible(true);
cubridCMConfTabTableViewer.setUseHashlookup(true);
//create column
TableViewerColumn column = new TableViewerColumn(cubridCMConfTabTableViewer, SWT.LEFT);
column.getColumn().setWidth(0);
column.getColumn().setText("");
cubridCMConfTabTableViewer.setContentProvider(new UnifyHostCubridCMConfTableContentProvider());
cubridCMConfTabTableViewer.setLabelProvider(new UnifyHostCubridCMConfTableLabelProvider());
//use to mark click point, the right click menu use this point
cubridCMConfTabTableViewer.getTable().addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
cubridCMConfTableClickPoint = new Point(event.x, event.y);
cubridCMConfTableClickPointTiming = System.currentTimeMillis();
}
});
registerCubridCMConfTableContextMenu();
cubridCMConfTableCTabItem.setControl(comp);
if (confTabFolder.getSelection() == null) {
confTabFolder.setSelection(cubridCMConfTableCTabItem);
}
}
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();
}
Aggregations