use of gen.taas.TaasCollection in project omegat by omegat-org.
the class BrowseTaasCollectionsController method show.
public static void show() {
dialog = new BrowseTaasCollectionsUI(Core.getMainWindow().getApplicationFrame(), true);
final Language sourceLang = Core.getProject().getProjectProperties().getSourceLanguage();
final Language targetLang = Core.getProject().getProjectProperties().getTargetLanguage();
List<TaasCollection> list = Collections.emptyList();
CollectionsTable model = new CollectionsTable(list, sourceLang, targetLang);
dialog.tableCollections.setModel(model);
dialog.tableCollections.setColumnModel(createColumnModel());
dialog.labelStatus.setText(OStrings.getString("TAAS_STATUS_LIST"));
new SwingWorker<List<TaasCollection>, Void>() {
@Override
protected List<TaasCollection> doInBackground() throws Exception {
return TaaSPlugin.getClient().getCollectionsList();
}
@Override
protected void done() {
try {
List<TaasCollection> list = get();
removeUnusedCollections(list);
CollectionsTable model = new CollectionsTable(list, sourceLang, targetLang);
dialog.tableCollections.setModel(model);
TableRowSorter<CollectionsTable> sorter = new TableRowSorter<CollectionsTable>(model);
dialog.tableCollections.setRowSorter(sorter);
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
dialog.tableCollections.setColumnModel(createColumnModel());
dialog.labelStatus.setText(" ");
} catch (ExecutionException e) {
Throwable ex = e.getCause();
if (ex instanceof TaaSClient.FormatError) {
Log.logErrorRB(ex, "TAAS_FORMAT_ERROR", ex.getMessage());
dialog.labelStatus.setText(OStrings.getString("TAAS_FORMAT_ERROR"));
} else if (ex instanceof TaaSClient.Unauthorized) {
Log.logErrorRB(ex, "TAAS_UNAUTHORIZED_ERROR");
dialog.labelStatus.setText(OStrings.getString("TAAS_UNAUTHORIZED_ERROR"));
} else {
Log.logErrorRB(ex, "TAAS_GENERAL_ERROR", ex.getMessage());
dialog.labelStatus.setText(MessageFormat.format(OStrings.getString("TAAS_GENERAL_ERROR"), ex.getMessage()));
}
} catch (InterruptedException ex) {
}
}
}.execute();
dialog.btnDownload.addActionListener(DOWNLOAD_LISTENER);
StaticUIUtils.setEscapeClosable(dialog);
dialog.btnClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
dialog.setLocationRelativeTo(Core.getMainWindow().getApplicationFrame());
dialog.setVisible(true);
}
use of gen.taas.TaasCollection in project omegat by omegat-org.
the class BrowseTaasCollectionsController method removeUnusedCollections.
/**
* Removes collections with zero terms count.
*/
static void removeUnusedCollections(List<TaasCollection> list) {
final Language sourceLang = Core.getProject().getProjectProperties().getSourceLanguage();
final Language targetLang = Core.getProject().getProjectProperties().getTargetLanguage();
for (int i = 0; i < list.size(); i++) {
TaasCollection c = list.get(i);
if (getCountForLanguage(c, sourceLang) == 0 || getCountForLanguage(c, targetLang) == 0) {
list.remove(i);
i--;
}
}
}
Aggregations