use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class NewProjectWizardProjInfoPage method reload.
public void reload() {
if (lstText != null) {
lstText.clear();
}
if (lstCombo != null) {
lstCombo.clear();
}
ArrayList<String> lstField = PreferenceUtil.getProjectFieldList();
LinkedHashMap<String, ArrayList<String>> mapAttr = PreferenceUtil.getProjectAttributeMap();
if ((lstField != null && lstField.size() > 0) || (mapAttr != null && mapAttr.size() > 0)) {
if (groupField == null || groupField.isDisposed()) {
groupField = new Group((Composite) getControl(), SWT.None);
groupField.setLayout(new GridLayout());
GridData fieldData = new GridData(GridData.FILL_BOTH);
groupField.setLayoutData(fieldData);
groupField.setText(Messages.getString("wizards.NewProjectWizardProjInfoPage.groupField"));
cmpScrolled = new ScrolledComposite(groupField, SWT.V_SCROLL);
cmpScrolled.setAlwaysShowScrollBars(false);
cmpScrolled.setLayoutData(new GridData(GridData.FILL_BOTH));
cmpScrolled.setExpandHorizontal(true);
cmpScrolled.setExpandVertical(true);
cmpField = new Composite(cmpScrolled, SWT.None);
cmpField.setLayout(new GridLayout(2, false));
cmpScrolled.setContent(cmpField);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
if (cmpField != null && !cmpField.isDisposed()) {
for (Control control : cmpField.getChildren()) {
control.dispose();
}
cmpField.layout();
cmpScrolled.layout();
groupField.layout();
groupField.getParent().layout();
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
if (lstField != null && lstField.size() > 0) {
if (lstText == null) {
lstText = new ArrayList<Text>();
}
for (String strField : lstField) {
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = strField.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x >= 100) {
gd.widthHint = 100;
}
Text txt = new Text(cmpField, SWT.BORDER);
txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txt.setData(strField);
txt.addListener(SWT.Modify, this);
lstText.add(txt);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
if (mapAttr != null && mapAttr.size() > 0) {
Iterator<Entry<String, ArrayList<String>>> it = mapAttr.entrySet().iterator();
if (lstCombo == null) {
lstCombo = new ArrayList<Combo>();
}
while (it.hasNext()) {
Entry<String, ArrayList<String>> entry = (Entry<String, ArrayList<String>>) it.next();
String attrName = entry.getKey();
ArrayList<String> lstAttrVal = entry.getValue();
lstAttrVal.add(0, "");
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = attrName.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x >= 100) {
gd.widthHint = 100;
}
Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmb.setItems(lstAttrVal.toArray(new String[lstAttrVal.size()]));
cmb.select(0);
cmb.setData(attrName);
lstCombo.add(cmb);
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
cmpField.layout();
cmpScrolled.layout();
groupField.layout();
groupField.getParent().layout();
}
} else if (groupField != null && !groupField.isDisposed()) {
Composite cmpParent = groupField.getParent();
groupField.dispose();
cmpParent.layout();
}
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class NewProjectWizardSourceFilePage 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(1, false));
setControl(container);
fileListViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
fileListViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
fileListViewer.setContentProvider(new ArrayContentProvider());
fileListViewer.setInput(srcFileList);
if (this.converterCaller != null) {
final Button btnConvert = new Button(container, SWT.CHECK);
btnConvert.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.btnConvert"));
btnConvert.setSelection(true);
isOpenConverter = true;
btnConvert.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isOpenConverter = btnConvert.getSelection();
}
});
}
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
Button addBtn = new Button(composite, SWT.NONE);
addBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.addBtn"));
addBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell(), SWT.MULTI);
// CONVERTEREXTENTION
String[] supExtentions = new String[] { "*.mif;*.idml;*.inx;*.xlf;*.rtf;*.po;*.properties;*.js;*.mqxlz;*.doc;*.xls;*.ppt;" + "*.docx;*.xlsx;*.pptx;*.odt;*.ods;*.odp;*.odg;*.rtf;*.sdlxliff;*.ttx;*.htm;*.html;*.txt;*.resx;*.rc;*.xml;*.txml", "*.*" };
dlg.setFilterExtensions(supExtentions);
if (dlg.open() != null) {
String[] files = dlg.getFileNames();
for (int i = 0; i < files.length; i++) {
StringBuffer buf = new StringBuffer(dlg.getFilterPath());
buf.append(File.separator);
buf.append(files[i]);
String file = buf.toString();
if (!srcFileList.contains(file)) {
srcFileList.add(file);
}
}
fileListViewer.refresh();
}
}
});
Button deleteBtn = new Button(composite, SWT.NONE);
deleteBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.deleteBtn"));
deleteBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selections = (IStructuredSelection) fileListViewer.getSelection();
Iterator<?> it = selections.iterator();
while (it.hasNext()) {
String file = (String) it.next();
srcFileList.remove(file);
}
fileListViewer.refresh();
}
});
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class KeysPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IWorkbenchHelpContextIds.KEYS_PREFERENCE_PAGE);
final Composite page = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
page.setLayout(layout);
Group groupParent = new Group(page, SWT.None);
groupParent.setLayout(new GridLayout());
groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
groupParent.setText(Messages.getString("preferencepage.KeysPreferencePage.groupParent"));
HsImageLabel imageLabel = new HsImageLabel(Messages.getString("preferencepage.KeysPreferencePage.imageLabel"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_KEY));
Composite cmp = imageLabel.createControl(groupParent);
cmp.setLayout(new GridLayout());
Composite cmpTemp = (Composite) imageLabel.getControl();
cmpTemp.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite cmpContent = new Composite(cmpTemp, SWT.None);
cmpContent.setLayout(new GridLayout());
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
cmpContent.setLayoutData(data);
// 不显示过滤文本框
PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.SHOW_FILTERED_TEXTS, false);
IDialogSettings settings = getDialogSettings();
fPatternFilter = new CategoryPatternFilter(true, commandService.getCategory(null));
if (settings.get(TAG_FILTER_UNCAT) != null) {
fPatternFilter.filterCategories(settings.getBoolean(TAG_FILTER_UNCAT));
}
createTree(cmpContent);
fill();
applyDialogFont(cmpContent);
imageLabel.computeSize();
return page;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class ProjectSettingBaseInfoPage method createContents.
/**
* Create contents of the preference page.
* @param parent
*/
@Override
public Control createContents(Composite parent) {
// GridData fieldData = new GridData();
// fieldData.heightHint = 10;
// Composite container = new Composite(parent, SWT.NULL);
// container.setLayout(new GridLayout());
// container.setLayoutData(fieldData);
//
// ScrolledComposite cmpScrolled = new ScrolledComposite(container, SWT.V_SCROLL);
// cmpScrolled.setAlwaysShowScrollBars(true);
// cmpScrolled.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// cmpScrolled.setExpandHorizontal(true);
// cmpScrolled.setExpandVertical(true);
Composite cmpField = new Composite(parent, SWT.None);
cmpField.setLayout(new GridLayout(2, false));
// cmpScrolled.setContent(cmpField);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Label label = new Label(cmpField, SWT.RIGHT);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.projectNameLabel"));
Point namePoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
projectNameLabel = new Label(cmpField, SWT.NONE);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
label = new Label(cmpField, SWT.RIGHT);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.sourceLangLabel"));
Point srcPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
sourceLangLabel = new Label(cmpField, SWT.NONE);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
label = new Label(cmpField, SWT.RIGHT);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
label.setText(Messages.getString("projectsetting.ProjectSettingBaseInfoPage.targetlangLabel"));
Point tgtPoint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
targetlangLabel = new Label(cmpField, SWT.NONE);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
initData();
int width = Math.max(namePoint.x, Math.max(srcPoint.x, tgtPoint.x)) + 10;
Map<String, String> mapField = projCfgBean.getMapField();
if (mapField != null && mapField.size() > 0) {
lstText = new ArrayList<Text>();
Iterator<Entry<String, String>> it = mapField.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> entry = (Entry<String, String>) it.next();
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = TextUtil.xmlToString(entry.getKey()).replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x > width) {
gd.widthHint = width;
}
Text txt = new Text(cmpField, SWT.BORDER);
txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txt.setText(TextUtil.xmlToString(entry.getValue()));
txt.setData(TextUtil.xmlToString(entry.getKey()));
txt.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (lstText != null && lstText.size() > 0) {
boolean isValid = true;
for (Text txt : lstText) {
String value = txt.getText();
if (value != null && !value.equals("")) {
if (value.trim().equals("")) {
setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg3"));
isValid = false;
setValid(false);
break;
} else if (value.trim().length() > 50) {
setErrorMessage(Messages.getString("wizard.NewProjectWizardProjInfoPage.msg4"));
setValid(false);
isValid = false;
break;
}
}
}
if (isValid) {
setErrorMessage(null);
setValid(true);
}
}
}
});
lstText.add(txt);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
Map<String, Object[]> mapAttr = projCfgBean.getMapAttr();
if (mapAttr != null && mapAttr.size() > 0) {
lstCombo = new ArrayList<Combo>();
Iterator<Entry<String, Object[]>> it = mapAttr.entrySet().iterator();
while (it.hasNext()) {
Entry<String, Object[]> entry = (Entry<String, Object[]>) it.next();
String attrName = TextUtil.xmlToString(entry.getKey());
String attrSelVal = TextUtil.xmlToString((String) entry.getValue()[0]);
@SuppressWarnings("unchecked") List<String> lstAttrVal = (List<String>) entry.getValue()[1];
String[] arrAttrVal = new String[lstAttrVal.size()];
int selIndex = 0;
for (int i = 0; i < lstAttrVal.size(); i++) {
arrAttrVal[i] = TextUtil.xmlToString(lstAttrVal.get(i));
if (attrSelVal.equals(arrAttrVal[i])) {
selIndex = i;
}
}
Label lbl = new Label(cmpField, SWT.WRAP);
String strLbl = attrName.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
lbl.setText(strLbl);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
GridData gd = (GridData) lbl.getLayoutData();
Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (p.x > width) {
gd.widthHint = width;
}
Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmb.setItems(arrAttrVal);
cmb.select(selIndex);
cmb.setData(attrName);
lstCombo.add(cmb);
// cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
}
return cmpField;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class ImportProjectWizardPage2 method createResourceTree.
/**
* 创建两颗显示资源树
*/
private void createResourceTree(Composite tparent) {
Composite resourceTreeCmp = new Composite(tparent, SWT.NONE);
resourceTreeCmp.setLayoutData(new GridData(GridData.FILL_BOTH));
resourceTreeCmp.setLayout(new GridLayout(2, true));
Label leftLbl = new Label(resourceTreeCmp, SWT.NONE);
leftLbl.setText(Messages.getString("importProjectWizardPage.projectOfImport"));
Label rightLbl = new Label(resourceTreeCmp, SWT.NONE);
rightLbl.setText(Messages.getString("importProjectWizardPage.repeatedContent"));
// 定义两颗树
selectContentProvider = new SelectProjectContentProvider();
repeateContentProvider = new RepeatProjectContentProvider();
selectElementTree = new ResourceTree(resourceTreeCmp, selectContentProvider, new ProjectLabelProvider());
repeatElementTree = new ResourceTree(resourceTreeCmp, repeateContentProvider, new ProjectLabelProvider());
// 左边的按钮
Composite leftBtnCmp = new Composite(resourceTreeCmp, SWT.NONE);
leftBtnCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(3).applyTo(leftBtnCmp);
leftSelectAllBtn = new Button(leftBtnCmp, SWT.PUSH);
leftSelectAllBtn.setText(Messages.getString("importProjectWizardPage.leftSelectAllBtn"));
leftSelectAllBtn.addListener(SWT.Selection, this);
setButtonLayoutData(leftSelectAllBtn);
leftDisSelectAllBtn = new Button(leftBtnCmp, SWT.PUSH);
leftDisSelectAllBtn.setText(Messages.getString("importProjectWizardPage.leftDisSelectAllBtn"));
leftDisSelectAllBtn.addListener(SWT.Selection, this);
setButtonLayoutData(leftDisSelectAllBtn);
leftAllExpandBtn = new Button(leftBtnCmp, SWT.PUSH);
leftAllExpandBtn.setText(Messages.getString("importProjectWizardPage.leftExpandAllBtn"));
leftAllExpandBtn.addListener(SWT.Selection, this);
setButtonLayoutData(leftAllExpandBtn);
// 右边的按钮
Composite rightBtnCmp = new Composite(resourceTreeCmp, SWT.NONE);
rightBtnCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(3).applyTo(rightBtnCmp);
rightSelectAllBtn = new Button(rightBtnCmp, SWT.PUSH);
rightSelectAllBtn.setText(Messages.getString("importProjectWizardPage.rightSelectAllBtn"));
rightSelectAllBtn.addListener(SWT.Selection, this);
setButtonLayoutData(rightSelectAllBtn);
rightDisSelectAllBtn = new Button(rightBtnCmp, SWT.PUSH);
rightDisSelectAllBtn.setText(Messages.getString("importProjectWizardPage.rightDisSelectAllBtn"));
rightDisSelectAllBtn.addListener(SWT.Selection, this);
setButtonLayoutData(rightDisSelectAllBtn);
rightAllExpandBtn = new Button(rightBtnCmp, SWT.PUSH);
rightAllExpandBtn.setText(Messages.getString("importProjectWizardPage.rightExpandAllBtn"));
rightAllExpandBtn.addListener(SWT.Selection, this);
setButtonLayoutData(rightAllExpandBtn);
// 初始化两颗树的事件
initTreeListener();
selectElementTree.setInput(this);
repeatElementTree.setInput(this);
}
Aggregations