use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AbstractStyleEditorDialog method createButtons.
/**
* Create OK, Reset and Cancel buttons
*/
protected void createButtons(final Shell shell) {
Composite buttonPanel = new Composite(shell, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
gridLayout.marginLeft = 65;
buttonPanel.setLayout(gridLayout);
GridData gridLayoutData = new GridData();
gridLayoutData.horizontalAlignment = GridData.FILL_HORIZONTAL;
buttonPanel.setLayoutData(gridLayoutData);
Button okButton = new Button(buttonPanel, SWT.PUSH);
okButton.setText("OK");
okButton.setLayoutData(new GridData(70, 25));
okButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doFormOK(shell);
}
});
Button clearButton = new Button(buttonPanel, SWT.PUSH);
clearButton.setText("Clear");
clearButton.setToolTipText("Reset to original settings");
clearButton.setLayoutData(new GridData(80, 25));
clearButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doFormClear(shell);
}
});
Button cancelButton = new Button(buttonPanel, SWT.NONE);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(new GridData(80, 25));
cancelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doFormCancel(shell);
}
});
shell.setDefaultButton(okButton);
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class WaitDialog method createContents.
@Override
protected Control createContents(Composite parent) {
centerDialogOnScreen(getShell());
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(CENTER, CENTER, true, true));
composite.setRedraw(true);
Label imgLabel = new Label(composite, SWT.NONE);
imgLabel.setImage(iconImage);
textLabel = new Label(composite, SWT.NONE);
textLabel.setLayoutData(new GridData(CENTER, CENTER, true, true));
textLabel.setFont(GUIHelper.getFont(new FontData("Arial", 9, SWT.BOLD)));
textLabel.setRedraw(true);
textLabel.setText(msg);
return composite;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class FileTypePreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite tparent = new Composite(parent, SWT.NONE);
tparent.setLayout(new GridLayout());
tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
HsImageLabel imageLabel = new HsImageLabel(Messages.getString("preference.FileTypePreferencePage.imageLabel"), null);
imageLabel.createControl(tparent);
imageLabel.computeSize();
return parent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class MergeXliffWizardPage method createMergeXlfGroup.
public void createMergeXlfGroup(Composite tparent) {
final Group xliffDataGroup = new Group(tparent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).margins(8, 8).applyTo(xliffDataGroup);
GridDataFactory.fillDefaults().grab(true, true).applyTo(xliffDataGroup);
xliffDataGroup.setText(Messages.getString("wizard.MergeXliffWizardPage.xliffDataGroup"));
tableViewer = new TableViewer(xliffDataGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
tableData.heightHint = 50;
table.setLayoutData(tableData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
String[] columnNames = new String[] { Messages.getString("wizard.MergeXliffWizardPage.columnNames1"), Messages.getString("wizard.MergeXliffWizardPage.columnNames2") };
int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
for (int i = 0; i < columnNames.length; i++) {
TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
tableColumn.setText(columnNames[i]);
}
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(getSplitTableInfos());
validXlf();
// 让列表列宽动态变化
table.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
final Table table = ((Table) event.widget);
final TableColumn[] columns = table.getColumns();
event.widget.getDisplay().syncExec(new Runnable() {
public void run() {
double[] columnWidths = new double[] { 0.15, 0.75 };
for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
}
});
}
});
Composite buttonComp = new Composite(xliffDataGroup, SWT.None);
GridLayoutFactory.fillDefaults().numColumns(1).margins(8, 8).applyTo(buttonComp);
GridDataFactory.fillDefaults().grab(false, true).hint(100, SWT.DEFAULT).applyTo(buttonComp);
Button addbutton = new Button(buttonComp, SWT.NONE);
addbutton.setText(Messages.getString("wizard.MergeXliffWizardPage.addbutton"));
addbutton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addbutton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(xliffDataGroup.getShell(), true, IResource.FILE);
dialog.setMessage(Messages.getString("wizard.MergeXliffWizardPage.dialogMsg"));
dialog.setTitle(Messages.getString("wizard.MergeXliffWizardPage.dialogTitle"));
dialog.setDoubleClickSelects(true);
try {
dialog.setInput(EFS.getStore(root.getLocationURI()));
} catch (CoreException e1) {
LOGGER.error("", e1);
e1.printStackTrace();
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof LocalFile) {
LocalFile folder = (LocalFile) element;
if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata") || folder.getName().equalsIgnoreCase(".config") || folder.getName().equalsIgnoreCase(".nonTransElement")) {
return false;
}
if (projectPath.equals(folder.toString())) {
return true;
}
String xliffFolderPath = folder.toString();
String tempPath = projectPath + System.getProperty("file.separator") + ".TEMP";
String configPath = projectPath + System.getProperty("file.separator") + ".config";
String projectFilePath = projectPath + System.getProperty("file.separator") + ".project";
if (xliffFolderPath.startsWith(tempPath) || xliffFolderPath.startsWith(configPath) || xliffFolderPath.startsWith(projectFilePath)) {
return false;
} else if (xliffFolderPath.startsWith(projectPath)) {
return xliffFolderPath.substring(projectPath.length()).startsWith(System.getProperty("file.separator"));
}
}
return false;
}
});
dialog.create();
dialog.open();
if (dialog.getResult() != null) {
Object[] selectFiles = dialog.getResult();
XLFValidator.resetFlag();
for (int i = 0; i < selectFiles.length; i++) {
IFile iFile = root.getFileForLocation(Path.fromOSString(selectFiles[i].toString()));
if (XLFValidator.validateXliffFile(iFile)) {
// 如果该文件已经存在于列表中,就向添加到重复集合中
if (model.getMergeXliffFile().indexOf(iFile) >= 0) {
exsistFileList.add(iFile);
}
model.getMergeXliffFile().add(iFile);
}
}
XLFValidator.resetFlag();
tableViewer.setInput(getSplitTableInfos());
if (!validIsRepeate()) {
validXlf();
}
// for (int i = 0; i < selectFiles.length; i++) {
// IFile file = root.getFileForLocation(Path.fromOSString(selectFiles[i].toString()));
// // 如果该文件已经存在于列表中,就向添加到重复集合中
// if (model.getMergeXliffFile().indexOf(file) >= 0) {
// exsistFileList.add(file);
// }
// model.getMergeXliffFile().add(file);
// }
// tableViewer.setInput(getSplitTableInfos());
// if (!validIsRepeate()) {
// validXlf();
// }
}
}
});
Button deleteButton = new Button(buttonComp, SWT.NONE);
deleteButton.setText(Messages.getString("wizard.MergeXliffWizardPage.deleteButton"));
deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
deleteButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ISelection selection = tableViewer.getSelection();
Table table = tableViewer.getTable();
if (selection != null && !selection.isEmpty()) {
int[] indices = table.getSelectionIndices();
for (int index : indices) {
String fileFullPath = table.getItem(index).getText(1);
for (int i = 0; i < model.getMergeXliffFile().size(); i++) {
if (model.getMergeXliffFile().get(i).getFullPath().toOSString().equals(fileFullPath)) {
model.getMergeXliffFile().remove(i);
break;
}
}
// 如果该文件存在于重复集合中,则从该集合中删除
for (int j = 0; j < exsistFileList.size(); j++) {
if (exsistFileList.get(j).getFullPath().toOSString().equals(fileFullPath)) {
exsistFileList.remove(j);
break;
}
}
}
tableViewer.setInput(getSplitTableInfos());
}
if (!validIsRepeate()) {
validXlf();
}
}
});
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class MergeXliffWizardPage method createControl.
public void createControl(Composite parent) {
setTitle(Messages.getString("wizard.MergeXliffWizardPage.title"));
setMessage(Messages.getString("wizard.MergeXliffWizardPage.desc"));
Composite tparent = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
tparent.setLayout(layout);
GridDataFactory.fillDefaults().hint(600, 500).grab(true, true).applyTo(tparent);
createMergeXlfGroup(tparent);
setImageDescriptor(Activator.getImageDescriptor("images/file/file-merge-logo.png"));
setControl(parent);
}
Aggregations