use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class CustomMessageDialog method createButtonsForButtonBar.
@Override
protected void createButtonsForButtonBar(Composite parent) {
Button btnDownload = createButton(parent, -1, Messages.getString("license.CustomMessageDialog.download"), false);
btnDownload.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Program.launch(MessageFormat.format(Messages.getString("license.CustomMessageDialog.urlDownload"), ProtectionFactory.getProduct(editionInput), ProtectionFactory.getPlatform(), ProtectionFactory.getVersion()));
}
});
if (!"L".equals(System.getProperty("TSEdition"))) {
Button btnBuy = createButton(parent, -1, Messages.getString("license.LicenseManageDialog.link1"), false);
btnBuy.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Program.launch(Messages.getString("license.LicenseManageDialog.urlr8buy") + "&PRODUCT=" + ProtectionFactory.getProduct() + "&PLATFORM=" + ProtectionFactory.getPlatform());
}
});
}
Button btnTrial = createButton(parent, -1, Messages.getString("license.LicenseManageDialog.link2"), false);
btnTrial.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Program.launch(Messages.getString("license.LicenseManageDialog.urlr8trial") + "&PRODUCT=" + ProtectionFactory.getProduct() + "&PLATFORM=" + ProtectionFactory.getPlatform());
}
});
createButton(parent, IDialogConstants.OK_ID, Messages.getString("license.CustomMessageDialog.inputAgain"), true).setFocus();
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class GetActiveKeyDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = 10;
layout.marginTop = 10;
tparent.setLayout(layout);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
Composite compNav = new Composite(tparent, SWT.NONE);
GridLayout navLayout = new GridLayout();
compNav.setLayout(navLayout);
createNavigation(compNav);
Group groupActivekey = new Group(tparent, SWT.NONE);
groupActivekey.setText(Messages.getString("license.GetActiveKeyDialog.activekey"));
GridDataFactory.fillDefaults().grab(true, true).applyTo(groupActivekey);
GridLayout layoutGroup = new GridLayout(2, false);
layoutGroup.marginWidth = 5;
layoutGroup.marginHeight = 20;
groupActivekey.setLayout(layoutGroup);
StyledText text = new StyledText(groupActivekey, SWT.WRAP | SWT.READ_ONLY);
text.setBackground(text.getParent().getBackground());
text.setText(Messages.getString("license.GetActiveKeyDialog.activemessage"));
GridData dataText = new GridData();
dataText.horizontalSpan = 2;
dataText.widthHint = 470;
text.setLayoutData(dataText);
int start = Messages.getString("license.GetActiveKeyDialog.activemessage").indexOf(Messages.getString("license.GetActiveKeyDialog.ts"));
int length = Messages.getString("license.GetActiveKeyDialog.ts").length();
StyleRange styleRange = new StyleRange();
styleRange.start = start;
styleRange.length = length;
styleRange.fontStyle = SWT.BOLD;
styleRange.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
text.setStyleRange(styleRange);
Label label = new Label(groupActivekey, SWT.WRAP | SWT.NONE);
label.setText(Messages.getString("license.GetActiveKeyDialog.activemessage1"));
GridDataFactory.fillDefaults().span(2, 1).applyTo(label);
textActivekey = new Text(groupActivekey, SWT.MULTI | SWT.WRAP);
textActivekey.setEditable(false);
textActivekey.setText(activekey);
textActivekey.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 150).applyTo(textActivekey);
Button btnCopy = new Button(groupActivekey, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.END).applyTo(btnCopy);
btnCopy.setImage(Activator.getImageDescriptor("images/help/copy.png").createImage());
btnCopy.setToolTipText(Messages.getString("license.GetActiveKeyDialog.copytoclipboard"));
btnCopy.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Clipboard cb = new Clipboard(Display.getCurrent());
String textData = textActivekey.getText();
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { textData }, new Transfer[] { textTransfer });
}
});
return tparent;
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class TermDbManagerImportWizardDialog method createButtonsForButtonBar.
@Override
protected void createButtonsForButtonBar(Composite parent) {
btnSetting = createButton(parent, -1, Messages.getString("wizard.TermDbManagerImportWizardTbxPage.settingBtn"), true);
super.createButtonsForButtonBar(parent);
btnSetting.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PreferenceUtil.openPreferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), TBDatabasePage.ID);
}
});
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class TermDbManagerImportWizardTbxPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(3, false));
Label lblTmx = new Label(container, SWT.NONE);
lblTmx.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblTmx.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblTmx"));
tbxFileText = new Text(container, SWT.BORDER | SWT.READ_ONLY);
tbxFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tbxFileText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validator();
}
});
Button tmxFileBorwserBtn = new Button(container, SWT.NONE);
tmxFileBorwserBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.tmxFileBorwserBtn"));
tmxFileBorwserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell());
String[] filterExt = { "*.tbx", "*.xlsx", "*.txt" };
dlg.setFilterExtensions(filterExt);
String path = dlg.open();
// Messages.getString("wizard.TermDbManagerImportWizardTbxPage.openFile"), SWT.OPEN);
if (path != null) {
tbxFileText.setText(path);
}
}
});
Label lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblNewLabel.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblNewLabel"));
text = new Text(container, SWT.BORDER | SWT.READ_ONLY);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validator();
}
});
HSDropDownButton addBtn = new HSDropDownButton(container, SWT.NONE);
addBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.button"));
Menu addMenu = addBtn.getMenu();
MenuItem item = new MenuItem(addMenu, SWT.PUSH);
item.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddFileTb"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialg = new FileDialog(getShell());
fileDialg.setFilterExtensions(new String[] { "*.hstb", "*.*" });
String result = fileDialg.open();
if (result == null) {
return;
}
File f = new File(result);
if (!f.exists()) {
return;
}
Map<DatabaseModelBean, String> r = null;
try {
r = Utils.convertFile2TbModel(f, false);
} catch (Exception e1) {
MessageDialog.openError(getShell(), Messages.getString("tb.dialog.addFileTb.errorTitle"), e1.getMessage());
}
if (r == null) {
return;
}
Iterator<DatabaseModelBean> it = r.keySet().iterator();
if (it.hasNext()) {
dbModel = it.next();
text.setText(f.getAbsolutePath());
}
}
});
MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
serverItem.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddServerTb"));
serverItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TermDbManagerDialog dialog = new TermDbManagerDialog(getShell());
dialog.setDialogUseFor(TermDbManagerDialog.TYPE_DBSELECTED);
if (dialog.open() == Window.OK) {
Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
List<DatabaseModelBean> list = new ArrayList<DatabaseModelBean>();
while (it.hasNext()) {
list.add(it.next());
}
if (list.size() > 0) {
// 只取第一个.
dbModel = list.get(0);
text.setText(dbModel.getDbName());
}
}
}
});
setControl(container);
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class TmDbManagerDialog method addListeners.
/**
* Add Selection Listener to tree viewer
* @param viewer
* ;
*/
private void addListeners(final TreeViewer viewer) {
// 选择事件
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof DatabaseModelBean) {
DatabaseModelBean bean = (DatabaseModelBean) obj;
setCurrDbType(bean.getDbType());
bean.copyToOtherIntance(currServer);
SystemDBOperator dbop = getCurrSysDbOp();
if (dbop != null) {
executeSearch(dbop);
}
// 当数据库类型发生改变时重新初始化界面
initUI(false);
} else if (obj instanceof String) {
setCurrDbType((String) obj);
resetInputValue();
currServerdbListInput.clear();
initUI(true);
}
}
});
// 双击展开事件
((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(final SelectionEvent event) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof String) {
String type = (String) obj;
boolean expanded = viewer.getExpandedState(type);
viewer.setExpandedState(type, !expanded);
}
}
});
// 右键菜单事件,判断何时出现右键菜单
viewer.getControl().addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
Tree tree = treeViewer.getTree();
if (obj instanceof DatabaseModelBean) {
// 将菜单挂到树上
tree.setMenu(treePopMenu);
} else {
tree.setMenu(null);
}
}
});
}
Aggregations