[SubtitlesAdjuster]
[aprog.git] / SubtitlesAdjuster / src / net / sourceforge / aprog / subtitlesadjuster / SubtitlesAdjuster.java
blob683bb63e43e52b4d7eae311921b21234d659613d
1 /*
2 * The MIT License
4 * Copyright 2010 Codist Monk.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 package net.sourceforge.aprog.subtitlesadjuster;
27 import static net.sourceforge.aprog.i18n.Messages.*;
28 import static net.sourceforge.aprog.subtitlesadjuster.Constants.*;
29 import static net.sourceforge.aprog.subtitlesadjuster.Constants.Variables.*;
30 import static net.sourceforge.aprog.subtitlesadjuster.SubtitlesAdjusterTools.*;
31 import static net.sourceforge.aprog.swing.SwingTools.*;
32 import static net.sourceforge.aprog.tools.Tools.*;
34 import java.util.Date;
36 import net.sourceforge.aprog.context.Context;
37 import net.sourceforge.jmacadapter.MacAdapterTools;
39 /**
41 * @author codistmonk (creation 2010-06-26)
43 public final class SubtitlesAdjuster {
45 /**
46 * Private default constructor to prevent instantiation.
48 private SubtitlesAdjuster() {
49 // Do nothing
52 static {
53 MacAdapterTools.setApplicationName(APPLICATION_NAME);
54 useSystemLookAndFeel();
55 setMessagesBase(getCallerPackagePath() + "Messages");
58 /**
59 * @param arguments the command line arguments
60 * <br>Not null
61 * <br>Shared
62 * <br>Unused
64 public static final void main(final String[] arguments) {
65 if (canInvokeThisMethodInAWT(null, (Object) arguments)) {
66 Components.createMainFrame(createContext()).setVisible(true);
70 /**
72 * @return
73 * <br>Not null
74 * <br>New
76 public static final Context createContext() {
77 final Context result = new Context();
79 result.set(FILE, null);
80 result.set(FILE_MODIFIED, false);
81 result.set(FIRST_TIME, new Date(0L));
82 result.set(LAST_TIME, new Date(0L));
84 new Subtitles(result);
86 setFileModifiedOnVariableChanged(result, FIRST_TIME, true);
87 setFileModifiedOnVariableChanged(result, LAST_TIME, true);
88 setFileModifiedOnVariableChanged(result, FILE, false);
90 return result;
93 /**
95 * @param context
96 * <br>Not null
97 * @param variableName
98 * <br>Not null
99 * @param value
101 private static final void setFileModifiedOnVariableChanged(
102 final Context context, final String variableName, final boolean value) {
103 invokeOnVariableChanged(context, variableName, context.getVariable(FILE_MODIFIED), "setValue", value);