use of net.heartsome.cat.document.ExportAbstract in project translationstudio8 by heartsome.
the class ExportTbxDialog method okPressed.
@Override
protected void okPressed() {
String encoding = "UTF-8";
if (hasChangedCodingCbtn.getSelection()) {
encoding = this.encodingComboViewer.getCombo().getText();
}
String exportPath = this.tbxFileText.getText();
ExportFilterBean filterBean = null;
if (hasFilterChangedBtn.getSelection()) {
IStructuredSelection sel = (IStructuredSelection) filterComboViewer.getSelection();
filterBean = (ExportFilterBean) sel.getFirstElement();
if (filterBean.equals(filterList.get(0))) {
filterBean = null;
}
}
if (this.dbList.size() == 0) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg3"));
return;
}
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean dbBean = iterator.next();
if (dbBean.getHasSelectedLangs().size() < 2) {
String dbType = dbBean.getDbBean().getDbType();
String name = dbBean.getDbBean().getDatabaseName();
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg4"), dbType, name));
return;
}
}
if (exportPath == null || exportPath.equals("")) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg5"));
return;
}
if (this.dbList.size() > 1) {
File f = new File(exportPath);
if (!f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg7"));
return;
}
}
if (this.dbList.size() == 1) {
File f = new File(exportPath);
if (f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg8"));
return;
}
}
if (this.dbList.size() == 1) {
dbList.get(0).setExportFilePath(exportPath);
File file = new File(exportPath);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg6"), exportPath))) {
return;
}
}
} else {
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean db = iterator.next();
String databaseName = db.getDbBean().getDatabaseName();
String path = exportPath + System.getProperty("file.separator") + databaseName + db.getDbBean().getDbType() + ".tbx";
File file = new File(path);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg6"), path))) {
return;
}
}
db.setExportFilePath(path);
}
}
final ExportAbstract exportor = new ExportTbxImpl(this.dbList, filterBean, encoding);
Job job = new Job(Messages.getString("dialog.ExportTbxDialog.job")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final String result = DatabaseService.executeExport(exportor, monitor);
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), result);
}
});
return Status.OK_STATUS;
}
};
// 当程序退出时,检测当前 job 是否正常关闭
CommonFunction.jobCantCancelTip(job);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void running(IJobChangeEvent event) {
ProgressIndicatorManager.displayProgressIndicator();
super.running(event);
}
@Override
public void done(IJobChangeEvent event) {
ProgressIndicatorManager.hideProgressIndicator();
super.done(event);
}
});
job.setUser(true);
job.schedule();
super.okPressed();
}
use of net.heartsome.cat.document.ExportAbstract in project translationstudio8 by heartsome.
the class ExportTmxDialog method okPressed.
@Override
protected void okPressed() {
String encoding = "UTF-8";
if (hasChangedCodingCbtn.getSelection()) {
encoding = this.encodingComboViewer.getCombo().getText();
}
String exportPath = this.tmxFileText.getText();
boolean isTopLevelTmx = this.isTopLevelTmxCbtn.getSelection();
boolean isTagLevelTmx = this.isTagCbtn.getSelection();
ExportFilterBean filterBean = null;
if (this.hasfilterCbtn.getSelection()) {
IStructuredSelection sel = (IStructuredSelection) filterComboViewer.getSelection();
filterBean = (ExportFilterBean) sel.getFirstElement();
if (filterBean.equals(filterList.get(0))) {
filterBean = null;
}
}
if (this.dbList.size() == 0) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), Messages.getString("dialog.ExportTmxDialog.msg3"));
return;
}
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean dbBean = iterator.next();
String dbType = dbBean.getDbBean().getDbType();
String name = dbBean.getDbBean().getDatabaseName();
if (dbBean.getHasSelectedLangs().size() < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTmxDialog.msg4"), dbType, name));
return;
}
if (dbBean.getSrcLang().equals("")) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTmxDialog.msg5"), dbType, name));
return;
}
}
if (exportPath == null || exportPath.equals("")) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), Messages.getString("dialog.ExportTmxDialog.msg6"));
return;
}
if (this.dbList.size() > 1) {
File f = new File(exportPath);
if (!f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), Messages.getString("dialog.ExportTmxDialog.msg8"));
return;
}
}
if (this.dbList.size() == 1) {
File f = new File(exportPath);
if (f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), Messages.getString("dialog.ExportTmxDialog.msg9"));
return;
}
}
if (this.dbList.size() == 1) {
dbList.get(0).setExportFilePath(exportPath);
File file = new File(exportPath);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTmxDialog.msg7"), exportPath))) {
return;
}
}
} else {
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean db = iterator.next();
String databaseName = db.getDbBean().getDatabaseName();
String path = exportPath + System.getProperty("file.separator") + databaseName + db.getDbBean().getDbType() + ".tmx";
File file = new File(path);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTmxDialog.msg7"), path))) {
return;
}
}
db.setExportFilePath(path);
}
}
final ExportAbstract tmxExport = new ExportTmxImpl(this.dbList, filterBean, encoding, isTopLevelTmx, isTagLevelTmx);
Job job = new Job(Messages.getString("dialog.ExportTmxDialog.job")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final String result = DatabaseService.executeExport(tmxExport, monitor);
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTmxDialog.msgTitle"), result);
}
});
return Status.OK_STATUS;
}
};
// 当程序退出时,检测当前 job 是否正常关闭
CommonFunction.jobCantCancelTip(job);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void running(IJobChangeEvent event) {
ProgressIndicatorManager.displayProgressIndicator();
super.running(event);
}
@Override
public void done(IJobChangeEvent event) {
ProgressIndicatorManager.hideProgressIndicator();
super.done(event);
}
});
job.setUser(true);
job.schedule();
super.okPressed();
}
Aggregations