package de.todesbaum.jsite.main;
+import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Date;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import de.todesbaum.jsite.gui.ProjectPage;
import de.todesbaum.jsite.i18n.I18n;
import de.todesbaum.jsite.i18n.I18nContainer;
+import de.todesbaum.jsite.main.Configuration.ConfigurationDirectory;
import de.todesbaum.util.image.IconLoader;
import de.todesbaum.util.swing.TWizard;
import de.todesbaum.util.swing.TWizardPage;
private static final Logger logger = Logger.getLogger(Main.class.getName());
/** The version. */
- private static final Version VERSION = new Version(0, 8);
+ private static final Version VERSION = new Version(0, 9, 2);
/** The configuration. */
private Configuration configuration;
if (configFilename != null) {
configuration = new Configuration(configFilename);
} else {
- configuration = new Configuration();
+ /* are we executed from a JAR file? */
+ String resource = getClass().getResource("/de/todesbaum/jsite/i18n/jSite.properties").toString();
+ if (resource.startsWith("jar:")) {
+ String jarFileLocation = resource.substring(9, resource.indexOf(".jar!") + 4);
+ String jarFileDirectory = new File(jarFileLocation).getParent();
+ File configurationFile = new File(jarFileDirectory, "jSite.conf");
+ if (configurationFile.exists()) {
+ configuration = new Configuration(configurationFile.getAbsolutePath());
+ configuration.setConfigurationDirectory(ConfigurationDirectory.NEXT_TO_JAR_FILE);
+ }
+ }
+ if (configuration == null) {
+ configuration = new Configuration();
+ }
}
Locale.setDefault(configuration.getLocale());
I18n.setLocale(configuration.getLocale());
nodeMenu.setEnabled(false);
optionsPreferencesAction.setEnabled(false);
} else if ("page.project.insert".equals(pageName)) {
- showPage(PageType.PAGE_PROJECTS);
- nodeMenu.setEnabled(true);
- optionsPreferencesAction.setEnabled(true);
+ ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
+ if (projectInsertPage.isRunning()) {
+ projectInsertPage.stopInsert();
+ } else {
+ showPage(PageType.PAGE_PROJECTS);
+ nodeMenu.setEnabled(true);
+ optionsPreferencesAction.setEnabled(true);
+ }
} else if ("page.preferences".equals(pageName)) {
showPage(PageType.PAGE_PROJECTS);
optionsPreferencesAction.setEnabled(true);
/**
* {@inheritDoc}
*/
+ public void nodeSelected(Node node) {
+ for (Component menuItem : nodeMenu.getMenuComponents()) {
+ if (menuItem instanceof JMenuItem) {
+ if (node.equals(((JMenuItem) menuItem).getClientProperty("Node"))) {
+ ((JMenuItem) menuItem).setSelected(true);
+ }
+ }
+ }
+ freenetInterface.setNode(node);
+ selectedNode = node;
+ }
+
+ //
+ // INTERFACE ActionListener
+ //
+
+ /**
+ * {@inheritDoc}
+ */
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source instanceof JRadioButtonMenuItem) {