use of org.eclipse.swt.events.FocusAdapter in project cubrid-manager by CUBRID.
the class AddHADatabaseDialog method createDialogArea.
/**
* Create dialog area content
*
* @param parent the parent composite
* @return the control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
{
GridLayout compLayout = new GridLayout();
compLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
compLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
compLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
compLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(compLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
}
Group cmServerInfoGroup = new Group(composite, SWT.NONE);
cmServerInfoGroup.setText(Messages.grpHostInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
cmServerInfoGroup.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
cmServerInfoGroup.setLayout(layout);
Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
ipLabel.setText(Messages.lblIPAddress);
ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
ipCombo = new Combo(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
ipCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
portNameLabel.setText(Messages.lblPort);
portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
portText.setTextLimit(5);
portText.setText("8001");
portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
portText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
portText.selectAll();
portText.setFocus();
}
});
Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
userNameLabel.setText(Messages.lblUserName);
userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
userNameText.setText("admin");
userNameText.setEnabled(false);
userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
passwordLabel.setText(Messages.lblPassword);
passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
passwordText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
passwordText.selectAll();
passwordText.setFocus();
}
});
Label dbNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
dbNameLabel.setText(Messages.lblDbName);
dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
dbNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Label dbaPasswordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
dbaPasswordLabel.setText(Messages.lblDbaPassword);
dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbaPasswordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Composite btnComposite = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
btnComposite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
btnComposite.setLayoutData(gridData);
addDatabaseButton = new Button(btnComposite, SWT.NONE);
addDatabaseButton.setText(Messages.btnAddDb);
addDatabaseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//check this database whether already be added
String dbName = dbNameText.getText();
if (isDbExist()) {
setErrorMessage(Messages.bind(Messages.errDbExist, dbName));
return;
}
//connect server
String address = ipCombo.getText();
String port = portText.getText();
String userName = userNameText.getText();
String password = passwordText.getText();
ServerInfo serverInfo = ServerManager.getInstance().getServer(address, Integer.parseInt(port), userName);
if (serverInfo == null) {
serverInfo = new ServerInfo();
serverInfo.setServerName(address);
serverInfo.setHostAddress(address);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
}
String dbaPassword = dbaPasswordText.getText();
TaskExecutor executor = null;
VerifyDbUserPasswordTask verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
verifyDbUserPasswordTask.setDbName(dbName);
verifyDbUserPasswordTask.setDbUser("dba");
verifyDbUserPasswordTask.setDbPassword(dbaPassword);
if (serverInfo.isConnected()) {
DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
if (dbInfo == null) {
setErrorMessage(Messages.errDbNoExist);
return;
}
executor = new CommonTaskExec(null);
if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
String pwd = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (!dbaPassword.equals(pwd)) {
CommonUITool.openErrorBox(Messages.errDbaPassowrd);
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
return;
}
} else {
executor.addTask(verifyDbUserPasswordTask);
}
} else {
executor = new ConnectHostExecutor(getShell(), serverInfo, true);
executor.addTask(verifyDbUserPasswordTask);
}
//get this database status
HAHostStatusInfo haHostStatusInfo = null;
HADatabaseStatusInfo haDbStatusInfo = null;
GetDbModeTask getDbModeTask = new GetDbModeTask(serverInfo);
List<String> dbList = new ArrayList<String>();
dbList.add(dbNameText.getText());
getDbModeTask.setDbList(dbList);
executor.addTask(getDbModeTask);
new ExecTaskWithProgress(executor).exec(true, true);
if (!executor.isSuccess()) {
if (verifyDbUserPasswordTask != null && verifyDbUserPasswordTask.getErrorMsg() != null && verifyDbUserPasswordTask.getErrorMsg().length() > 0) {
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
}
return;
}
if (getDbModeTask.getDbModes() != null && getDbModeTask.getDbModes().size() > 0) {
List<HADatabaseStatusInfo> dbModeList = getDbModeTask.getDbModes();
haDbStatusInfo = dbModeList.get(0);
haHostStatusInfo = getHAHostStatusInfo(serverInfo.getHostAddress());
if (haHostStatusInfo != null) {
haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
}
}
if (haDbStatusInfo == null) {
haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbNameText.getText(), haHostStatusInfo, serverInfo);
}
if (haHostStatusInfo == null) {
haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
}
DatabaseNode dbNode = new DatabaseNode();
dbNode.setDbName(dbNameText.getText());
dbNode.setDbUser("dba");
dbNode.setDbPassword(dbaPassword);
dbNode.setName(dbNameText.getText());
dbNode.setConnected(true);
dbNode.setHaDatabaseStatus(haDbStatusInfo);
HostNode hostNode = new HostNode();
hostNode.setName(ipCombo.getText() + ":" + portText.getText());
hostNode.setIp(ipCombo.getText());
hostNode.setPort(portText.getText());
hostNode.setUserName(userNameText.getText());
hostNode.setPassword(passwordText.getText());
hostNode.setHostStatusInfo(haHostStatusInfo);
hostNode.setConnected(true);
dbNode.setParent(hostNode);
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", dbNode.getDbName());
map.put("1", DBStatusType.getShowText(dbNode.getDbStatusType()));
map.put("2", dbNode.getParent().getIp());
map.put("3", dbNode.getParent().getPort());
map.put("4", HostStatusType.getShowText(haHostStatusInfo.getStatusType()));
map.put("5", dbNode);
if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
dbNodeList.add(0, map);
} else {
dbNodeList.add(map);
}
dbTableViewer.refresh();
for (int i = 0; i < dbTable.getColumnCount(); i++) {
dbTable.getColumn(i).pack();
}
verify();
}
});
addDatabaseButton.setEnabled(false);
createTable(composite);
setTitle(Messages.titleAddHADbDialog);
initial();
return parentComp;
}
use of org.eclipse.swt.events.FocusAdapter in project tdi-studio-se by Talend.
the class TextNotePropertySection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
FormData data;
//$NON-NLS-1$
text = getWidgetFactory().createText(composite, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
data = new FormData();
data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
// 5 lines
data.height = 5 * text.getLineHeight();
text.setLayoutData(data);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("TextNoteSection.Label"));
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(text, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(text, 0, SWT.TOP);
labelLabel.setLayoutData(data);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (!text.getText().equals(note.getText())) {
ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
getCommandStack().execute(command);
}
}
});
}
use of org.eclipse.swt.events.FocusAdapter in project tdi-studio-se by Talend.
the class ImportItemWizardPage method createItemRoot.
private void createItemRoot(Composite workArea) {
Composite projectGroup = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 0;
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
itemFromDirectoryRadio = new Button(projectGroup, SWT.RADIO);
// itemFromDirectoryRadio.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
//$NON-NLS-1$
itemFromDirectoryRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_RootSelectTitle"));
this.directoryPathField = new Text(projectGroup, SWT.BORDER);
this.directoryPathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
// browseDirectoriesButton.setText(DataTransferMessages.DataTransfer_browse);
//$NON-NLS-1$
browseDirectoriesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
setButtonLayoutData(browseDirectoriesButton);
nothing = new Label(projectGroup, SWT.NONE);
//$NON-NLS-1$
nothing.setText(" ");
// new project from archive radio button
itemFromArchiveRadio = new Button(projectGroup, SWT.RADIO);
// itemFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
//$NON-NLS-1$
itemFromArchiveRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle"));
// project location entry field
archivePathField = new Text(projectGroup, SWT.BORDER);
archivePathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
// browse button
// Composite buttonCom = new Composite(projectGroup, SWT.NONE);
// GridLayout buttonlayout = new GridLayout();
// buttonlayout.numColumns = 2;
// buttonlayout.makeColumnsEqualWidth = false;
// buttonlayout.marginWidth = 0;
// buttonCom.setLayout(buttonlayout);
// buttonCom.setLayoutData(new GridData());
browseArchivesButton = new Button(projectGroup, SWT.PUSH);
// browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
//$NON-NLS-1$
browseArchivesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
setButtonLayoutData(browseArchivesButton);
if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
selectExchangeButton = new Button(projectGroup, SWT.PUSH);
//$NON-NLS-1$
selectExchangeButton.setText(Messages.getString("ImportItemWizardPage.browseTalend"));
setButtonLayoutData(selectExchangeButton);
selectExchangeButton.setEnabled(false);
}
itemFromDirectoryRadio.setSelection(true);
archivePathField.setEnabled(false);
browseArchivesButton.setEnabled(false);
browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleLocationDirectoryButtonPressed();
}
});
browseArchivesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleLocationArchiveButtonPressed();
}
});
if (selectExchangeButton != null) {
selectExchangeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
archivePathField.setEditable(false);
IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
selectedArchive = service.openExchangeDialog();
if (selectedArchive != null) {
previouslyBrowsedArchive = selectedArchive;
archivePathField.setText(previouslyBrowsedArchive);
updateItemsList(selectedArchive, false);
}
}
});
}
directoryPathField.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
updateItemsList(directoryPathField.getText().trim(), false);
}
}
});
directoryPathField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
updateItemsList(directoryPathField.getText().trim(), false);
}
});
archivePathField.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
updateItemsList(archivePathField.getText().trim(), false);
}
}
});
archivePathField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
updateItemsList(archivePathField.getText().trim(), false);
}
});
itemFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
directoryRadioSelected();
}
});
itemFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
archiveRadioSelected();
}
});
}
use of org.eclipse.swt.events.FocusAdapter in project tesb-studio-se by Talend.
the class SearchControl method initialize.
private void initialize(int style) {
text = new Text(this, style);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setMessage("search what you want");
text.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
text.selectAll();
}
});
text.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
text.selectAll();
}
});
clear = new ToolBar(this, SWT.FLAT);
ToolItem item = new ToolItem(clear, SWT.PUSH);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
text.setText("");
}
});
Point computeSize = clear.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int height = computeSize.y + 2;
arcSize = height > arcSize ? height : arcSize;
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginBottom = 0;
layout.marginHeight = 0;
layout.marginLeft = marginHorizon;
layout.marginRight = marginHorizon;
layout.marginTop = 1;
layout.marginWidth = 0;
setLayout(layout);
setBackground(backgroundColor);
}
use of org.eclipse.swt.events.FocusAdapter in project tdi-studio-se by Talend.
the class DataSetTableKeyListener method createPopup.
/**
* Display column finder popup.
*/
private void createPopup() {
plastNameSearched = null;
// recycle old popup
if (ppopup != null && !ppopup.isDisposed()) {
if (!ppopup.isVisible()) {
ppopup.open();
}
return;
}
// find out where to put the popup on screen
Point popupLocation = ptable.toDisplay(10, 40);
// create new shell
ppopup = new Shell(pparent.getShell(), SWT.BORDER | SWT.ON_TOP);
ppopup.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
ppopup.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
ppopup.setSize(250, 50);
ppopup.setLocation(popupLocation);
ppopup.setLayout(new GridLayout());
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
// add 'find:' label
Label label = new Label(ppopup, SWT.NULL);
//$NON-NLS-1$
label.setText(Messages.getString("DataSetTable.PopUp.Find"));
label.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
// add input field for search text
final Text input = new Text(ppopup, SWT.SINGLE | SWT.FILL);
input.setLayoutData(gridData);
input.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
// scroll columns whenever something is typed in input field.
input.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text t = (Text) e.widget;
String text = t.getText();
// locate column and show if found
if (jumpToColumn(text)) {
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
} else {
// give some subtle feedback to user that column doesn't exist..
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
}
}
});
// add listener so that we can jump to next column match when
// user hits enter..
input.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == ENTER) {
// scroll to next match
if (jumpToColumn(null)) {
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
} else {
// give some subtle feedback to user that column doesn't exist..
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
}
}
}
});
// close popup when user is no longer in inputfield
input.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
disposePopup();
}
});
// activate popup
ppopup.open();
ppopup.forceActive();
}
Aggregations