use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class ColumnTypeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(750, 400).grab(true, true).applyTo(tparent);
ScrolledComposite cmpScrolled = new ScrolledComposite(tparent, SWT.V_SCROLL);
cmpScrolled.setAlwaysShowScrollBars(false);
cmpScrolled.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
cmpScrolled.setExpandHorizontal(true);
cmpScrolled.setShowFocusedControl(true);
Composite cmpContent = new Composite(cmpScrolled, SWT.None);
cmpScrolled.setContent(cmpContent);
cmpContent.setLayout(new GridLayout(5, false));
arrCmbLangs = new Combo[size];
arrCmbPropsName = new Combo[size];
arrCmbPropsType = new Combo[size];
arrCmbPropsLevel = new Combo[size];
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column1"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column2"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column3"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column4"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column5"));
for (int i = 0; i < size; i++) {
ColProperties type = colTypes.get(i);
new Label(cmpContent, SWT.None).setText(type.getColName() + " : ");
arrCmbPropsLevel[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbPropsLevel[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsName[i] = new Combo(cmpContent, SWT.READ_ONLY);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 120;
arrCmbPropsName[i].setLayoutData(data);
arrCmbPropsType[i] = new Combo(cmpContent, SWT.READ_ONLY);
data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 150;
arrCmbPropsType[i].setLayoutData(data);
arrCmbLangs[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbLangs[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsLevel[i].setItems(levelValues);
arrCmbPropsLevel[i].select(0);
String propLevel = type.getLevel();
if (!propLevel.equals("")) {
//$NON-NLS-1$
arrCmbPropsLevel[i].setText(propLevel);
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbLangs[i].setEnabled(false);
arrCmbPropsName[i].setItems(conceptPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbLangs[i].setEnabled(true);
arrCmbPropsName[i].setItems(TranslationPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
arrCmbPropsType[i].select(0);
}
}
// fixed a bug 2339 by John.
String propName = type.getPropName();
if (!propName.equals("")) {
//$NON-NLS-1$
arrCmbPropsName[i].setText(propName);
}
// Update content for Prop Type combo
String propType = type.getPropType();
if (!propType.equals("")) {
//$NON-NLS-1$
arrCmbPropsType[i].setText(propType);
}
if (!propLevel.equals("")) {
//$NON-NLS-1$
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[i].setEnabled(propName.equals(ColProperties.descripName));
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbPropsType[i].setEnabled(!propName.equals(ColProperties.termName));
if (propName.equals(ColProperties.descripName)) {
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[i].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[i].select(0);
}
}
// Update content for Language Combo
arrCmbLangs[i].setItems(LocaleService.getLanguages());
arrCmbLangs[i].select(0);
String lang = type.getLanguage();
if (!lang.equals("")) {
//$NON-NLS-1$
arrCmbLangs[i].setText(LocaleService.getLanguage(lang));
}
final int idx = i;
arrCmbPropsName[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (name.equals(ColProperties.termName)) {
arrCmbPropsType[idx].setEnabled(false);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.termNoteName)) {
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.noteName)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsType[idx].setEnabled(false);
return;
}
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setEnabled(true);
if (level.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
}
arrCmbPropsType[idx].select(0);
return;
}
arrCmbPropsType[idx].setEnabled(false);
}
});
arrCmbPropsLevel[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (level.equals(ColProperties.conceptLevel)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsName[idx].setItems(conceptPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
}
if (level.equals(ColProperties.langLevel)) {
arrCmbLangs[idx].setEnabled(true);
arrCmbPropsName[idx].setItems(TranslationPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(false);
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[idx].select(0);
}
}
});
}
cmpContent.setSize(cmpContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
return tparent;
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class PluginHelpDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent);
createMenu();
createToolBar(tparent);
mainSash = new SashForm(tparent, SWT.NONE);
mainSash.setOrientation(SWT.HORIZONTAL);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
mainSash.setLayout(layout);
mainSash.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
Composite navigation = new Composite(mainSash, SWT.BORDER);
navigation.setLayout(new GridLayout(1, false));
navigation.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
tree = new Tree(navigation, SWT.NONE);
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if (tree.getSelectionCount() > 0) {
TreeItem item = tree.getSelection()[0];
String url = hashTable.get(item);
if (url != null && !url.equals("")) {
browser.setUrl(url);
browser.update();
}
}
}
});
tree.addTreeListener(new TreeAdapter() {
public void treeCollapsed(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (item != null && item.getData() != null) {
if (item.getData().equals("toc")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_CLOSED).createImage());
}
if (item.getData().equals("book")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_CLOSED).createImage());
}
}
}
public void treeExpanded(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (item != null && item.getData() != null) {
if (item.getData().equals("toc")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_TOC_OPEN).createImage());
}
if (item.getData().equals("book")) {
item.setImage(Activator.getImageDescriptor(PluginConstants.HELP_BOOK_OPEN).createImage());
}
}
}
});
tree.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
Composite contents = new Composite(mainSash, SWT.BORDER);
contents.setLayout(new GridLayout(1, false));
contents.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
browser = new Browser(contents, SWT.NONE);
browser.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
mainSash.setWeights(new int[] { 30, 70 });
hashTable = new Hashtable<TreeItem, String>();
if (!helpFilePath.equals("")) {
loadTree(helpFilePath);
}
return tparent;
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class RTFCleanerDialog method createToolBar.
/**
* 创建工具栏
* @param parent
* 父控件
*/
private void createToolBar(Composite parent) {
ToolBar toolBar = new ToolBar(parent, SWT.NO_FOCUS | SWT.None);
toolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolItem addStyleItem = new ToolItem(toolBar, SWT.PUSH);
addStyleItem.setToolTipText(Messages.getString("dialog.RTFCleanerDialog.addStyleItem"));
addStyleItem.setImage(new Image(Display.getDefault(), PluginUtil.getAbsolutePath(PluginConstants.PIC_OPEN_CSV_PATH)));
addStyleItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
handleFile();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class RTFCleanerDialog method createMenu.
/**
* 创建菜单 ;
*/
private void createMenu() {
Menu menu = new Menu(getShell(), SWT.BAR);
getShell().setMenuBar(menu);
getShell().pack();
Rectangle screenSize = Display.getDefault().getClientArea();
Rectangle frameSize = getShell().getBounds();
getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
Menu fileMenu = new Menu(menu);
MenuItem fileItem = new MenuItem(menu, SWT.CASCADE);
fileItem.setMenu(fileMenu);
fileItem.setText(Messages.getString("dialog.RTFCleanerDialog.fileMenu"));
MenuItem addStylesItem = new MenuItem(fileMenu, SWT.PUSH);
addStylesItem.setText(Messages.getString("dialog.RTFCleanerDialog.addStylesItem"));
addStylesItem.setImage(new Image(Display.getDefault(), PluginUtil.getAbsolutePath(PluginConstants.PIC_OPEN_CSV_PATH)));
addStylesItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
handleFile();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
new MenuItem(fileMenu, SWT.SEPARATOR);
MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
exitItem.setText(Messages.getString("dialog.RTFCleanerDialog.exitItem"));
exitItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
close();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class PluginConfigManageDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).hint(500, 350).minSize(500, 350).applyTo(tparent);
// 插件基本信息,包括名称,命令行之类的东西
Composite pluginInfoCmp = new Composite(tparent, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(pluginInfoCmp);
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(pluginInfoCmp);
Label nameLbl = new Label(pluginInfoCmp, SWT.NONE);
nameLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.nameLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(nameLbl);
nameTxt = new Text(pluginInfoCmp, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, SWT.DEFAULT).applyTo(nameTxt);
Label commandLbl = new Label(pluginInfoCmp, SWT.NONE);
commandLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.commandLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(commandLbl);
commandTxt = new Text(pluginInfoCmp, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(commandTxt);
Button browseBtn = new Button(pluginInfoCmp, SWT.NONE);
browseBtn.setText(Messages.getString("dialog.PluginConfigManageDialog.browseBtn"));
browseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String[] extensions = { "*.exe", "*.*" };
String[] names = { Messages.getString("dialog.PluginConfigManageDialog.names1"), Messages.getString("dialog.PluginConfigManageDialog.names2") };
String fileLocation = browseFile(Messages.getString("dialog.PluginConfigManageDialog.dialogTitle"), extensions, names);
commandTxt.setText(fileLocation == null ? "" : fileLocation);
}
});
createShortcutKeyGoup(tparent);
createProcessesAddReturnGroup(tparent);
createSwitchCmp(tparent);
initListener();
return tparent;
}
Aggregations