use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class ExternalFinder method getProjectConfig.
/**
* Get the project-specific configuration.
*
* @return The configuration, or null if no project is loaded or the project
* has no config file
*/
public static ExternalFinderConfiguration getProjectConfig() {
IProject currentProject = Core.getProject();
if (!currentProject.isProjectLoaded()) {
return null;
}
if (projectConfig == null) {
// load project's xml file
File projectFile = getProjectFile(currentProject);
IExternalFinderItemLoader projectItemLoader = new ExternalFinderXMLLoader(projectFile, SCOPE.PROJECT);
try {
projectConfig = projectItemLoader.load();
} catch (FileNotFoundException e) {
// Ignore
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
return projectConfig;
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class DictionariesTextArea method onProjectOpen.
@Override
protected void onProjectOpen() {
clear();
IProject project = Core.getProject();
tokenizer = project.getSourceTokenizer();
manager.setIndexLanguage(project.getProjectProperties().getSourceLanguage());
manager.setTokenizer(tokenizer);
manager.start(new File(project.getProjectProperties().getDictRoot()));
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class EditorController method setFilter.
/**
* {@inheritDoc} Document is reloaded to immediately have the filter being
* effective.
*/
public void setFilter(IEditorFilter filter) {
UIThreadsUtil.mustBeSwingThread();
if (entriesFilterControlComponent != null) {
pane.remove(entriesFilterControlComponent);
}
entriesFilter = filter;
entriesFilterControlComponent = filter.getControlComponent();
pane.add(entriesFilterControlComponent, BorderLayout.NORTH);
pane.revalidate();
SourceTextEntry curEntry = getCurrentEntry();
Document3 doc = editor.getOmDocument();
IProject project = Core.getProject();
// Prevent NullPointerErrors in loadDocument. Only load if there is a document.
if (doc != null && project != null && project.getProjectFiles() != null && curEntry != null) {
int curEntryNum = curEntry.entryNum();
// rebuild entrylist
loadDocument();
if (entriesFilter == null || entriesFilter.allowed(curEntry)) {
gotoEntry(curEntry.entryNum());
} else {
// filtered entry could have been if it was not filtered.
for (int j = 0; j < m_docSegList.length; j++) {
if (m_docSegList[j].segmentNumberInProject >= curEntryNum) {
//
displayedEntryIndex = j - 1;
break;
}
}
nextEntry();
}
}
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class EditorController method showStat.
/**
* Calculate statistic for file, request statistic for project and display in status bar.
*/
public void showStat() {
IProject project = Core.getProject();
IProject.FileInfo fi = project.getProjectFiles().get(displayedFileIndex);
int translatedInFile = 0;
int translatedUniqueInFile = 0;
int uniqueInFile = 0;
boolean isUnique;
for (SourceTextEntry ste : fi.entries) {
isUnique = ste.getDuplicate() != SourceTextEntry.DUPLICATE.NEXT;
if (isUnique) {
uniqueInFile++;
}
if (project.getTranslationInfo(ste).isTranslated()) {
translatedInFile++;
if (isUnique) {
translatedUniqueInFile++;
}
}
}
StatisticsInfo stat = project.getStatistics();
final MainWindowUI.StatusBarMode progressMode = Preferences.getPreferenceEnumDefault(Preferences.SB_PROGRESS_MODE, MainWindowUI.StatusBarMode.DEFAULT);
if (progressMode == MainWindowUI.StatusBarMode.DEFAULT) {
StringBuilder pMsg = new StringBuilder(1024).append(" ");
pMsg.append(translatedInFile).append("/").append(fi.entries.size()).append(" (").append(stat.numberofTranslatedSegments).append("/").append(stat.numberOfUniqueSegments).append(", ").append(stat.numberOfSegmentsTotal).append(") ");
mw.showProgressMessage(pMsg.toString());
} else {
/*
* Percentage mode based on idea by Yu Tang
* http://dirtysexyquery.blogspot.tw/2013/03/omegat-custom-progress-format.html
*/
java.text.NumberFormat nfPer = java.text.NumberFormat.getPercentInstance();
nfPer.setRoundingMode(java.math.RoundingMode.DOWN);
nfPer.setMaximumFractionDigits(1);
String message = StringUtil.format(OStrings.getString("MW_PROGRESS_DEFAULT_PERCENTAGE"), (translatedUniqueInFile == 0) ? "0%" : nfPer.format((double) translatedUniqueInFile / uniqueInFile), uniqueInFile - translatedUniqueInFile, (stat.numberofTranslatedSegments == 0) ? "0%" : nfPer.format((double) stat.numberofTranslatedSegments / stat.numberOfUniqueSegments), stat.numberOfUniqueSegments - stat.numberofTranslatedSegments, stat.numberOfSegmentsTotal);
mw.showProgressMessage(message);
}
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class HistoryCompleter method train.
synchronized void train() {
IProject project = Core.getProject();
if (!project.isProjectLoaded()) {
return;
}
long start = System.currentTimeMillis();
wordCompleter.reset();
project.iterateByDefaultTranslations((source, trans) -> trainString(trans.translation));
project.iterateByMultipleTranslations((source, trans) -> trainString(trans.translation));
long time = System.currentTimeMillis() - start;
LOGGER.finer(() -> String.format("Time to train History Completer: %d ms", time));
}
Aggregations