• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

OmegaT のメニューバーにフォルダーツリー参照用のメニューを追加します。


Commit MetaInfo

Revision56 (tree)
Time2014-04-30 11:42:28
Authoryu-tang

Log Message

add CurrentSourceFile menu and CurrentTargetFile menu

Change Summary

Incremental Difference

--- trunk/src-stubs/org/omegat/gui/editor/IEditor.java (nonexistent)
+++ trunk/src-stubs/org/omegat/gui/editor/IEditor.java (revision 56)
@@ -0,0 +1,26 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.gui.editor;
6+
7+/**
8+ * Interface for access to editor functionality.
9+ *
10+ * Almost all methods must be called from UI thread.
11+ *
12+ * @author Alex Buloichik (alex73mail@gmail.com)
13+ * @author Didier Briel
14+ * @author Guido Leenders
15+ * @author Aaron Madlon-Kay
16+ */
17+public interface IEditor {
18+
19+ /**
20+ * Get current file name which opened in editor.
21+ *
22+ * Can be called from any thread.
23+ */
24+ String getCurrentFile();
25+
26+}
--- trunk/src-stubs/org/omegat/core/Core.java (revision 55)
+++ trunk/src-stubs/org/omegat/core/Core.java (revision 56)
@@ -5,6 +5,8 @@
55 package org.omegat.core;
66
77 import org.omegat.core.data.IProject;
8+import org.omegat.filters2.master.FilterMaster;
9+import org.omegat.gui.editor.IEditor;
810 import org.omegat.gui.main.IMainWindow;
911
1012 /**
@@ -32,9 +34,20 @@
3234 throw new UnsupportedOperationException("This method is only a stub.");
3335 }
3436
37+ /** Get editor instance. */
38+ public static IEditor getEditor() {
39+ throw new UnsupportedOperationException("This method is only a stub.");
40+ }
41+
42+ public static FilterMaster getFilterMaster() {
43+ throw new UnsupportedOperationException("This method is only a stub.");
44+ }
45+
3546 /**
3647 * Any plugin can call this method for say about error on loading.
3748 */
38- public static void pluginLoadingError(String errorText) { }
49+ public static void pluginLoadingError(String errorText) {
50+ throw new UnsupportedOperationException("This method is only a stub.");
51+ }
3952
4053 }
--- trunk/src-stubs/org/omegat/filters2/AbstractFilter.java (nonexistent)
+++ trunk/src-stubs/org/omegat/filters2/AbstractFilter.java (revision 56)
@@ -0,0 +1,107 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.filters2;
6+
7+/**
8+ *
9+ * @author Yu-Tang
10+ */
11+public abstract class AbstractFilter implements IFilter {
12+
13+ /**
14+ * This value represents to the user that the encoding is determined by the filter itself. "In code" the
15+ * <code>null</code> is used to represent automatic encoding selection.
16+ */
17+ public static String ENCODING_AUTO_HUMAN = ""; //OStrings.getString("ENCODING_AUTO");
18+
19+ /** The original filename (with extension). */
20+ public static final String TFP_FILENAME = "${filename}";
21+ /** The original filename without extension. */
22+ public static final String TFP_NAMEONLY = "${nameOnly}";
23+ /** The original file extension. */
24+ public static final String TFP_EXTENSION = "${extension}";
25+ /** "xx_YY", locale code */
26+ public static final String TFP_TARGET_LOCALE = "${targetLocale}";
27+ /** "XX-YY", the TMX/XML language code */
28+ public static final String TFP_TARGET_LANGUAGE = "${targetLanguage}";
29+ /** language "XX" only */
30+ public static final String TFP_TARGET_LANG_CODE = "${targetLanguageCode}";
31+ /** country "YY" only */
32+ public static final String TFP_TARGET_COUNTRY_CODE = "${targetCountryCode}";
33+ /** Old spelling of the variable for country "YY" only */
34+ public static final String TFP_TARGET_COUTRY_CODE = "${targetCoutryCode}";
35+ /** System time at generation time in various patterns. */
36+ public static final String TFP_TIMESTAMP_LA = "${timestamp-a}";
37+ public static final String TFP_TIMESTAMP_LD = "${timestamp-d}";
38+ public static final String TFP_TIMESTAMP_LDD = "${timestamp-dd}";
39+ public static final String TFP_TIMESTAMP_LH = "${timestamp-h}";
40+ public static final String TFP_TIMESTAMP_LHH = "${timestamp-hh}";
41+ public static final String TFP_TIMESTAMP_LM = "${timestamp-m}";
42+ public static final String TFP_TIMESTAMP_LMM = "${timestamp-mm}";
43+ public static final String TFP_TIMESTAMP_LS = "${timestamp-s}";
44+ public static final String TFP_TIMESTAMP_LSS = "${timestamp-ss}";
45+ public static final String TFP_TIMESTAMP_LYYYY = "${timestamp-yyyy}";
46+ public static final String TFP_TIMESTAMP_UD = "${timestamp-D}";
47+ public static final String TFP_TIMESTAMP_UEEE = "${timestamp-EEE}";
48+ public static final String TFP_TIMESTAMP_UEEEE = "${timestamp-EEEE}";
49+ public static final String TFP_TIMESTAMP_UH = "${timestamp-H}";
50+ public static final String TFP_TIMESTAMP_UHH = "${timestamp-HH}";
51+ public static final String TFP_TIMESTAMP_UM = "${timestamp-M}";
52+ public static final String TFP_TIMESTAMP_UMM = "${timestamp-MM}";
53+ public static final String TFP_TIMESTAMP_UMMM = "${timestamp-MMM}";
54+ /** Workstation properties. */
55+ public static final String TFP_SYSTEM_OS_NAME = "${system-os-name}";
56+ public static final String TFP_SYSTEM_OS_VERSION = "${system-os-version}";
57+ public static final String TFP_SYSTEM_OS_ARCH = "${system-os-arch}";
58+ public static final String TFP_SYSTEM_USER_NAME = "${system-user-name}";
59+ public static final String TFP_SYSTEM_HOST_NAME = "${system-host-name}";
60+ /** File properties. */
61+ public static final String TFP_FILE_SOURCE_ENCODING = "${file-source-encoding}";
62+ public static final String TFP_FILE_TARGET_ENCODING = "${file-target-encoding}";
63+ public static final String TFP_FILE_FILTER_NAME = "${file-filter-name}";
64+ /** Microsoft. */
65+ public static final String TFP_TARGET_LOCALE_LCID = "${targetLocaleLCID}";
66+
67+ protected String inEncodingLastParsedFile;
68+
69+ /** All target filename patterns. */
70+ public static final String[] TARGET_FILENAME_PATTERNS = new String[] {
71+ TFP_FILENAME,
72+ TFP_NAMEONLY,
73+ TFP_EXTENSION,
74+ TFP_TARGET_LOCALE,
75+ TFP_TARGET_LOCALE_LCID,
76+ TFP_TARGET_LANGUAGE,
77+ TFP_TARGET_LANG_CODE,
78+ TFP_TARGET_COUNTRY_CODE,
79+ TFP_TIMESTAMP_LA,
80+ TFP_TIMESTAMP_LD,
81+ TFP_TIMESTAMP_LDD,
82+ TFP_TIMESTAMP_LH,
83+ TFP_TIMESTAMP_LHH,
84+ TFP_TIMESTAMP_LM,
85+ TFP_TIMESTAMP_LMM,
86+ TFP_TIMESTAMP_LS,
87+ TFP_TIMESTAMP_LSS,
88+ TFP_TIMESTAMP_LYYYY,
89+ TFP_TIMESTAMP_UD,
90+ TFP_TIMESTAMP_UEEE,
91+ TFP_TIMESTAMP_UEEEE,
92+ TFP_TIMESTAMP_UH,
93+ TFP_TIMESTAMP_UHH,
94+ TFP_TIMESTAMP_UM,
95+ TFP_TIMESTAMP_UMM,
96+ TFP_TIMESTAMP_UMMM,
97+ TFP_SYSTEM_OS_NAME,
98+ TFP_SYSTEM_OS_VERSION,
99+ TFP_SYSTEM_OS_ARCH,
100+ TFP_SYSTEM_USER_NAME,
101+ TFP_SYSTEM_HOST_NAME,
102+ TFP_FILE_SOURCE_ENCODING,
103+ TFP_FILE_TARGET_ENCODING,
104+ TFP_FILE_FILTER_NAME
105+ };
106+
107+}
--- trunk/src-stubs/org/omegat/filters2/FilterContext.java (nonexistent)
+++ trunk/src-stubs/org/omegat/filters2/FilterContext.java (revision 56)
@@ -0,0 +1,27 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.filters2;
6+
7+import org.omegat.core.data.ProjectProperties;
8+import org.omegat.util.Language;
9+
10+public class FilterContext {
11+ public FilterContext(ProjectProperties props) {
12+ throw new UnsupportedOperationException("This method is only a stub.");
13+ }
14+
15+ /** Target language of project. */
16+ public Language getTargetLang() {
17+ throw new UnsupportedOperationException("This method is only a stub.");
18+ }
19+ public void setInEncoding(String inEncoding) {
20+ throw new UnsupportedOperationException("This method is only a stub.");
21+ }
22+
23+ public void setOutEncoding(String outEncoding) {
24+ throw new UnsupportedOperationException("This method is only a stub.");
25+ }
26+
27+}
--- trunk/src-stubs/org/omegat/filters2/master/FilterMaster.java (nonexistent)
+++ trunk/src-stubs/org/omegat/filters2/master/FilterMaster.java (revision 56)
@@ -0,0 +1,50 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.filters2.master;
6+
7+import gen.core.filters.Filter.Option;
8+import gen.core.filters.Filters;
9+import java.util.List;
10+import java.util.Map;
11+import org.omegat.filters2.IFilter;
12+
13+public class FilterMaster {
14+ public Filters getConfig() {
15+ throw new UnsupportedOperationException("This method is only a stub.");
16+ }
17+
18+
19+ /**
20+ * Get filter's instance by filter class name.
21+ *
22+ * @param classname
23+ * filter's class name
24+ * @return filter instance
25+ */
26+ public static IFilter getFilterInstance(final String classname) {
27+ throw new UnsupportedOperationException("This method is only a stub.");
28+ }
29+
30+ /**
31+ * Return current system time in the specified date format.
32+ *
33+ * @param dateFormat
34+ * Date format for java.text.SimpleDateFormat.
35+ */
36+ public static String now(String dateFormat) {
37+ throw new UnsupportedOperationException("This method is only a stub.");
38+ }
39+
40+ /**
41+ * Convert options from xml for filter usage.
42+ *
43+ * @param options
44+ * xml options
45+ * @return options for filter usage
46+ */
47+ public static Map<String, String> forFilter(List<Option> options) {
48+ throw new UnsupportedOperationException("This method is only a stub.");
49+ }
50+}
--- trunk/src-stubs/org/omegat/filters2/TranslationException.java (nonexistent)
+++ trunk/src-stubs/org/omegat/filters2/TranslationException.java (revision 56)
@@ -0,0 +1,9 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.filters2;
6+
7+public class TranslationException extends Exception {
8+
9+}
--- trunk/src-stubs/org/omegat/filters2/IFilter.java (nonexistent)
+++ trunk/src-stubs/org/omegat/filters2/IFilter.java (revision 56)
@@ -0,0 +1,188 @@
1+/**************************************************************************
2+ OmegaT - Computer Assisted Translation (CAT) tool
3+ with fuzzy matching, translation memory, keyword search,
4+ glossaries, and translation leveraging into updated projects.
5+
6+ Copyright (C) 2009-2010 Alex Buloichik
7+ Home page: http://www.omegat.org/
8+ Support center: http://groups.yahoo.com/group/OmegaT/
9+
10+ This file is part of OmegaT.
11+
12+ OmegaT is free software: you can redistribute it and/or modify
13+ it under the terms of the GNU General Public License as published by
14+ the Free Software Foundation, either version 3 of the License, or
15+ (at your option) any later version.
16+
17+ OmegaT is distributed in the hope that it will be useful,
18+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+ GNU General Public License for more details.
21+
22+ You should have received a copy of the GNU General Public License
23+ along with this program. If not, see <http://www.gnu.org/licenses/>.
24+ **************************************************************************/
25+
26+package org.omegat.filters2;
27+
28+import java.awt.Dialog;
29+import java.io.File;
30+import java.util.Map;
31+
32+/**
33+ * Interface for filters declaration.
34+ *
35+ * TODO: each filter should be stateless, i.e. options shouldn't be stored in filter, but should be sent to
36+ * filter on each parse, align, or translate operation.
37+ *
38+ * Filters shouldn't use Core, but use Context instead.
39+ *
40+ * @author Alex Buloichik (alex73mail@gmail.com)
41+ */
42+public interface IFilter {
43+ /**
44+ * Human-readable name of the File Format this filter supports.
45+ *
46+ * @return File format name
47+ */
48+ String getFileFormatName();
49+
50+ /**
51+ * Returns the hint displayed while the user edits the filter, and when she adds/edits the instance of
52+ * this filter. The hint may be any string, preferably in a non-geek language.
53+ *
54+ * @return The hint for editing the filter in a non-geek language.
55+ */
56+ String getHint();
57+
58+ /**
59+ * The default list of filter instances that this filter class has. One filter class may have different
60+ * filter instances, different by source file mask, encoding of the source file etc.
61+ * <p>
62+ * Note that the user may change the instances freely.
63+ *
64+ * @return Default filter instances
65+ */
66+// Instance[] getDefaultInstances();
67+
68+ /**
69+ * Whether source encoding can be varied by the user.
70+ * <p>
71+ * True means that OmegaT should handle all the encoding mess.
72+ * <p>
73+ * Return false to state that your filter doesn't need encoding management provided by OmegaT, because it
74+ * either autodetects the encoding based on file contents (like HTML filter does) or the encoding is fixed
75+ * (like in OpenOffice files).
76+ *
77+ * @return whether source encoding can be changed by the user
78+ */
79+ boolean isSourceEncodingVariable();
80+
81+ /**
82+ * Whether target encoding can be varied by the user.
83+ * <p>
84+ * True means that OmegaT should handle all the encoding mess.
85+ * <p>
86+ * Return false to state that your filter doesn't need encoding management provided by OmegaT, because the
87+ * encoding is fixed (like in OpenOffice files), or for some other reason.
88+ *
89+ * @return whether target encoding can be changed by the user
90+ */
91+ boolean isTargetEncodingVariable();
92+
93+ /**
94+ * Define fuzzy mark prefix for source which will be stored in TM. It's 'fuzzy' by default, but each
95+ * filter can redefine it.
96+ *
97+ * @return fuzzy mark prefix
98+ */
99+ String getFuzzyMark();
100+
101+ /**
102+ * Returns whether the file is supported by the filter, given the file and possible file's encoding (
103+ * <code>null</code> encoding means autodetect).
104+ * <p>
105+ * For example, DocBook files have .xml extension, as possibly many other XML files, so the filter should
106+ * check a DTD of the document.
107+ *
108+ * @param inFile
109+ * Source file.
110+ * @param config
111+ * filter's configuration options
112+ * @param context
113+ * processing context
114+ * @return Does the filter support the file.
115+ */
116+ boolean isFileSupported(File inFile, Map<String, String> config, FilterContext context);
117+
118+ /**
119+ * Parse single file.
120+ *
121+ * @param inFile
122+ * file to parse
123+ * @param config
124+ * filter's configuration options
125+ * @param context
126+ * processing context
127+ * @param callback
128+ * callback for parsed data
129+ * @throws Exception
130+ */
131+// void parseFile(File inFile, Map<String, String> config, FilterContext context, IParseCallback callback)
132+// throws Exception;
133+
134+ /**
135+ * Create translated file.
136+ *
137+ * @param inFile
138+ * source file
139+ * @param outFile
140+ * output file
141+ * @param config
142+ * filter's configuration options
143+ * @param context
144+ * processing context
145+ * @param callback
146+ * callback for get translation
147+ * @throws Exception
148+ */
149+// void translateFile(File inFile, File outFile, Map<String, String> config, FilterContext context,
150+// ITranslateCallback callback) throws Exception;
151+
152+ /**
153+ * Align source and translated files.
154+ *
155+ * @param inFile
156+ * source file
157+ * @param outFile
158+ * translated file
159+ * @param config
160+ * filter's configuration options
161+ * @param context
162+ * processing context
163+ * @param callback
164+ * callback for store aligned data
165+ * @throws Exception
166+ */
167+// void alignFile(File inFile, File outFile, Map<String, String> config, FilterContext context,
168+// IAlignCallback callback) throws Exception;
169+
170+ boolean hasOptions();
171+
172+ /**
173+ * Show change options dialog for able to change options.
174+ *
175+ * @param parent
176+ * parent window
177+ * @param config
178+ * old options
179+ * @return new options or null if options not changed
180+ */
181+ Map<String, String> changeOptions(Dialog parent, Map<String, String> config);
182+
183+ /**
184+ * Returns the encoding of the last parsed source file.
185+ * @return the encoding of the last parsed source file, or null when no file has been parsed yet.
186+ */
187+ String getInEncodingLastParsedFile();
188+}
--- trunk/src-stubs/org/omegat/util/Language.java (nonexistent)
+++ trunk/src-stubs/org/omegat/util/Language.java (revision 56)
@@ -0,0 +1,49 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package org.omegat.util;
6+
7+public class Language implements Comparable<Object> {
8+
9+ @Override
10+ public int compareTo(Object o) {
11+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
12+ }
13+
14+ /**
15+ * Returns a string representation as an ISO language code (XX-YY).
16+ */
17+ public String getLanguage() {
18+ throw new UnsupportedOperationException("This method is only a stub.");
19+ }
20+
21+ /**
22+ * Returns a string representation as a Java locale (xx_YY).
23+ */
24+ public String getLocaleCode() {
25+ throw new UnsupportedOperationException("This method is only a stub.");
26+ }
27+
28+ /**
29+ * Returns a string representation as a Microsoft locale (xx-yy).
30+ */
31+ public String getLocaleLCID() {
32+ throw new UnsupportedOperationException("This method is only a stub.");
33+ }
34+
35+ /**
36+ * Returns only a language (XX).
37+ */
38+ public String getLanguageCode() {
39+ throw new UnsupportedOperationException("This method is only a stub.");
40+ }
41+
42+ /**
43+ * Returns only a country (YY).
44+ */
45+ public String getCountryCode() {
46+ throw new UnsupportedOperationException("This method is only a stub.");
47+ }
48+
49+}
--- trunk/src-stubs/gen/core/filters/Files.java (nonexistent)
+++ trunk/src-stubs/gen/core/filters/Files.java (revision 56)
@@ -0,0 +1,109 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package gen.core.filters;
6+
7+/**
8+ *
9+ * @author Yu-Tang
10+ */
11+public class Files {
12+
13+ /**
14+ * Gets the value of the sourceFilenameMask property.
15+ *
16+ * @return
17+ * possible object is
18+ * {@link String }
19+ *
20+ */
21+ public String getSourceFilenameMask() {
22+ throw new UnsupportedOperationException("This method is only a stub.");
23+ }
24+
25+ /**
26+ * Sets the value of the sourceFilenameMask property.
27+ *
28+ * @param value
29+ * allowed object is
30+ * {@link String }
31+ *
32+ */
33+ public void setSourceFilenameMask(String value) {
34+ throw new UnsupportedOperationException("This method is only a stub.");
35+ }
36+
37+ /**
38+ * Gets the value of the targetFilenamePattern property.
39+ *
40+ * @return
41+ * possible object is
42+ * {@link String }
43+ *
44+ */
45+ public String getTargetFilenamePattern() {
46+ throw new UnsupportedOperationException("This method is only a stub.");
47+ }
48+
49+ /**
50+ * Sets the value of the targetFilenamePattern property.
51+ *
52+ * @param value
53+ * allowed object is
54+ * {@link String }
55+ *
56+ */
57+ public void setTargetFilenamePattern(String value) {
58+ throw new UnsupportedOperationException("This method is only a stub.");
59+ }
60+
61+ /**
62+ * Gets the value of the sourceEncoding property.
63+ *
64+ * @return
65+ * possible object is
66+ * {@link String }
67+ *
68+ */
69+ public String getSourceEncoding() {
70+ throw new UnsupportedOperationException("This method is only a stub.");
71+ }
72+
73+ /**
74+ * Sets the value of the sourceEncoding property.
75+ *
76+ * @param value
77+ * allowed object is
78+ * {@link String }
79+ *
80+ */
81+ public void setSourceEncoding(String value) {
82+ throw new UnsupportedOperationException("This method is only a stub.");
83+ }
84+
85+ /**
86+ * Gets the value of the targetEncoding property.
87+ *
88+ * @return
89+ * possible object is
90+ * {@link String }
91+ *
92+ */
93+ public String getTargetEncoding() {
94+ throw new UnsupportedOperationException("This method is only a stub.");
95+ }
96+
97+ /**
98+ * Sets the value of the targetEncoding property.
99+ *
100+ * @param value
101+ * allowed object is
102+ * {@link String }
103+ *
104+ */
105+ public void setTargetEncoding(String value) {
106+ throw new UnsupportedOperationException("This method is only a stub.");
107+ }
108+
109+}
--- trunk/src-stubs/gen/core/filters/Filter.java (nonexistent)
+++ trunk/src-stubs/gen/core/filters/Filter.java (revision 56)
@@ -0,0 +1,29 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package gen.core.filters;
6+
7+import java.util.List;
8+
9+public class Filter {
10+
11+ public List<Files> getFiles() {
12+ throw new UnsupportedOperationException("This method is only a stub.");
13+ }
14+
15+ public List<Filter.Option> getOption() {
16+ throw new UnsupportedOperationException("This method is only a stub.");
17+ }
18+
19+ public String getClassName() {
20+ throw new UnsupportedOperationException("This method is only a stub.");
21+ }
22+
23+ public boolean isEnabled() {
24+ throw new UnsupportedOperationException("This method is only a stub.");
25+ }
26+
27+ public static class Option {
28+ }
29+}
--- trunk/src-stubs/gen/core/filters/Filters.java (nonexistent)
+++ trunk/src-stubs/gen/core/filters/Filters.java (revision 56)
@@ -0,0 +1,17 @@
1+/**************************************************************************
2+ This code is only a stub.
3+ **************************************************************************/
4+
5+package gen.core.filters;
6+
7+import java.util.List;
8+
9+/**
10+ *
11+ * @author Yu-Tang
12+ */
13+public class Filters {
14+ public List<Filter> getFilters() {
15+ throw new UnsupportedOperationException("This method is only a stub.");
16+ }
17+}
--- trunk/nbproject/project.xml (revision 55)
+++ trunk/nbproject/project.xml (revision 56)
@@ -2,6 +2,11 @@
22 <project xmlns="http://www.netbeans.org/ns/project/1">
33 <type>org.netbeans.modules.java.j2seproject</type>
44 <configuration>
5+ <buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1">
6+ <extension file="groovy-build.xml" id="groovy">
7+ <dependency dependsOn="-groovy-init-macrodef-javac" target="-pre-pre-compile"/>
8+ </extension>
9+ </buildExtensions>
510 <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
611 <name>FolderMenu</name>
712 <source-roots>
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/MenuManager.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/MenuManager.java (revision 56)
@@ -20,7 +20,9 @@
2020 import java.io.IOException;
2121 import javax.swing.JMenu;
2222 import javax.swing.JMenuBar;
23+import javax.swing.JSeparator;
2324 import org.omegat.core.Core;
25+import org.omegat.util.FileUtil;
2426 import org.omegat.util.Log;
2527 import org.omegat.util.StaticUtils;
2628 import org.openide.awt.Mnemonics;
@@ -27,13 +29,14 @@
2729
2830 /**
2931 *
30- * @author Yu-Tang
32+ * @author Yu Tang
3133 */
3234 public class MenuManager {
3335
3436 private JMenu root;
35- private JMenu currentProject;
36- private JMenu userConfig;
37+ private ShellLinkMenu currentProject;
38+ private ShellLinkMenuItem currentSourceFile;
39+ private ShellLinkMenuItem currentTargetFile;
3740
3841 public MenuManager() {
3942 root = createLocalizedMenu(L10n.getFoldersMenuLabel()); // Folders menu
@@ -42,7 +45,8 @@
4245
4346 // ProjectRoot
4447 try {
45- root.add(currentProject = new ShellLinkMenu(L10n.getProjectRootMenuLabel()).getMenu());
48+ currentProject = new ShellLinkMenu(L10n.getProjectRootMenuLabel());
49+ root.add(currentProject.getMenu());
4650 } catch (IOException ex) {
4751 Log.log(ex);
4852 return;
@@ -51,11 +55,22 @@
5155 // User Config
5256 try {
5357 File confDir = new File(StaticUtils.getConfigDir());
54- root.add(userConfig = new ShellLinkMenu(confDir, L10n.getUserConfigMenuLabel()).getMenu());
58+ root.add(new ShellLinkMenu(confDir, L10n.getUserConfigMenuLabel()).getMenu());
5559 } catch (IOException ex) {
5660 Log.log(ex);
5761 }
58-
62+
63+ // ---- separator ----
64+ root.add(new JSeparator());
65+
66+ // Current Source File
67+ currentSourceFile = new ShellLinkMenuItem(L10n.getCurrentSourceFileNoneMenuLabel());
68+ root.add(currentSourceFile.getMenuItem());
69+
70+ // Current Target File
71+ currentTargetFile = new ShellLinkMenuItem(L10n.getCurrentTargetFileNoneMenuLabel());
72+ root.add(currentTargetFile.getMenuItem());
73+
5974 // insert Files menu before the last menu (Help menu.)
6075 JMenuBar mainMenuBar = (JMenuBar) Core.getMainWindow().getMainMenu().getOptionsMenu().getParent();
6176 mainMenuBar.add(root, mainMenuBar.getMenuCount() - 1);
@@ -64,7 +79,7 @@
6479 public void createProjectItems() {
6580 File rootDir = new File(Core.getProject().getProjectProperties().getProjectRoot());
6681 try {
67- new ShellLinkMenu(currentProject).link(rootDir);
82+ currentProject.link(rootDir);
6883 } catch (IOException ex) {
6984 Log.log(ex);
7085 }
@@ -71,9 +86,31 @@
7186 }
7287
7388 public void removeAllProjectItems() {
74- new ShellLinkMenu(currentProject).unlink();
89+ currentProject.unlink();
7590 }
76-
91+
92+ public void linkCurrentSourceFile(File file) throws IOException {
93+ String sourceRoot = Core.getProject().getProjectProperties().getSourceRoot();
94+ String midName = FileUtil.computeRelativePath(new File(sourceRoot), file);
95+ String label = StaticUtils.format(L10n.getCurrentSourceFileMenuLabel(), midName);
96+ currentSourceFile.link(file, label);
97+ }
98+
99+ public void unlinkCurrentSourceFile() {
100+ currentSourceFile.unlink(L10n.getCurrentSourceFileNoneMenuLabel());
101+ }
102+
103+ public void linkCurrentTargetFile(File file) throws IOException {
104+ String targetRoot = Core.getProject().getProjectProperties().getTargetRoot();
105+ String midName = FileUtil.computeRelativePath(new File(targetRoot), file);
106+ String label = StaticUtils.format(L10n.getCurrentTargetFileMenuLabel(), midName);
107+ currentTargetFile.link(file, label);
108+ }
109+
110+ public void unlinkCurrentTargetFile() {
111+ currentTargetFile.unlink(L10n.getCurrentTargetFileNoneMenuLabel());
112+ }
113+
77114 private JMenu createLocalizedMenu(String labelString) {
78115 JMenu m = new JMenu();
79116 Mnemonics.setLocalizedText(m, labelString);
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/FolderMenu.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/FolderMenu.java (revision 56)
@@ -61,6 +61,7 @@
6161 @Override
6262 public void onApplicationStartup() {
6363 menuManager = new MenuManager();
64+ MenuHelper.setMenuManager(menuManager);
6465 FilePreview.init();
6566 CoreEvents.registerProjectChangeListener(this);
6667 }
@@ -77,6 +78,7 @@
7778 break;
7879 case CLOSE:
7980 menuManager.removeAllProjectItems();
81+ menuManager.unlinkCurrentSourceFile();
8082 break;
8183 }
8284 }
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/VersionInfo.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/VersionInfo.java (revision 56)
@@ -1,7 +1,7 @@
11 /**************************************************************************
22 FolderMenu - easy access to project folders from menu.
33
4- Copyright (C) 2013 Yu Tang
4+ Copyright (C) 2013-2014 Yu Tang
55 Home page: http://sourceforge.jp/users/yu-tang/
66 Support center: http://sourceforge.jp/users/yu-tang/
77
@@ -20,13 +20,13 @@
2020
2121 /**
2222 *
23- * @author Yu-Tang
23+ * @author Yu Tang
2424 */
2525 public class VersionInfo {
2626
2727 private static final String APP_NAME = "FolderMenu";
28- private static final String APP_VERSION = "0.3";
29- private static final String APP_BUILD = "20131024";
28+ private static final String APP_VERSION = "0.4";
29+ private static final String APP_BUILD = "20140430";
3030 private static final String APP_AUTHOR = "Yu-Tang";
3131
3232 public static void main(String[] args) {
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/TempFileCleaner.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/TempFileCleaner.java (revision 56)
@@ -25,7 +25,7 @@
2525 /**
2626 * Cleanup temp files
2727 *
28- * @author Yu-Tang
28+ * @author Yu Tang
2929 */
3030 public class TempFileCleaner {
3131
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/FilePreview.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/FilePreview.java (revision 56)
@@ -31,7 +31,7 @@
3131 /**
3232 * must call init() before using this class.
3333 *
34- * @author Yu-Tang
34+ * @author Yu Tang
3535 */
3636
3737 public class FilePreview {
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/IPreview.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/IPreview.java (revision 56)
@@ -20,7 +20,7 @@
2020
2121 /**
2222 *
23- * @author Yu-Tang
23+ * @author Yu Tang
2424 */
2525 public interface IPreview {
2626
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/WordPreview.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/filepreview/WordPreview.java (revision 56)
@@ -34,7 +34,7 @@
3434 * Word 文書をプレビュー用に開きます。
3535 *
3636 *
37- * @author Yu-Tang
37+ * @author Yu Tang
3838 */
3939 public class WordPreview implements IPreview {
4040
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/MenuHelper.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/MenuHelper.java (revision 56)
@@ -24,6 +24,7 @@
2424 import java.awt.event.MouseListener;
2525 import java.io.File;
2626 import java.io.FileFilter;
27+import java.io.IOException;
2728 import java.util.Comparator;
2829 import javax.swing.Icon;
2930 import javax.swing.JMenu;
@@ -35,10 +36,13 @@
3536 import javax.swing.event.MenuKeyListener;
3637 import javax.swing.event.MenuListener;
3738 import javax.swing.filechooser.FileSystemView;
39+import org.omegat.core.Core;
40+import org.omegat.core.data.IProject;
41+import org.omegat.util.Log;
3842
3943 /**
4044 *
41- * @author Yu-Tang
45+ * @author Yu Tang
4246 */
4347 public class MenuHelper {
4448
@@ -126,8 +130,49 @@
126130 melRoot = new MenuListener() {
127131
128132 @Override
129- public void menuSelected(MenuEvent e) { /* do nothing */ }
133+ public void menuSelected(MenuEvent e) {
130134
135+ // update menuitems for CurrentSourceFile and CurrentTargetFile
136+ IProject project = Core.getProject();
137+ File sourceFile = null;
138+ File translatedFile = null;
139+
140+ if (project.isProjectLoaded()) {
141+ // relative path to the root of Source directory
142+ String currentFile = Core.getEditor().getCurrentFile();
143+ if (currentFile != null) {
144+ String sourceRoot = project.getProjectProperties().getSourceRoot();
145+ sourceFile = new File(sourceRoot + currentFile);
146+ translatedFile = FilterHelper.getTargetFile(currentFile);
147+ }
148+ }
149+
150+ if (sourceFile == null || !sourceFile.isFile()) {
151+ menuManager.unlinkCurrentSourceFile();
152+ menuManager.unlinkCurrentTargetFile();
153+ return;
154+ }
155+
156+ try {
157+ menuManager.linkCurrentSourceFile(sourceFile);
158+ } catch (IOException ex) {
159+ Log.log(ex.getMessage());
160+ menuManager.unlinkCurrentSourceFile();
161+ }
162+
163+ if (translatedFile == null || !translatedFile.isFile()) {
164+ menuManager.unlinkCurrentTargetFile();
165+ } else {
166+ try {
167+ menuManager.linkCurrentTargetFile(translatedFile);
168+ } catch (IOException ex) {
169+ Log.log(ex.getMessage());
170+ menuManager.unlinkCurrentTargetFile();
171+ }
172+ }
173+
174+ }
175+
131176 @Override
132177 public void menuDeselected(MenuEvent e) {
133178 // remove children's all menuitems
@@ -135,8 +180,9 @@
135180 for (Component c: menu.getMenuComponents()) {
136181 if (c instanceof JMenu) {
137182 JMenu m = (JMenu) c;
138- if (m.isEnabled())
183+ if (m.isEnabled()) {
139184 m.removeAll();
185+ }
140186 }
141187 }
142188 }
@@ -214,6 +260,10 @@
214260 return new ShellLinkMenu((JMenu) e.getSource());
215261 }
216262
263+ public static void setMenuManager(MenuManager manager) {
264+ menuManager = manager;
265+ }
266+
217267 private static final FileSystemView fs;
218268 private static final FileFilter ff;
219269 private static final ActionListener al;
@@ -222,5 +272,6 @@
222272 private static final MenuListener mel;
223273 private static final MenuListener melRoot;
224274 private static final Comparator<File> comp;
275+ private static MenuManager menuManager;
225276
226277 }
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/FilterHelper.java (nonexistent)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/FilterHelper.java (revision 56)
@@ -0,0 +1,345 @@
1+/**************************************************************************
2+ FolderMenu - easy access to project folders from menu.
3+
4+ Copyright (C) 2000-2006 Keith Godfrey and Maxym Mykhalchuk
5+ 2005-2006 Henry Pijffers
6+ 2006 Martin Wunderlich
7+ 2006-2007 Didier Briel
8+ 2008 Martin Fleurke, Didier Briel
9+ 2009 Didier Briel, Arno Peters, Alex Buloichik
10+ 2010 Alex Buloichik
11+ 2011 Alex Buloichik, Didier Briel
12+ 2012 Guido Leenders, Thomas Cordonnier
13+ 2013 Alex Buloichik
14+ 2014 Yu Tang
15+
16+ Home page: http://sourceforge.jp/users/yu-tang/
17+ Support center: http://sourceforge.jp/users/yu-tang/pf/
18+
19+ This file is part of plugin for OmegaT.
20+ http://www.omegat.org/
21+
22+ License: GNU GPL version 3 or (at your option) any later version.
23+
24+ You should have received a copy of the GNU General Public License
25+ along with this program. If not, see <http://www.gnu.org/licenses/>.
26+ **************************************************************************/
27+
28+package jp.sourceforge.users.yutang.omegat.plugin.foldermenu;
29+
30+import gen.core.filters.Files;
31+import gen.core.filters.Filter;
32+import gen.core.filters.Filters;
33+import java.io.File;
34+import java.io.IOException;
35+import java.util.Map;
36+import java.util.regex.Pattern;
37+import org.omegat.core.Core;
38+import org.omegat.core.data.ProjectProperties;
39+import org.omegat.filters2.AbstractFilter;
40+import org.omegat.filters2.FilterContext;
41+import org.omegat.filters2.IFilter;
42+import org.omegat.filters2.TranslationException;
43+import org.omegat.filters2.master.FilterMaster;
44+import org.omegat.util.Language;
45+
46+//
47+
48+/**
49+ * Based on org.omegat.filters2.master.FilterMaster#translateFile.
50+ *
51+ * A master class that registers and handles all the filters. Singleton - there can be only one instance of
52+ * this class.
53+ *
54+ * @author Maxym Mykhalchuk
55+ * @author Henry Pijffers
56+ * @author Martin Wunderlich
57+ * @author Didier Briel
58+ * @author Martin Fleurke
59+ * @author Arno Peters
60+ * @author Alex Buloichik (alex73mail@gmail.com)
61+ * @author Guido Leenders
62+ * @author Thomas Cordonnier
63+ * +
64+ * @author Yu-Tang
65+ */
66+public class FilterHelper {
67+
68+ /**
69+ * Get translated file object corresponding to source file.
70+ * It does not check whether a file exists.
71+ *
72+ * @param filename
73+ * Relative source file path to the Source root directory.
74+ * @return File object, can be null.
75+ */
76+ public static File getTargetFile(String filename) {
77+ try {
78+ ProjectProperties props = Core.getProject().getProjectProperties();
79+ String sourcedir = props.getSourceRoot();
80+ String targetdir = props.getTargetRoot();
81+ FilterMaster fm = Core.getFilterMaster();
82+ FilterContext fc = new FilterContext(props);
83+
84+ LookupInformation lookup = lookupFilter(sourcedir + File.separator + filename, fc, fm.getConfig());
85+ if (lookup == null) {
86+ // The file is not supported by any of the filters.
87+ return null;
88+ }
89+
90+ File inFile = new File(sourcedir + File.separator + filename);
91+
92+ String name = inFile.getName();
93+ String path = filename.substring(0, filename.length() - name.length());
94+
95+ File outFile = new File(targetdir
96+ + File.separator
97+ + path
98+ + File.separator
99+ + constructTargetFilename(lookup.outFilesInfo.getSourceFilenameMask(), name,
100+ lookup.outFilesInfo.getTargetFilenamePattern(), fc.getTargetLang(),
101+ lookup.outFilesInfo.getSourceEncoding(), lookup.outFilesInfo.getTargetEncoding(),
102+ lookup.filterObject.getFileFormatName()));
103+ return outFile;
104+ } catch (Exception ex) {
105+ return null;
106+ }
107+ }
108+
109+ static class LookupInformation {
110+ public final Files outFilesInfo;
111+ public final IFilter filterObject;
112+ public final Map<String, String> config;
113+
114+ public LookupInformation(IFilter filterObject, Files outFilesInfo, Map<String, String> config) {
115+ this.filterObject = filterObject;
116+ this.outFilesInfo = outFilesInfo;
117+ this.config = config;
118+ }
119+ }
120+
121+ /**
122+ * Gets the filter according to the source filename provided. In case of failing to find a filter to
123+ * handle the file returns <code>null</code>.
124+ *
125+ * In case of finding an appropriate filter it
126+ * <ul>
127+ * <li>Creates the filter (use <code>OneFilter.getFilter()</code> to get it)
128+ * <li>Creates a reader (use <code>OneFilter.getReader()</code> to get it)
129+ * <li>Checks whether the filter supports the file.
130+ * </ul>
131+ * It <b>does not</b> check whether the filter supports the inFile, i.e. it doesn't call
132+ * <code>isFileSupported</code>
133+ *
134+ *
135+ * @param filename
136+ * The source filename.
137+ * @return The filter to handle the inFile.
138+ */
139+ private static LookupInformation lookupFilter(String filename, FilterContext fc, Filters filters) throws TranslationException,
140+ IOException {
141+ File inFile = new File(filename);
142+ String name = inFile.getName();
143+ String path = inFile.getParent();
144+ if (path == null)
145+ path = "";
146+
147+ for (Filter f : filters.getFilters()) {
148+ if (!f.isEnabled()) {
149+ continue;
150+ }
151+ for (Files ff : f.getFiles()) {
152+ if (matchesMask(name, ff.getSourceFilenameMask())) {
153+ IFilter filterObject;
154+ filterObject = FilterMaster.getFilterInstance(f.getClassName());
155+
156+ if (filterObject != null) {
157+ fc.setInEncoding(ff.getSourceEncoding());
158+ fc.setOutEncoding(ff.getTargetEncoding());
159+ // only for exist filters
160+ Map<String, String> config = FilterMaster.forFilter(f.getOption());
161+ if (!filterObject.isFileSupported(inFile, config, fc)) {
162+ break;
163+ }
164+
165+ return new LookupInformation(filterObject, ff, config);
166+ }
167+ }
168+ }
169+ }
170+ return null;
171+ }
172+
173+ /**
174+ * Construct a target filename according to pattern from a file's name. Filename should be "name.ext",
175+ * without path.
176+ * <p>
177+ * Output filename pattern is pretty complex. <br>
178+ * It may consist of normal characters and some substituted variables. They have the format
179+ * <code>${variableName}</code> and are case insensitive. <br>
180+ * There're such variables:
181+ * <ul>
182+ * <li><code>${filename}</code> - full filename of the input file, both name and extension (default)
183+ * <li><code>${nameOnly}</code> - only the name of the input file without extension part
184+ * <li><code>${extension}</code> - the extension of the input file
185+ * <li><code>${nameOnly-1}</code> - only the name of the input file with first extension
186+ * <li><code>${extension-1}</code> - the extensions, without the first one
187+ * <li><code>${targetLocale}</code> - target locale code (of a form "xx_YY")
188+ * <li><code>${targetLanguage}</code> - the target language and country code together (of a form "XX-YY")
189+ * <li><code>${targetLanguageCode}</code> - the target language only ("XX")
190+ * <li><code>${targetCountryCode}</code> - the target country only ("YY")
191+ * <li><code>${1}, ${2}, ...</code> - variables captured by jokers (* or ?)
192+ * </ul>
193+ * <p>
194+ * Most file filters will use default "<code>${filename}</code>, that leads to the name of translated file
195+ * being the same as the name of source file. But for example the Java(TM) Resource Bundles file filter
196+ * will have the pattern equal to "<code>${nameonly}_${targetlanguage}.${extension}</code> ".
197+ * <p>
198+ * E.g. if you have
199+ * <ul>
200+ * <li>a source filename mask "*.ext1.ext2"
201+ * <li>file name "thisisfile.ext1.ext2"
202+ * </ul>
203+ * Then
204+ * <ul>
205+ * <li><code>${nameOnly}</code> will be equal to "thisisfile"
206+ * <li>and <code>${extension}</code> - "ext1.ext2"
207+ * <li><code>${nameOnly-1}</code> will be equal to "thisisfile.ext1"
208+ * <li>and <code>${extension-1}</code> - "ext2"
209+ * </ul>
210+ *
211+ * @param filename
212+ * Filename to change
213+ * @param pattern
214+ * Pattern, according to which we change the filename
215+ * @return The changed filename
216+ */
217+ private static String constructTargetFilename(String sourceMask, String filename, String pattern,
218+ Language targetLang, String sourceEncoding, String targetEncoding, String filterFormatName) {
219+ int lastStarPos = sourceMask.lastIndexOf('*');
220+ int dot = 0;
221+ if (lastStarPos >= 0) {
222+ // bugfix #1204740
223+ // so where's the dot next to the star
224+ int lastDotPos = sourceMask.indexOf('.', lastStarPos);
225+ // counting chars after the dot
226+ int extlength = sourceMask.length() - lastDotPos;
227+ // going forward this many chars
228+ // and finding the dot we looked for
229+ dot = filename.length() - extlength;
230+ } else {
231+ dot = filename.lastIndexOf('.');
232+ }
233+
234+ String nameOnly = filename;
235+ String extension = "";
236+ if (dot >= 0) {
237+ nameOnly = filename.substring(0, dot);
238+ extension = filename.substring(dot + 1);
239+ }
240+
241+ String res = pattern;
242+ res = res.replace(AbstractFilter.TFP_FILENAME, filename);
243+ res = res.replace(AbstractFilter.TFP_NAMEONLY, nameOnly);
244+ res = res.replace(AbstractFilter.TFP_EXTENSION, extension);
245+
246+ res = res.replace(AbstractFilter.TFP_TARGET_LOCALE, targetLang.getLocaleCode());
247+ res = res.replace(AbstractFilter.TFP_TARGET_LANGUAGE, targetLang.getLanguage());
248+ res = res.replace(AbstractFilter.TFP_TARGET_LANG_CODE, targetLang.getLanguageCode());
249+ res = res.replace(AbstractFilter.TFP_TARGET_COUNTRY_CODE, targetLang.getCountryCode());
250+ // Replace also old variable spelling
251+ res = res.replace(AbstractFilter.TFP_TARGET_COUTRY_CODE, targetLang.getCountryCode());
252+ res = res.replace(AbstractFilter.TFP_TARGET_LOCALE_LCID, targetLang.getLocaleLCID());
253+ //
254+ // System generation time
255+ //
256+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LA, FilterMaster.now("a"));
257+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LD, FilterMaster.now("d"));
258+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LDD, FilterMaster.now("dd"));
259+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LH, FilterMaster.now("h"));
260+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LHH, FilterMaster.now("hh"));
261+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LM, FilterMaster.now("m"));
262+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LMM, FilterMaster.now("mm"));
263+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LS, FilterMaster.now("s"));
264+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LSS, FilterMaster.now("ss"));
265+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_LYYYY, FilterMaster.now("yyyy"));
266+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UD, FilterMaster.now("D"));
267+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UEEE, FilterMaster.now("EEE"));
268+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UEEEE, FilterMaster.now("EEEE"));
269+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UH, FilterMaster.now("H"));
270+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UHH, FilterMaster.now("HH"));
271+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UM, FilterMaster.now("M"));
272+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UMM, FilterMaster.now("MM"));
273+ res = res.replace(AbstractFilter.TFP_TIMESTAMP_UMMM, FilterMaster.now("MMM"));
274+ //
275+ // Workstation properties
276+ //
277+ res = res.replace(AbstractFilter.TFP_SYSTEM_OS_NAME, System.getProperty("os.name"));
278+ res = res.replace(AbstractFilter.TFP_SYSTEM_OS_VERSION, System.getProperty("os.arch"));
279+ res = res.replace(AbstractFilter.TFP_SYSTEM_OS_ARCH, System.getProperty("os.version"));
280+ res = res.replace(AbstractFilter.TFP_SYSTEM_USER_NAME, System.getProperty("user.name"));
281+ String hostName = null;
282+ try {
283+ hostName = java.net.InetAddress.getLocalHost().getHostName();
284+ } catch (java.net.UnknownHostException uhe) {
285+ hostName = "";
286+ }
287+ res = res.replace(AbstractFilter.TFP_SYSTEM_HOST_NAME, hostName);
288+ //
289+ // File properties.
290+ //
291+ String sourceEncodingText = "auto";
292+ if (sourceEncoding != null) {
293+ sourceEncodingText = sourceEncoding;
294+ }
295+ res = res.replace(AbstractFilter.TFP_FILE_SOURCE_ENCODING, sourceEncodingText);
296+ //
297+ String targetEncodingText = "auto";
298+ if (targetEncoding != null) {
299+ targetEncodingText = targetEncoding;
300+ }
301+ res = res.replace(AbstractFilter.TFP_FILE_TARGET_ENCODING, targetEncodingText);
302+ //
303+ res = res.replace(AbstractFilter.TFP_FILE_FILTER_NAME, filterFormatName);
304+ //
305+
306+ String sourceMaskPattern = sourceMask.replaceAll("\\?","(.)").replaceAll("\\*","(.*?)");
307+ java.util.regex.Matcher sourceMatcher = Pattern.compile(sourceMaskPattern).matcher(filename);
308+ if (sourceMatcher.find()) {
309+ for (int i = 1; i <= sourceMatcher.groupCount(); i++) {
310+ res = res.replaceAll("\\$\\{" + i + "\\}", sourceMatcher.group(i));
311+ }
312+ }
313+
314+ String[] splitName = filename.split("\\.");
315+ StringBuffer nameOnlyBuf = new StringBuffer (splitName[0]);
316+ StringBuffer extensionBuf = new StringBuffer (splitName[splitName.length - 1]);
317+ for (int i = 0; i < splitName.length; i++) {
318+ res = res.replaceAll ("\\$\\{nameOnly-" + i + "\\}", nameOnlyBuf.toString());
319+ res = res.replaceAll ("\\$\\{extension-" + i + "\\}", extensionBuf.toString());
320+ if (i + 1 < splitName.length) {
321+ nameOnlyBuf.append (".").append(splitName[i + 1]);
322+ extensionBuf.insert(0, splitName[splitName.length - i - 2] + '.');
323+ }
324+ }
325+
326+ return res;
327+ }
328+
329+ /**
330+ * Whether the mask matches the filename. Filename should be "name.ext", without path.
331+ *
332+ * @param filename
333+ * The filename to check
334+ * @param mask
335+ * The mask, against which the filename is tested
336+ * @return Whether the mask matches the filename.
337+ */
338+ private static boolean matchesMask(String filename, String mask) {
339+ mask = mask.replaceAll("\\.", "\\\\.");
340+ mask = mask.replaceAll("\\*", ".*");
341+ mask = mask.replaceAll("\\?", ".");
342+ return filename.matches("(?iu)" + mask);
343+ }
344+
345+}
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/ShellLinkMenuItem.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/ShellLinkMenuItem.java (revision 56)
@@ -21,20 +21,15 @@
2121 import java.io.IOException;
2222 import javax.swing.JMenuItem;
2323 import org.omegat.core.Core;
24-import static jp.sourceforge.users.yutang.omegat.plugin.foldermenu.MenuHelper.getActionListener;
25-import static jp.sourceforge.users.yutang.omegat.plugin.foldermenu.MenuHelper.getIcon;
2624 import jp.sourceforge.users.yutang.omegat.plugin.foldermenu.filepreview.FilePreview;
2725 import org.omegat.util.Log;
28-import static org.omegat.util.Platform.OsType.MAC32;
29-import static org.omegat.util.Platform.OsType.MAC64;
30-import static org.omegat.util.Platform.OsType.WIN32;
31-import static org.omegat.util.Platform.OsType.WIN64;
26+import static org.omegat.util.Platform.OsType.*;
3227 import static org.omegat.util.Platform.getOsType;
3328 import org.omegat.util.StaticUtils;
3429
3530 /**
3631 *
37- * @author Yu-Tang
32+ * @author Yu Tang
3833 */
3934 public class ShellLinkMenuItem {
4035
@@ -49,11 +44,16 @@
4944 }
5045
5146 public ShellLinkMenuItem(File file) throws IOException {
52- JMenuItem m = new JMenuItem(file.getName(), getIcon(file));
47+ JMenuItem m = new JMenuItem(file.getName(), MenuHelper.getIcon(file));
5348 m.setActionCommand(file.getCanonicalPath());
54- m.addActionListener(getActionListener());
49+ m.addActionListener(MenuHelper.getActionListener());
5550 menuItem = m;
5651 }
52+
53+ public ShellLinkMenuItem(String label) {
54+ menuItem = new JMenuItem(label);
55+ menuItem.setEnabled(false);
56+ }
5757
5858 public boolean isEnabled() {
5959 return menuItem.isEnabled();
@@ -63,9 +63,32 @@
6363 return menuItem;
6464 }
6565
66+ public void link(File file, String label) throws IOException {
67+ menuItem.setActionCommand(file.getCanonicalPath());
68+ menuItem.setIcon(MenuHelper.getIcon(file));
69+ menuItem.setEnabled(true);
70+ menuItem.setText(label);
71+ if (menuItem.getActionListeners().length == 0) {
72+ menuItem.addActionListener(MenuHelper.getActionListener());
73+ }
74+ }
75+
76+ public void unlink(String label) {
77+ menuItem.setEnabled(false);
78+ menuItem.setActionCommand("");
79+ menuItem.setIcon(null);
80+ menuItem.setText(label);
81+
82+
83+
84+
85+
86+ }
87+
6688 public void open() {
67- if (! menuItem.isEnabled())
89+ if (! menuItem.isEnabled()) {
6890 return;
91+ }
6992
7093 String path = menuItem.getActionCommand();
7194 try {
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/L10n.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/L10n.java (revision 56)
@@ -20,7 +20,7 @@
2020
2121 /**
2222 *
23- * @author Yu-Tang
23+ * @author Yu Tang
2424 */
2525 public class L10n {
2626
@@ -43,6 +43,22 @@
4343 public static String getUserConfigMenuLabel() {
4444 return bundle.getString("USER_CONFIG_MENU_LABEL");
4545 }
46+
47+ public static String getCurrentSourceFileNoneMenuLabel() {
48+ return bundle.getString("CURRENT_SOURCE_FILE_NONE_MENU_LABEL");
49+ }
50+
51+ public static String getCurrentTargetFileNoneMenuLabel() {
52+ return bundle.getString("CURRENT_TARGET_FILE_NONE_MENU_LABEL");
53+ }
54+
55+ public static String getCurrentSourceFileMenuLabel() {
56+ return bundle.getString("CURRENT_SOURCE_FILE_MENU_LABEL");
57+ }
58+
59+ public static String getCurrentTargetFileMenuLabel() {
60+ return bundle.getString("CURRENT_TARGET_FILE_MENU_LABEL");
61+ }
4662
4763 // for Word
4864
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/ShellLinkMenu.java (revision 55)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/foldermenu/ShellLinkMenu.java (revision 56)
@@ -30,7 +30,7 @@
3030
3131 /**
3232 *
33- * @author Yu-Tang
33+ * @author Yu Tang
3434 */
3535 public class ShellLinkMenu extends ShellLinkMenuItem {
3636