use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class SegmentPropertiesArea method setProperties.
private void setProperties(SourceTextEntry ste) {
properties.clear();
if (ste != null) {
for (String s : ste.getRawProperties()) {
properties.add(s);
}
if (ste.getDuplicate() != DUPLICATE.NONE) {
setProperty(KEY_ISDUP, ste.getDuplicate());
}
if (ste.getSourceTranslation() != null) {
setProperty(KEY_TRANSLATION, ste.getSourceTranslation());
if (ste.isSourceTranslationFuzzy()) {
setProperty(KEY_TRANSLATIONISFUZZY, true);
}
}
setKeyProperties(ste.getKey());
IProject project = Core.getProject();
if (project.isProjectLoaded()) {
TMXEntry trg = project.getTranslationInfo(ste);
setTranslationProperties(trg);
}
}
viewImpl.update();
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class Searcher method searchProject.
private void searchProject() {
// reset the number of search hits
m_numFinds = 0;
// search the Memory, if requested
if (m_searchExpression.memory) {
// search through all project entries
IProject dataEngine = m_project;
for (int i = 0; i < m_project.getAllEntries().size(); i++) {
// stop searching if the max. nr of hits has been reached
if (m_numFinds >= expression.numberOfResults) {
return;
}
// get the source and translation of the next entry
SourceTextEntry ste = dataEngine.getAllEntries().get(i);
TMXEntry te = m_project.getTranslationInfo(ste);
checkEntry(ste.getSrcText(), te.translation, te.note, ste.getComment(), te, i, null);
checkStop.checkInterrupted();
}
// search in orphaned
if (!m_searchExpression.excludeOrphans) {
m_project.iterateByDefaultTranslations(new IProject.DefaultTranslationsIterator() {
final String file = OStrings.getString("CT_ORPHAN_STRINGS");
public void iterate(String source, TMXEntry en) {
// stop searching if the max. nr of hits has been reached
if (m_numFinds >= expression.numberOfResults) {
return;
}
checkStop.checkInterrupted();
if (m_project.isOrphaned(source)) {
checkEntry(en.source, en.translation, en.note, null, en, ENTRY_ORIGIN_ORPHAN, file);
}
}
});
m_project.iterateByMultipleTranslations(new IProject.MultipleTranslationsIterator() {
final String file = OStrings.getString("CT_ORPHAN_STRINGS");
public void iterate(EntryKey source, TMXEntry en) {
// reached
if (m_numFinds >= expression.numberOfResults) {
return;
}
checkStop.checkInterrupted();
if (m_project.isOrphaned(source)) {
checkEntry(en.source, en.translation, en.note, null, en, ENTRY_ORIGIN_ORPHAN, file);
}
}
});
}
}
// search the TM, if requested
if (m_searchExpression.tm) {
// that case.
if (!expression.searchAuthor && !expression.searchDateAfter && !expression.searchDateBefore) {
for (Map.Entry<String, ExternalTMX> tmEn : m_project.getTransMemories().entrySet()) {
final String fileTM = tmEn.getKey();
if (!searchEntries(tmEn.getValue().getEntries(), fileTM)) {
return;
}
checkStop.checkInterrupted();
}
for (Map.Entry<Language, ProjectTMX> tmEn : m_project.getOtherTargetLanguageTMs().entrySet()) {
final Language langTM = tmEn.getKey();
if (!searchEntriesAlternative(tmEn.getValue().getDefaults(), langTM.getLanguage())) {
return;
}
if (!searchEntriesAlternative(tmEn.getValue().getAlternatives(), langTM.getLanguage())) {
return;
}
checkStop.checkInterrupted();
}
}
}
// search the glossary, if requested
if (m_searchExpression.glossary) {
String intro = OStrings.getString("SW_GLOSSARY_RESULT");
List<GlossaryEntry> entries = Core.getGlossaryManager().getLocalEntries();
for (GlossaryEntry en : entries) {
checkEntry(en.getSrcText(), en.getLocText(), null, null, null, ENTRY_ORIGIN_GLOSSARY, intro);
// stop searching if the max. nr of hits has been reached
if (m_numFinds >= expression.numberOfResults) {
return;
}
checkStop.checkInterrupted();
}
}
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class CalcStandardStatistics method run.
@Override
public void run() {
IProject p = Core.getProject();
String result = buildProjectStats(p, null, callback);
callback.setTextData(result);
callback.finishData();
String internalDir = p.getProjectProperties().getProjectInternal();
// removing old stats
try {
File oldstats = new File(internalDir + "word_counts");
if (oldstats.exists()) {
oldstats.delete();
}
} catch (Exception e) {
}
// now dump file based word counts to disk
String fn = internalDir + OConsts.STATS_FILENAME;
Statistics.writeStat(fn, result);
callback.setDataFile(fn);
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class ExternalFinder method setProjectConfig.
/**
* Set the project-specific configuration. Has no effect if no project is
* loaded. Any existing configuration file will be overwritten with the new
* one. Pass null to delete the config file.
*/
public static void setProjectConfig(ExternalFinderConfiguration newConfig) {
IProject currentProject = Core.getProject();
if (!currentProject.isProjectLoaded()) {
return;
}
ExternalFinderConfiguration oldConfig = projectConfig;
projectConfig = newConfig;
if (!Objects.equals(newConfig, oldConfig)) {
File projectFile = getProjectFile(currentProject);
writeConfig(newConfig, projectFile);
}
}
use of org.omegat.core.data.IProject in project omegat by omegat-org.
the class EditorController method gotoEntry.
public void gotoEntry(final int entryNum, final CaretPosition pos) {
UIThreadsUtil.mustBeSwingThread();
if (!Core.getProject().isProjectLoaded()) {
return;
}
if (m_docSegList == null) {
// document didn't loaded yet
return;
}
Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
Cursor oldCursor = editor.getCursor();
editor.setCursor(hourglassCursor);
commitAndDeactivate();
if (entryNum == 0) {
// it was empty project, need to display first entry
displayedFileIndex = 0;
displayedEntryIndex = 0;
loadDocument();
} else {
IProject dataEngine = Core.getProject();
for (int i = 0; i < dataEngine.getProjectFiles().size(); i++) {
IProject.FileInfo fi = dataEngine.getProjectFiles().get(i);
SourceTextEntry firstEntry = fi.entries.get(0);
SourceTextEntry lastEntry = fi.entries.get(fi.entries.size() - 1);
if (firstEntry.entryNum() <= entryNum && lastEntry.entryNum() >= entryNum) {
// this file
if (i != displayedFileIndex) {
// it's other file than displayed
displayedFileIndex = i;
loadDocument();
}
// find correct displayedEntryIndex
for (int j = 0; j < m_docSegList.length; j++) {
if (m_docSegList[j].segmentNumberInProject >= entryNum) {
//
displayedEntryIndex = j;
break;
}
}
break;
}
}
}
activateEntry(pos);
editor.setCursor(oldCursor);
}
Aggregations