use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class CSVSettingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(5, 5, 5, 5).applyTo(tparent);
int height = 160;
if (isTBXConverter) {
height = 230;
}
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(320, height).grab(true, true).applyTo(tparent);
Composite cmpSelFile = new Composite(tparent, SWT.None);
GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).extendedMargins(0, 0, 0, 0).applyTo(cmpSelFile);
GridDataFactory.fillDefaults().applyTo(cmpSelFile);
new Label(cmpSelFile, SWT.None).setText(Messages.getString("dialog.CSVSettingDialog.lblFile"));
txtCSV = new Text(cmpSelFile, SWT.BORDER);
txtCSV.setEditable(false);
txtCSV.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnBrowse = new Button(cmpSelFile, SWT.None);
btnBrowse.setText(Messages.getString("dialog.CSVSettingDialog.btnBrowse"));
btnBrowse.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(Messages.getString("dialog.CSVSettingDialog.dialogTitle"));
String[] extensions = { "*.csv", "*.txt", "*" };
String[] filters = { Messages.getString("dialog.CSVSettingDialog.filters1"), Messages.getString("dialog.CSVSettingDialog.filters2"), Messages.getString("dialog.CSVSettingDialog.filters3") };
dialog.setFilterExtensions(extensions);
dialog.setFilterNames(filters);
String fileSep = System.getProperty("file.separator");
if (txtCSV.getText() != null && !txtCSV.getText().trim().equals("")) {
dialog.setFilterPath(txtCSV.getText().substring(0, txtCSV.getText().lastIndexOf(fileSep)));
dialog.setFileName(txtCSV.getText().substring(txtCSV.getText().lastIndexOf(fileSep) + 1));
} else {
dialog.setFilterPath(System.getProperty("user.home"));
}
String name = dialog.open();
if (name != null) {
txtCSV.setText(name);
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Composite cmpContent = new Composite(tparent, SWT.NONE);
cmpContent.setLayout(new GridLayout(2, false));
cmpContent.setLayoutData(new GridData(GridData.FILL_BOTH));
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbColSeparator"));
cmbColSeparator = new Combo(cmpContent, SWT.NONE);
cmbColSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbColSeparator.setItems(arrColSeparator);
cmbColSeparator.select(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbTextDelimiter"));
cmbTextDelimiter = new Combo(cmpContent, SWT.NONE);
cmbTextDelimiter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbTextDelimiter.setItems(arrTextDelimiter);
cmbTextDelimiter.setText("\"");
cmbTextDelimiter.setTextLimit(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbEncoding"));
cmbEncoding = new Combo(cmpContent, SWT.READ_ONLY);
cmbEncoding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
String[] arrEncoding = LocaleService.getPageCodes();
cmbEncoding.setItems(arrEncoding);
cmbEncoding.select(indexOf(arrEncoding, "UTF-8"));
if (isTBXConverter) {
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbLang"));
cmbLang = new TableComboViewer(cmpContent, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = cmbLang.getTableCombo();
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
cmbLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
ArrayList<Language> languages = new ArrayList<Language>(LocaleService.getDefaultLanguage().values());
Collections.sort(languages, new Comparator<Language>() {
public int compare(Language o1, Language o2) {
return o1.toString().compareTo(o2.toString());
}
});
cmbLang.setContentProvider(new ArrayContentProvider());
cmbLang.setLabelProvider(new LanguageLabelProvider());
cmbLang.setInput(languages);
cmbLang.getTableCombo().select(0);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbXCSTemplate"));
cmbXCSTemplate = new Combo(cmpContent, SWT.READ_ONLY);
cmbXCSTemplate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (xcsTemplates.length > 0) {
cmbXCSTemplate.setItems(xcsTemplates);
cmbXCSTemplate.select(0);
}
}
return tparent;
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class ColumnRemoveDialog 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(150, 200).grab(true, true).applyTo(tparent);
listColumn = new List(tparent, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
listColumn.setLayoutData(new GridData(GridData.FILL_BOTH));
for (int i = 0; i < allColumnVector.size(); i++) {
listColumn.add(allColumnVector.get(i));
}
Button btnRemove = new Button(tparent, SWT.None);
btnRemove.setText(Messages.getString("dialog.ColumnRemoveDialog.btnRemove"));
GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(btnRemove);
btnRemove.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
int total = listColumn.getItemCount();
int selCount = listColumn.getSelectionCount();
if (selCount == 0) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ColumnRemoveDialog.msgTitle"), Messages.getString("dialog.ColumnRemoveDialog.msg1"));
return;
}
if ((total - selCount) < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ColumnRemoveDialog.msgTitle"), Messages.getString("dialog.ColumnRemoveDialog.msg2"));
return;
}
listColumn.remove(listColumn.getSelectionIndices());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
return tparent;
}
use of org.eclipse.swt.layout.GridLayout 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.layout.GridLayout 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.layout.GridLayout in project translationstudio8 by heartsome.
the class PluginConfigurationDialog method createButtonBar.
@Override
protected Control createButtonBar(Composite parent) {
Composite buttonCmp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
buttonCmp.setLayout(layout);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
buttonCmp.setLayoutData(data);
buttonCmp.setFont(parent.getFont());
Composite leftCmp = new Composite(buttonCmp, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(leftCmp);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).equalWidth(false).applyTo(leftCmp);
addBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialog.PluginConfigurationDialog.addBtn"), false);
editBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialog.PluginConfigurationDialog.editBtn"), false);
deleteBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialog.PluginConfigurationDialog.deleteBtn"), false);
Composite rightCmp = new Composite(buttonCmp, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).equalWidth(false).applyTo(rightCmp);
new Label(rightCmp, SWT.NONE);
Label separatorLbl = new Label(buttonCmp, SWT.HORIZONTAL | SWT.SEPARATOR);
GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(separatorLbl);
new Label(buttonCmp, SWT.NONE);
Composite bottomCmp = new Composite(buttonCmp, SWT.NONE);
GridDataFactory.fillDefaults().grab(false, false).applyTo(bottomCmp);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).applyTo(bottomCmp);
createButton(bottomCmp, IDialogConstants.CANCEL_ID, Messages.getString("dialog.PluginConfigurationDialog.cancel"), true).setFocus();
initListener();
return buttonCmp;
}
Aggregations