You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(10) |
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(35) |
Feb
(12) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(39) |
Sep
(13) |
Oct
|
Nov
|
Dec
(4) |
From: <ch...@us...> - 2008-12-17 00:22:58
|
Revision: 226 http://opencds.svn.sourceforge.net/opencds/?rev=226&view=rev Author: chl501 Date: 2008-12-17 00:22:55 +0000 (Wed, 17 Dec 2008) Log Message: ----------- Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java 2008-12-13 17:53:21 UTC (rev 225) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java 2008-12-17 00:22:55 UTC (rev 226) @@ -128,7 +128,10 @@ { ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); - cfgMgr.setValue("Application.MinimizeToTray", String.valueOf(m_MinimizeToTray.isSelected())); + if (Tray.isTraySupported) + { + cfgMgr.setValue("Application.MinimizeToTray", String.valueOf(m_MinimizeToTray.isSelected())); + } cfgMgr.setValue("Application.ShowMemoryStatus", String.valueOf(m_ShowMemoryStatus.isSelected())); cfgMgr.setValue("Application.EnableTooltips", String.valueOf(m_EnableTooltips.isSelected())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ch...@us...> - 2008-12-13 17:53:35
|
Revision: 225 http://opencds.svn.sourceforge.net/opencds/?rev=225&view=rev Author: chl501 Date: 2008-12-13 17:53:21 +0000 (Sat, 13 Dec 2008) Log Message: ----------- Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java 2008-12-13 17:51:37 UTC (rev 224) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java 2008-12-13 17:53:21 UTC (rev 225) @@ -1,200 +1,237 @@ -/* - OpenCDS - Copyright (C) 2007 - 2008 The OpenCDS team - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - ---------------------------------------------------------------------------- - * Author: Lars 'Levia' Wesselius - ---------------------------------------------------------------------------- -*/ -package org.opencdspowered.opencds.ui.util; - -import org.opencdspowered.opencds.core.util.DesktopIntegration; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import javax.swing.border.*; - -/** - * The interface util class. - * - * @author Lars 'Levia' Wesselius -*/ -public class Util -{ - private static Timer m_Timer; - - public static JLabel createPanelHeader(String text) - { - JLabel header = new JLabel(" " + text); - header.setBorder(BorderFactory.createLineBorder(Color.WHITE)); - header.setOpaque(true); - header.setMinimumSize(new Dimension(500, 25)); - header.setMaximumSize(new Dimension(500, 25)); - header.setBackground(new Color(49, 106, 197)); - header.setForeground(Color.WHITE); - header.setFont(new Font("Arial", Font.BOLD, 16)); - return header; - } - - /** - * Linkifies a label. This method sets the color, and changes it's cursor - * to the standard link cursor. - * - * @param label The label to linkify. - * @param underline Whether to underline the link or not. - */ - public static void linkify(JLabel label, boolean underline) - { - label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - label.setForeground(Color.blue); - if (underline) - { - label.setText("<html><u>" + label.getText() + "</u></html>"); - } - } - - /** - * Linkifies a label. This method sets the color, and changes it's cursor - * to the standard link cursor, and tries to open the link when clicked. - * - * @param label The label to linkify. - * @param underline Whether to underline the link or not. - * @param link Opens this link when clicked. - */ - public static void linkify(JLabel label, boolean underline, final String link) - { - label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - label.setForeground(Color.blue); - if (underline) - { - label.setText("<html><u>" + label.getText() + "</u></html>"); - } - label.addMouseListener(new MouseListener() - { - public void mouseClicked(MouseEvent event) - { - DesktopIntegration.browse(java.net.URI.create(link)); - } - - public void mousePressed(MouseEvent event) - { - } - - public void mouseReleased(MouseEvent event) - { - } - - public void mouseExited(MouseEvent event) - { - } - - public void mouseEntered(MouseEvent event) - { - } - }); - } - - /** - * Linkifies a label. This method sets the color, and changes it's cursor - * to the standard link cursor, and tries to open the link when clicked. - * - * @param label The label to linkify. - * @param underline Whether to underline the link or not. - * @param colorize Whether to colorize the link or not. - * @param link Opens this link when clicked. - */ - public static void linkify(JLabel label, boolean underline, boolean colorize, final String link) - { - label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - if (colorize) - { - label.setForeground(Color.blue); - } - if (underline) - { - label.setText("<html><u>" + label.getText() + "</u></html>"); - } - label.addMouseListener(new MouseListener() - { - public void mouseClicked(MouseEvent event) - { - DesktopIntegration.browse(java.net.URI.create(link)); - } - - public void mousePressed(MouseEvent event) - { - } - - public void mouseReleased(MouseEvent event) - { - } - - public void mouseExited(MouseEvent event) - { - } - - public void mouseEntered(MouseEvent event) - { - } - }); - } - - /** - * Flashes a component in given color. The border of the component flashes - * to the color given and is then set back to it's old border. It does - * this 7 times, and changes it's state every 150 miliseconds. - * - * @param comp The component to flash. - * @param color The color to use when flashing. - */ - public static void flashComponent(final JComponent comp, final Color color) - { - final Border oldBorder = comp.getBorder(); - m_Timer = new Timer(150, new ActionListener() - { - private int count = 0; - public void actionPerformed(ActionEvent evt) - { - if (count != 7) - { - if (!comp.getBorder().equals(oldBorder)) - { - ++count; - comp.setBorder(oldBorder); - } - else - { - comp.setBorder(BorderFactory.createLineBorder(color)); - } - } - else - { - m_Timer.stop(); - } - } - } - - ); - m_Timer.start(); - - } -} - - - - - - +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.util; + +import org.opencdspowered.opencds.core.util.DesktopIntegration; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.border.*; +import java.io.*; +import java.nio.channels.*; + +/** + * The interface util class. + * + * @author Lars 'Levia' Wesselius +*/ +public class Util +{ + private static Timer m_Timer; + + private static File m_File; + private static FileChannel m_Channel; + private static FileLock m_Lock; + + /** + * Create .lock file. This ensure only one application instance exists. + */ + public static void lock() + { + try{ + m_File = new File(".lock"); + m_Channel = new RandomAccessFile(m_File, "rw").getChannel(); + m_Lock = m_Channel.tryLock(); + if(null == m_Lock) + System.exit(2); + }catch(Exception e){ + e.printStackTrace(); + } + } + + /** + * Remove .lock file. Delete .lock file once user stop the application. + */ + public static void unlock() + { + try{ + m_Lock.release(); + m_Channel.close(); + m_File.delete(); + System.exit(0); + }catch(Exception e){ + e.printStackTrace(); + } + } + + public static JLabel createPanelHeader(String text) + { + JLabel header = new JLabel(" " + text); + header.setBorder(BorderFactory.createLineBorder(Color.WHITE)); + header.setOpaque(true); + header.setMinimumSize(new Dimension(500, 25)); + header.setMaximumSize(new Dimension(500, 25)); + header.setBackground(new Color(49, 106, 197)); + header.setForeground(Color.WHITE); + header.setFont(new Font("Arial", Font.BOLD, 16)); + return header; + } + + /** + * Linkifies a label. This method sets the color, and changes it's cursor + * to the standard link cursor. + * + * @param label The label to linkify. + * @param underline Whether to underline the link or not. + */ + public static void linkify(JLabel label, boolean underline) + { + label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + label.setForeground(Color.blue); + if (underline) + { + label.setText("<html><u>" + label.getText() + "</u></html>"); + } + } + + /** + * Linkifies a label. This method sets the color, and changes it's cursor + * to the standard link cursor, and tries to open the link when clicked. + * + * @param label The label to linkify. + * @param underline Whether to underline the link or not. + * @param link Opens this link when clicked. + */ + public static void linkify(JLabel label, boolean underline, final String link) + { + label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + label.setForeground(Color.blue); + if (underline) + { + label.setText("<html><u>" + label.getText() + "</u></html>"); + } + label.addMouseListener(new MouseListener() + { + public void mouseClicked(MouseEvent event) + { + DesktopIntegration.browse(java.net.URI.create(link)); + } + + public void mousePressed(MouseEvent event) + { + } + + public void mouseReleased(MouseEvent event) + { + } + + public void mouseExited(MouseEvent event) + { + } + + public void mouseEntered(MouseEvent event) + { + } + }); + } + + /** + * Linkifies a label. This method sets the color, and changes it's cursor + * to the standard link cursor, and tries to open the link when clicked. + * + * @param label The label to linkify. + * @param underline Whether to underline the link or not. + * @param colorize Whether to colorize the link or not. + * @param link Opens this link when clicked. + */ + public static void linkify(JLabel label, boolean underline, boolean colorize, final String link) + { + label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + if (colorize) + { + label.setForeground(Color.blue); + } + if (underline) + { + label.setText("<html><u>" + label.getText() + "</u></html>"); + } + label.addMouseListener(new MouseListener() + { + public void mouseClicked(MouseEvent event) + { + DesktopIntegration.browse(java.net.URI.create(link)); + } + + public void mousePressed(MouseEvent event) + { + } + + public void mouseReleased(MouseEvent event) + { + } + + public void mouseExited(MouseEvent event) + { + } + + public void mouseEntered(MouseEvent event) + { + } + }); + } + + /** + * Flashes a component in given color. The border of the component flashes + * to the color given and is then set back to it's old border. It does + * this 7 times, and changes it's state every 150 miliseconds. + * + * @param comp The component to flash. + * @param color The color to use when flashing. + */ + public static void flashComponent(final JComponent comp, final Color color) + { + final Border oldBorder = comp.getBorder(); + m_Timer = new Timer(150, new ActionListener() + { + private int count = 0; + public void actionPerformed(ActionEvent evt) + { + if (count != 7) + { + if (!comp.getBorder().equals(oldBorder)) + { + ++count; + comp.setBorder(oldBorder); + } + else + { + comp.setBorder(BorderFactory.createLineBorder(color)); + } + } + else + { + m_Timer.stop(); + } + } + } + + ); + m_Timer.start(); + + } +} + + + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ch...@us...> - 2008-12-13 17:51:43
|
Revision: 224 http://opencds.svn.sourceforge.net/opencds/?rev=224&view=rev Author: chl501 Date: 2008-12-13 17:51:37 +0000 (Sat, 13 Dec 2008) Log Message: ----------- Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/AbstractFrame.java Added: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/AbstractFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/AbstractFrame.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/AbstractFrame.java 2008-12-13 17:51:37 UTC (rev 224) @@ -0,0 +1,69 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.main; + +import java.awt.event.WindowListener; +import java.awt.event.WindowEvent; + +public abstract class AbstractFrame implements WindowListener +{ + /** + * Window Activated. + */ + public void windowActivated(WindowEvent e){} + + /** + * Window Closed. + * @param WindowEvent window event + */ + public void windowClosed(WindowEvent e){} + + /** + * Window Closing. + * @param WindowEvent window event + */ + public void windowClosing(WindowEvent e){} + + /** + * Window Deactivated. + * @param WindowEvent window event + */ + public void windowDeactivated(WindowEvent e){} + + /** + * Window Deiconified. + * @param WindowEvent window event + */ + public void windowDeiconified(WindowEvent e){} + + /** + * Window Iconified. + * @param WindowEvent window event + */ + public void windowIconified(WindowEvent e){} + + /** + * Window Opened. + * @param WindowEvent window event + */ + public void windowOpened(WindowEvent e){} +} Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-12-13 17:46:21 UTC (rev 223) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-12-13 17:51:37 UTC (rev 224) @@ -1,550 +1,560 @@ -/* - OpenCDS - Copyright (C) 2007 - 2008 The OpenCDS team - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - ---------------------------------------------------------------------------- - * Author: Lars 'Levia' Wesselius - ---------------------------------------------------------------------------- -*/ -package org.opencdspowered.opencds.ui.main; - -import org.opencdspowered.opencds.core.init.CoreInitializer; -import org.opencdspowered.opencds.core.config.ConfigurationManager; -import org.opencdspowered.opencds.core.lang.DynamicLocalisation; -import org.opencdspowered.opencds.core.update.*; -import org.opencdspowered.opencds.core.download.*; -import org.opencdspowered.opencds.core.project.*; -import org.opencdspowered.opencds.ui.tray.Tray; -import org.opencdspowered.opencds.core.plugin.*; -import org.opencdspowered.opencds.ui.gear.*; -import org.opencdspowered.opencds.ui.update.*; -import org.opencdspowered.opencds.ui.browser.*; -import org.opencdspowered.opencds.ui.splash.*; -import org.opencdspowered.opencds.ui.update.ChangelogDialog; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.util.Iterator; -import org.opencdspowered.opencds.core.exceptions.InvalidActionException; - -/** - * The class that initializes our frame. - * - * @author Lars 'Levia' Wesselius -*/ -public class MainFrame implements WindowStateListener -{ - private JFrame m_MainFrame; - private JTabbedPane m_Tabs; - private CoreInitializer m_Core; - private ImageIcon m_TabClose; - - private BrowserManager m_BrowserManager; - private GearManager m_GearManager; - private LogManager m_LogManager; - private ProjectDownloader m_ProjectDownloader; - private Tray m_Tray; - - private SplashWindow m_Splash; - - public MainFrame() - { - m_Core = new CoreInitializer(); - m_MainFrame = new JFrame("OpenCDS"); - - m_Splash = new SplashWindow(m_MainFrame); - m_Splash.setAlwaysOnTop(true); - } - - /** - * Creates our frame, then initializes all components. - */ - public void initialize() - { - DynamicLocalisation loc = m_Core.getLocalisation(); - incrementSplashProgress(loc.getMessage("Splash.StartingServices"), 10); - m_TabClose = new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/tab-close.png")); - m_Tabs = new JTabbedPane(); - ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); - - m_LogManager = new LogManager(this); - - incrementSplashProgress(loc.getMessage("Splash.CreatingMenubar"), 10); - m_MainFrame.setJMenuBar(new MenuBar(this)); - incrementSplashProgress(loc.getMessage("Splash.MenubarCreated"), 0); - - ThemeManager themeManager = new ThemeManager(this); - - m_BrowserManager = new BrowserManager(); - m_BrowserManager.parseFile("data/openfrag-versions.xml", false); - m_GearManager = new GearManager(m_BrowserManager); - - GearBrowser gearBrowser = new GearBrowser(this); - Browser browser = new Browser(this); - - m_ProjectDownloader = new ProjectDownloader(m_Core.getDownloadManager()); - - incrementSplashProgress(loc.getMessage("Splash.StartingLogger"), 10); - if (cfgMgr.getBoolValue("Logger.ShowTab")) - { - m_LogManager.setIndex(addTab(loc.getMessage("Logger"), - new ImageIcon(LogManager.class.getResource("/org/opencdspowered/opencds/ui/icons/log-icon.png")), - m_LogManager.getContentPane(), - loc.getMessage("Logger.Description"))); - } - - incrementSplashProgress(loc.getMessage("Splash.InitializingSettings"), 10); - // Initialize proxies - // HTTP - String ret = cfgMgr.getValue("HTTP.UseProxy"); - if (ret != null && ret.equals("true")) - { - ret = cfgMgr.getValue("HTTP.ProxyServer"); - if (ret != null) - { - System.setProperty("http.proxyHost", ret); - } - ret = cfgMgr.getValue("HTTP.ProxyPort"); - if (ret != null) - { - System.setProperty("http.proxyPort", ret); - } - } - else - { - System.setProperty("http.proxyHost", ""); - System.setProperty("http.proxyPort", ""); - } - - // FTP - ret = cfgMgr.getValue("FTP.UseProxy"); - if (ret != null && ret.equals("true")) - { - ret = cfgMgr.getValue("FTP.ProxyServer"); - if (ret != null) - { - System.setProperty("ftp.proxyHost", ret); - } - ret = cfgMgr.getValue("FTP.ProxyPort"); - if (ret != null) - { - System.setProperty("ftp.proxyPort", ret); - } - } - else - { - System.setProperty("ftp.proxyHost", ""); - System.setProperty("ftp.proxyPort", ""); - } - - incrementSplashProgress(loc.getMessage("Splash.CreatingWindow"), 10); - m_MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - m_MainFrame.setIconImage(new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/opencds-32.png")).getImage()); - - m_MainFrame.setLocation(200, 100); - - incrementSplashProgress(loc.getMessage("Splash.CreatingComponents"), 10); - m_MainFrame.setSize(800, 600); - JPanel contentPane = new JPanel(); - contentPane.setOpaque(true); - BoxLayout bl = new BoxLayout(contentPane, BoxLayout.PAGE_AXIS); - contentPane.setLayout(bl); - //contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10)); - m_MainFrame.setContentPane(contentPane); - - - m_MainFrame.add(m_Tabs); - - - incrementSplashProgress(loc.getMessage("Splash.ComponentsInitialized"), 10); - - incrementSplashProgress(loc.getMessage("Splash.StartingPluginManager"), 5); - - PluginManager plgMan = new PluginManager(this); - plgMan.scanForPlugins(); - - incrementSplashProgress(loc.getMessage("Loading plugins.."), 5); - String enabledPlugins = cfgMgr.getValue("Plugins.Load"); - if (enabledPlugins != null) - { - String[] parts = enabledPlugins.split(","); - - for (int i = 0; i != parts.length; ++i) - { - String entry = parts[i]; - plgMan.runPlugin(entry); - } - } - incrementSplashProgress(loc.getMessage("Splash.PluginsLoaded"), 10); - - m_Tray = new Tray(this); - - incrementSplashProgress(loc.getMessage("Done"), 10); - - m_MainFrame.addWindowStateListener(this); - - final MainFrame frame = this; - Thread t = new Thread(new Runnable() - { - public void run() - { - UpdateChecker checker = new UpdateChecker(); - //Enumeration<Update> entries = checker.checkForUpdates("./plugins"); - Iterator<Update> entries = checker.checkForUpdates(); - int updateCount = checker.getUpdateCount(); - System.out.println(updateCount); - - if (updateCount > 0) - { - DynamicLocalisation loc = m_Core.getLocalisation(); - String message = loc.getMessage("Updater.Notifier.UpdatesFound"); - if (message != null) - { - message = message.replaceAll("#", String.valueOf(updateCount)); - - String caption = loc.getMessage("Updater.Notifier.Caption"); - if (caption != null) - { - int res = JOptionPane.showConfirmDialog(m_MainFrame, message, caption, JOptionPane.YES_NO_OPTION); - if (res == JOptionPane.YES_OPTION) - { - new UpdateWizard(frame); - } - else - { - MenuBar bar = (MenuBar)m_MainFrame.getJMenuBar(); - bar.updatesAvailable(); - } - } - } - } - else - { - String ch = ConfigurationManager.getInstance().getValue("Updater.ShowChangelog"); - - if (ch != null && ch.equals("true")) - { - // Show changelog dialog. - ChangelogDialog chDlg = new ChangelogDialog(frame, true); - } - } - } - }); - t.start(); - } - - /** - * Adds a tab to the main window. - * - * @param title The title of the tab. - * @param icon The icon used for this tab. - * @param panel The component used for the tab. - * @param toolTip The tooltip to use. - * @return The index of the created tab. - */ - public int addTab(String title, ImageIcon icon, final JComponent panel, String toolTip) - { - ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); - - boolean skipCloseButton = false; - JPanel tabPanel = new JPanel(); - tabPanel.setOpaque(false); - - JLabel tabLabel = new JLabel(title); - if (icon != null) - { - tabLabel.setIcon(icon); - } - if (title.equals(getLocalisation().getMessage("Browser")) || title.equals(getLocalisation().getMessage("MyGear"))) - { - skipCloseButton = true; - } - final JButton tabCloseButton = new JButton(m_TabClose); - if (!skipCloseButton) - { - tabCloseButton.setPreferredSize(new Dimension(16, 16)); - tabCloseButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - int closeTabNumber = m_Tabs.indexOfComponent(panel); - m_Tabs.removeTabAt(closeTabNumber); - } - - }); - tabCloseButton.addMouseListener(new MouseListener() - { - public void mouseEntered(MouseEvent event) - { - int tabIndex = m_Tabs.indexOfComponent(panel); - tabCloseButton.setIcon(new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/tab-closeHover.png"))); - //m_Tabs.setTabComponentAt(tabIndex, tabCloseButton); - } - - public void mouseExited(MouseEvent event) - { - int tabIndex = m_Tabs.indexOfComponent(panel); - tabCloseButton.setIcon(m_TabClose); - //m_Tabs.setTabComponentAt(tabIndex, tabCloseButton); - } - - public void mouseClicked(MouseEvent event) - { - } - - public void mouseReleased(MouseEvent event) - { - } - - public void mousePressed(MouseEvent event) - { - } - } - - ); - } - - tabPanel.add(tabLabel, BorderLayout.WEST); - if (!skipCloseButton) - { - tabPanel.add(Box.createRigidArea(new Dimension(5, 0))); - tabPanel.add(tabCloseButton, BorderLayout.EAST); - } - - - panel.setOpaque(false); - m_Tabs.addTab(null, panel); - - int tabIndex = m_Tabs.getTabCount() - 1; - - if (toolTip != null && cfgMgr.getBoolValue("Application.EnableTooltips")) - { - m_Tabs.setToolTipTextAt(tabIndex, toolTip); - } - - m_Tabs.setTabComponentAt(tabIndex, tabPanel); - return tabIndex; - } - - /** - * Called when the windows state has been changed. - * - * @param event The event associated. - */ - public void windowStateChanged(WindowEvent event) - { - String cfg = ConfigurationManager.getInstance().getValue("Application.MinimizeToTray"); - if (cfg != null && cfg.equals("true")) - { - if (event.getNewState() == 1) - { - m_Tray.toTray(); - } - } - } - - /** - * Adds a tab to the main window. - * - * @param title The title of the tab. - * @param icon The icon used for this tab. - * @param panel The component used for the tab. - * @return The index of the created tab. - */ - public int addTab(String title, ImageIcon icon, JComponent panel) - { - return addTab(title, icon, panel, null); - } - - /** - * Adds a tab to the main window. - * - * @param title The title of the tab. - * @param panel The component used for the tab. - * @param toolTip The tooltip to use. - * @return The index of the created tab. - */ - public int addTab(String title, JComponent panel, String toolTip) - { - return addTab(title, null, panel, null); - } - - /** - * Removes a tab from the main window. - * - * @param index The index of the tab to remove. - * @return True if successful, false if not. - */ - public boolean removeTab(int index) - { - try - { - m_Tabs.removeTabAt(index); - return true; - } - catch (IndexOutOfBoundsException ioob) - { - return false; - } - } - - /** - * Get the tabbed pane. - * - * @return A reference to JTabbedPane. - */ - public JTabbedPane getTabs() - { - return m_Tabs; - } - - /** - * Makes the frame visible or invisible. - * - * @param visible False for invisible, true for visible. - */ - public void setVisible(boolean visible) - { - m_MainFrame.setVisible(visible); - } - - /** - * Increment the splash window's progress bar and set its string. - * - * @param str The string to set it to. - * @param val The value to increment with. - */ - public void incrementSplashProgress(String str, int val) - { - m_Splash.increment(str, val); - } - - /** - * Get the localisation class. - * - * @return A reference to the localisation class. - */ - public DynamicLocalisation getLocalisation() - { - return m_Core.getLocalisation(); - } - - /** - * Get the frame. - * - * @return A reference to the frame. - */ - public JFrame getFrame() - { - return m_MainFrame; - } - - /** - * Get the download manager. - * - * @return Reference to the download manager. - */ - public DownloadManager getDownloadManager() - { - return m_Core.getDownloadManager(); - } - - /** - * Get the core initializer. - * - * @return Reference to the core initializer. - */ - public CoreInitializer getCoreInitializer() - { - return m_Core; - } - - /** - * Get the browser manager. - * - * @return Reference to the browser manager. - */ - public BrowserManager getBrowserManager() - { - return m_BrowserManager; - } - - /** - * Get the gear manager. - * - * @return Reference to the gear manager. - */ - public GearManager getGearManager() - { - return m_GearManager; - } - - /** - * Get the project downloader. - * - * @return The project downloader. - */ - public ProjectDownloader getProjectDownloader() - { - return m_ProjectDownloader; - } - - /** - * Get the tray manager. - * - * @return Reference to the tray manager. - */ - public Tray getTrayManager() - { - return m_Tray; - } - - /** - * Get the log manager. - * - * @return Reference to the log manager. - */ - public LogManager getLogManager() - { - return m_LogManager; - } - - /** - * Run the updater. - */ - public void runUpdater() - { - // - } - - /** - * Stop OpenCDS. - */ - public void stopOpenCDS() - { - System.exit(0); - } - - /** - * Stop OpenCDS. - * - * @param status The status code, important for the launcher. - */ - public void stopOpenCDS(int status) - { - System.exit(status); - } -} +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.main; + +import org.opencdspowered.opencds.ui.util.Util; +import org.opencdspowered.opencds.core.init.CoreInitializer; +import org.opencdspowered.opencds.core.config.ConfigurationManager; +import org.opencdspowered.opencds.core.lang.DynamicLocalisation; +import org.opencdspowered.opencds.core.update.*; +import org.opencdspowered.opencds.core.download.*; +import org.opencdspowered.opencds.core.project.*; +import org.opencdspowered.opencds.ui.tray.Tray; +import org.opencdspowered.opencds.core.plugin.*; +import org.opencdspowered.opencds.ui.gear.*; +import org.opencdspowered.opencds.ui.update.*; +import org.opencdspowered.opencds.ui.browser.*; +import org.opencdspowered.opencds.ui.splash.*; +import org.opencdspowered.opencds.ui.update.ChangelogDialog; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.Iterator; +import org.opencdspowered.opencds.core.exceptions.InvalidActionException; + +/** + * The class that initializes our frame. + * + * @author Lars 'Levia' Wesselius +*/ +public class MainFrame extends AbstractFrame implements WindowStateListener +{ + private JFrame m_MainFrame; + private JTabbedPane m_Tabs; + private CoreInitializer m_Core; + private ImageIcon m_TabClose; + + private BrowserManager m_BrowserManager; + private GearManager m_GearManager; + private LogManager m_LogManager; + private ProjectDownloader m_ProjectDownloader; + private Tray m_Tray; + + private SplashWindow m_Splash; + + public MainFrame() + { + m_Core = new CoreInitializer(); + m_MainFrame = new JFrame("OpenCDS"); + + m_Splash = new SplashWindow(m_MainFrame); + m_Splash.setAlwaysOnTop(true); + } + + /** + * Creates our frame, then initializes all components. + */ + public void initialize() + { + DynamicLocalisation loc = m_Core.getLocalisation(); + incrementSplashProgress(loc.getMessage("Splash.StartingServices"), 10); + m_TabClose = new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/tab-close.png")); + m_Tabs = new JTabbedPane(); + ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); + + m_LogManager = new LogManager(this); + + incrementSplashProgress(loc.getMessage("Splash.CreatingMenubar"), 10); + m_MainFrame.setJMenuBar(new MenuBar(this)); + incrementSplashProgress(loc.getMessage("Splash.MenubarCreated"), 0); + + ThemeManager themeManager = new ThemeManager(this); + + m_BrowserManager = new BrowserManager(); + m_BrowserManager.parseFile("data/openfrag-versions.xml", false); + m_GearManager = new GearManager(m_BrowserManager); + + GearBrowser gearBrowser = new GearBrowser(this); + Browser browser = new Browser(this); + + m_ProjectDownloader = new ProjectDownloader(m_Core.getDownloadManager()); + + incrementSplashProgress(loc.getMessage("Splash.StartingLogger"), 10); + if (cfgMgr.getBoolValue("Logger.ShowTab")) + { + m_LogManager.setIndex(addTab(loc.getMessage("Logger"), + new ImageIcon(LogManager.class.getResource("/org/opencdspowered/opencds/ui/icons/log-icon.png")), + m_LogManager.getContentPane(), + loc.getMessage("Logger.Description"))); + } + + incrementSplashProgress(loc.getMessage("Splash.InitializingSettings"), 10); + // Initialize proxies + // HTTP + String ret = cfgMgr.getValue("HTTP.UseProxy"); + if (ret != null && ret.equals("true")) + { + ret = cfgMgr.getValue("HTTP.ProxyServer"); + if (ret != null) + { + System.setProperty("http.proxyHost", ret); + } + ret = cfgMgr.getValue("HTTP.ProxyPort"); + if (ret != null) + { + System.setProperty("http.proxyPort", ret); + } + } + else + { + System.setProperty("http.proxyHost", ""); + System.setProperty("http.proxyPort", ""); + } + + // FTP + ret = cfgMgr.getValue("FTP.UseProxy"); + if (ret != null && ret.equals("true")) + { + ret = cfgMgr.getValue("FTP.ProxyServer"); + if (ret != null) + { + System.setProperty("ftp.proxyHost", ret); + } + ret = cfgMgr.getValue("FTP.ProxyPort"); + if (ret != null) + { + System.setProperty("ftp.proxyPort", ret); + } + } + else + { + System.setProperty("ftp.proxyHost", ""); + System.setProperty("ftp.proxyPort", ""); + } + + incrementSplashProgress(loc.getMessage("Splash.CreatingWindow"), 10); + m_MainFrame.addWindowListener(this); + m_MainFrame.setIconImage(new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/opencds-32.png")).getImage()); + + m_MainFrame.setLocation(200, 100); + + incrementSplashProgress(loc.getMessage("Splash.CreatingComponents"), 10); + m_MainFrame.setSize(800, 600); + JPanel contentPane = new JPanel(); + contentPane.setOpaque(true); + BoxLayout bl = new BoxLayout(contentPane, BoxLayout.PAGE_AXIS); + contentPane.setLayout(bl); + //contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10)); + m_MainFrame.setContentPane(contentPane); + + + m_MainFrame.add(m_Tabs); + + + incrementSplashProgress(loc.getMessage("Splash.ComponentsInitialized"), 10); + + incrementSplashProgress(loc.getMessage("Splash.StartingPluginManager"), 5); + + PluginManager plgMan = new PluginManager(this); + plgMan.scanForPlugins(); + + incrementSplashProgress(loc.getMessage("Loading plugins.."), 5); + String enabledPlugins = cfgMgr.getValue("Plugins.Load"); + if (enabledPlugins != null) + { + String[] parts = enabledPlugins.split(","); + + for (int i = 0; i != parts.length; ++i) + { + String entry = parts[i]; + plgMan.runPlugin(entry); + } + } + incrementSplashProgress(loc.getMessage("Splash.PluginsLoaded"), 10); + + m_Tray = new Tray(this); + + incrementSplashProgress(loc.getMessage("Done"), 10); + + m_MainFrame.addWindowStateListener(this); + + final MainFrame frame = this; + Thread t = new Thread(new Runnable() + { + public void run() + { + UpdateChecker checker = new UpdateChecker(); + //Enumeration<Update> entries = checker.checkForUpdates("./plugins"); + Iterator<Update> entries = checker.checkForUpdates(); + int updateCount = checker.getUpdateCount(); + System.out.println(updateCount); + + if (updateCount > 0) + { + DynamicLocalisation loc = m_Core.getLocalisation(); + String message = loc.getMessage("Updater.Notifier.UpdatesFound"); + if (message != null) + { + message = message.replaceAll("#", String.valueOf(updateCount)); + + String caption = loc.getMessage("Updater.Notifier.Caption"); + if (caption != null) + { + int res = JOptionPane.showConfirmDialog(m_MainFrame, message, caption, JOptionPane.YES_NO_OPTION); + if (res == JOptionPane.YES_OPTION) + { + new UpdateWizard(frame); + } + else + { + MenuBar bar = (MenuBar)m_MainFrame.getJMenuBar(); + bar.updatesAvailable(); + } + } + } + } + else + { + String ch = ConfigurationManager.getInstance().getValue("Updater.ShowChangelog"); + + if (ch != null && ch.equals("true")) + { + // Show changelog dialog. + ChangelogDialog chDlg = new ChangelogDialog(frame, true); + } + } + } + }); + t.start(); + } + + /** + * Adds a tab to the main window. + * + * @param title The title of the tab. + * @param icon The icon used for this tab. + * @param panel The component used for the tab. + * @param toolTip The tooltip to use. + * @return The index of the created tab. + */ + public int addTab(String title, ImageIcon icon, final JComponent panel, String toolTip) + { + ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); + + boolean skipCloseButton = false; + JPanel tabPanel = new JPanel(); + tabPanel.setOpaque(false); + + JLabel tabLabel = new JLabel(title); + if (icon != null) + { + tabLabel.setIcon(icon); + } + if (title.equals(getLocalisation().getMessage("Browser")) || title.equals(getLocalisation().getMessage("MyGear"))) + { + skipCloseButton = true; + } + final JButton tabCloseButton = new JButton(m_TabClose); + if (!skipCloseButton) + { + tabCloseButton.setPreferredSize(new Dimension(16, 16)); + tabCloseButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + int closeTabNumber = m_Tabs.indexOfComponent(panel); + m_Tabs.removeTabAt(closeTabNumber); + } + + }); + tabCloseButton.addMouseListener(new MouseListener() + { + public void mouseEntered(MouseEvent event) + { + int tabIndex = m_Tabs.indexOfComponent(panel); + tabCloseButton.setIcon(new ImageIcon(MainFrame.class.getResource("/org/opencdspowered/opencds/ui/icons/tab-closeHover.png"))); + //m_Tabs.setTabComponentAt(tabIndex, tabCloseButton); + } + + public void mouseExited(MouseEvent event) + { + int tabIndex = m_Tabs.indexOfComponent(panel); + tabCloseButton.setIcon(m_TabClose); + //m_Tabs.setTabComponentAt(tabIndex, tabCloseButton); + } + + public void mouseClicked(MouseEvent event) + { + } + + public void mouseReleased(MouseEvent event) + { + } + + public void mousePressed(MouseEvent event) + { + } + } + + ); + } + + tabPanel.add(tabLabel, BorderLayout.WEST); + if (!skipCloseButton) + { + tabPanel.add(Box.createRigidArea(new Dimension(5, 0))); + tabPanel.add(tabCloseButton, BorderLayout.EAST); + } + + + panel.setOpaque(false); + m_Tabs.addTab(null, panel); + + int tabIndex = m_Tabs.getTabCount() - 1; + + if (toolTip != null && cfgMgr.getBoolValue("Application.EnableTooltips")) + { + m_Tabs.setToolTipTextAt(tabIndex, toolTip); + } + + m_Tabs.setTabComponentAt(tabIndex, tabPanel); + return tabIndex; + } + + /** + * Called when the windows state has been changed. + * + * @param event The event associated. + */ + public void windowStateChanged(WindowEvent event) + { + String cfg = ConfigurationManager.getInstance().getValue("Application.MinimizeToTray"); + if (cfg != null && cfg.equals("true")) + { + if (event.getNewState() == 1) + { + m_Tray.toTray(); + } + } + } + + /** + * Adds a tab to the main window. + * + * @param title The title of the tab. + * @param icon The icon used for this tab. + * @param panel The component used for the tab. + * @return The index of the created tab. + */ + public int addTab(String title, ImageIcon icon, JComponent panel) + { + return addTab(title, icon, panel, null); + } + + /** + * Adds a tab to the main window. + * + * @param title The title of the tab. + * @param panel The component used for the tab. + * @param toolTip The tooltip to use. + * @return The index of the created tab. + */ + public int addTab(String title, JComponent panel, String toolTip) + { + return addTab(title, null, panel, null); + } + + /** + * Removes a tab from the main window. + * + * @param index The index of the tab to remove. + * @return True if successful, false if not. + */ + public boolean removeTab(int index) + { + try + { + m_Tabs.removeTabAt(index); + return true; + } + catch (IndexOutOfBoundsException ioob) + { + return false; + } + } + + /** + * Get the tabbed pane. + * + * @return A reference to JTabbedPane. + */ + public JTabbedPane getTabs() + { + return m_Tabs; + } + + /** + * Makes the frame visible or invisible. + * + * @param visible False for invisible, true for visible. + */ + public void setVisible(boolean visible) + { + m_MainFrame.setVisible(visible); + } + + /** + * Increment the splash window's progress bar and set its string. + * + * @param str The string to set it to. + * @param val The value to increment with. + */ + public void incrementSplashProgress(String str, int val) + { + m_Splash.increment(str, val); + } + + /** + * Get the localisation class. + * + * @return A reference to the localisation class. + */ + public DynamicLocalisation getLocalisation() + { + return m_Core.getLocalisation(); + } + + /** + * Get the frame. + * + * @return A reference to the frame. + */ + public JFrame getFrame() + { + return m_MainFrame; + } + + /** + * Get the download manager. + * + * @return Reference to the download manager. + */ + public DownloadManager getDownloadManager() + { + return m_Core.getDownloadManager(); + } + + /** + * Get the core initializer. + * + * @return Reference to the core initializer. + */ + public CoreInitializer getCoreInitializer() + { + return m_Core; + } + + /** + * Get the browser manager. + * + * @return Reference to the browser manager. + */ + public BrowserManager getBrowserManager() + { + return m_BrowserManager; + } + + /** + * Get the gear manager. + * + * @return Reference to the gear manager. + */ + public GearManager getGearManager() + { + return m_GearManager; + } + + /** + * Get the project downloader. + * + * @return The project downloader. + */ + public ProjectDownloader getProjectDownloader() + { + return m_ProjectDownloader; + } + + /** + * Get the tray manager. + * + * @return Reference to the tray manager. + */ + public Tray getTrayManager() + { + return m_Tray; + } + + /** + * Get the log manager. + * + * @return Reference to the log manager. + */ + public LogManager getLogManager() + { + return m_LogManager; + } + + /** + * Run the updater. + */ + public void runUpdater() + { + // + } + + /** + * Stop OpenCDS. + */ + public void stopOpenCDS() + { + System.exit(0); + } + + /** + * Stop OpenCDS. + * + * @param status The status code, important for the launcher. + */ + public void stopOpenCDS(int status) + { + System.exit(status); + } + + /** + * When window closing, deleteing .lock file. + */ + @Override + public void windowClosing(WindowEvent e) + { + Util.unlock(); + } +} Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-12-13 17:46:21 UTC (rev 223) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-12-13 17:51:37 UTC (rev 224) @@ -1,309 +1,310 @@ -/* - OpenCDS - Copyright (C) 2007 - 2008 The OpenCDS team - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - ---------------------------------------------------------------------------- - * Author: Lars 'Levia' Wesselius - ---------------------------------------------------------------------------- -*/ -package org.opencdspowered.opencds.ui.main; - -import org.opencdspowered.opencds.ui.help.*; -import org.opencdspowered.opencds.ui.config.*; -import org.opencdspowered.opencds.ui.tray.*; -import org.opencdspowered.opencds.ui.error.*; -import org.opencdspowered.opencds.ui.update.*; -import org.opencdspowered.opencds.core.lang.DynamicLocalisation; -import org.opencdspowered.opencds.core.config.*; -import javax.swing.*; -import java.awt.event.*; -import java.awt.Dimension; -import java.net.URL; -import java.awt.Font; - -/** - * The menu bar. - * - * @author Lars 'Levia' Wesselius -*/ -public class MenuBar extends JMenuBar implements ActionListener, SettingChangedListener -{ - private MainFrame m_MainFrame; - private ConfigurationDialog m_ConfDialog = null; - - private JLabel m_ExceptionList; - private JLabel m_UpdateNotifier; - - /** - * The MenuBar constructor. - */ - public MenuBar(MainFrame mainFrame) - { - m_MainFrame = mainFrame; - ConfigurationManager.getInstance().addSettingChangedListener(this); - m_MainFrame.getCoreInitializer().getExceptionList().initialize(this); - initialize(); - } - - /** - * Initializes the bar, and adds its item. - */ - public void initialize() - { - final DynamicLocalisation loc = m_MainFrame.getLocalisation(); - - java.net.URL imgURL; - JMenu menu = new JMenu(loc.getMessage("FileMenu")); - - menu.addSeparator(); - - JMenuItem menuItem = new JMenuItem(loc.getMessage("FileMenu.Close"), KeyEvent.VK_Q); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/file-stop.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - this.add(menu); - - menu = new JMenu(loc.getMessage("ToolsMenu")); - - menuItem = new JMenuItem(loc.getMessage("ToolsMenu.Configuration"), KeyEvent.VK_C); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/tools-configuration.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - this.add(menu); - - menu = new JMenu(loc.getMessage("ViewMenu")); - - menuItem = new JMenuItem(loc.getMessage("Tray.ToTray"), KeyEvent.VK_B); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/view-totray.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - this.add(menu); - // - - menu = new JMenu(loc.getMessage("HelpMenu")); - - menuItem = new JMenuItem(loc.getMessage("HelpMenu.ReportBug"), KeyEvent.VK_B); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-reportbug.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - - menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckForUpdates"), KeyEvent.VK_U); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkforupdates.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - - menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckChangelog"), KeyEvent.VK_U); - menuItem.setActionCommand("CheckChangelog"); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkchangelog.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - - menu.addSeparator(); - - menuItem = new JMenuItem(loc.getMessage("HelpMenu.About"), KeyEvent.VK_A); - menuItem.addActionListener(this); - - imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-about.png"); - menuItem.setIcon(new ImageIcon(imgURL)); - - menu.add(menuItem); - this.add(menu); - } - - public void updatesAvailable() - { - // Create and add exclamation mark. - final DynamicLocalisation loc = m_MainFrame.getLocalisation(); - m_UpdateNotifier = new JLabel(); - final Font oldFont = m_UpdateNotifier.getFont(); - - URL imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/updater-updatesavailable.png"); - m_UpdateNotifier.setIcon(new ImageIcon(imgURL)); - m_UpdateNotifier.addMouseListener(new MouseListener() - { - public void mouseExited(MouseEvent eve) - { - m_UpdateNotifier.setFont(oldFont); - m_UpdateNotifier.setText(""); - } - - public void mouseEntered(MouseEvent eve) - { - m_UpdateNotifier.setFont(new Font(oldFont.getFontName(), Font.BOLD, oldFont.getSize())); - m_UpdateNotifier.setText(loc.getMessage("Updater.Notifier.Icon.UpdatesFound")); - } - - public void mouseReleased(MouseEvent eve) - { - } - - public void mousePressed(MouseEvent eve) - { - } - - public void mouseClicked(MouseEvent eve) - { - new UpdateWizard(m_MainFrame); - } - }); - this.add(Box.createRigidArea(new Dimension(10, 0))); - this.add(m_UpdateNotifier); - this.revalidate(); - } - - public void updatesInstalled() - { - if (m_UpdateNotifier != null) - { - this.remove(m_UpdateNotifier); - m_UpdateNotifier = null; - this.repaint(); - } - } - - public void exceptionOccured() - { - // Create and add exclamation mark. - final DynamicLocalisation loc = m_MainFrame.getLocalisation(); - m_ExceptionList = new JLabel(); - final Font oldFont = m_ExceptionList.getFont(); - - URL imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/log-exceptions.png"); - m_ExceptionList.setIcon(new ImageIcon(imgURL)); - m_ExceptionList.addMouseListener(new MouseListener() - { - public void mouseExited(MouseEvent eve) - { - m_ExceptionList.setFont(oldFont); - m_ExceptionList.setText(""); - } - - public void mouseEntered(MouseEvent eve) - { - m_ExceptionList.setFont(new Font(oldFont.getFontName(), Font.BOLD, oldFont.getSize())); - m_ExceptionList.setText(loc.getMessage("Logger.ErrorList")); - } - - public void mouseReleased(MouseEvent eve) - { - } - - public void mousePressed(MouseEvent eve) - { - } - - public void mouseClicked(MouseEvent eve) - { - ErrorDialog dlg = new ErrorDialog(m_MainFrame, true, m_MainFrame.getCoreInitializer().getExceptionList()); - } - }); - this.add(Box.createRigidArea(new Dimension(10, 0))); - this.add(m_ExceptionList); - this.revalidate(); - } - - public void exceptionsCleared() - { - // Remove the exclamation mark again. - - if (m_ExceptionList != null) - { - this.remove(m_ExceptionList); - m_ExceptionList = null; - this.repaint(); - } - } - - public void actionPerformed(ActionEvent event) - { - DynamicLocalisation loc = m_MainFrame.getLocalisation(); - String e = event.getActionCommand(); - - if (e.equals(loc.getMessage("FileMenu.Close"))) - { - System.exit(0); - } - else if (e.equals(loc.getMessage("HelpMenu.About"))) - { - AboutDialog dlg = new AboutDialog(m_MainFrame, true); - } - else if (e.equals(loc.getMessage("HelpMenu.CheckForUpdates"))) - { - new UpdateWizard(m_MainFrame); - } - else if (e.equals(loc.getMessage("HelpMenu.ReportBug"))) - { - ReportBug dlg = new ReportBug(m_MainFrame, true); - } - else if (e.equals(loc.getMessage("ToolsMenu.Configuration"))) - { - ConfigurationManager.getInstance().startSession(); - if (m_ConfDialog == null) - { - m_ConfDialog = new ConfigurationDialog(m_MainFrame, true); - } - else - { - if (m_ConfDialog.isVisible()) - { - return; - } - else - { - m_ConfDialog.setVisible(true); - } - } - } - else if (e.equals(loc.getMessage("Tray.ToTray"))) - { - m_MainFrame.getTrayManager().toTray(); - } - else if (e.equals("CheckChangelog")) - { - new ChangelogDialog(m_MainFrame, true); - } - } - - public void settingChanged(String key, String oldSetting, String newSetting) - { - if (key.equals("Logging.IgnoreErrors")) - { - if (newSetting.equals("true")) - { - this.exceptionsCleared(); - } - } - } -} - +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.main; + +import org.opencdspowered.opencds.ui.util.Util; +import org.opencdspowered.opencds.ui.help.*; +import org.opencdspowered.opencds.ui.config.*; +import org.opencdspowered.opencds.ui.tray.*; +import org.opencdspowered.opencds.ui.error.*; +import org.opencdspowered.opencds.ui.update.*; +import org.opencdspowered.opencds.core.lang.DynamicLocalisation; +import org.opencdspowered.opencds.core.config.*; +import javax.swing.*; +import java.awt.event.*; +import java.awt.Dimension; +import java.net.URL; +import java.awt.Font; + +/** + * The menu bar. + * + * @author Lars 'Levia' Wesselius +*/ +public class MenuBar extends JMenuBar implements ActionListener, SettingChangedListener +{ + private MainFrame m_MainFrame; + private ConfigurationDialog m_ConfDialog = null; + + private JLabel m_ExceptionList; + private JLabel m_UpdateNotifier; + + /** + * The MenuBar constructor. + */ + public MenuBar(MainFrame mainFrame) + { + m_MainFrame = mainFrame; + ConfigurationManager.getInstance().addSettingChangedListener(this); + m_MainFrame.getCoreInitializer().getExceptionList().initialize(this); + initialize(); + } + + /** + * Initializes the bar, and adds its item. + */ + public void initialize() + { + final DynamicLocalisation loc = m_MainFrame.getLocalisation(); + + java.net.URL imgURL; + JMenu menu = new JMenu(loc.getMessage("FileMenu")); + + menu.addSeparator(); + + JMenuItem menuItem = new JMenuItem(loc.getMessage("FileMenu.Close"), KeyEvent.VK_Q); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/file-stop.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + this.add(menu); + + menu = new JMenu(loc.getMessage("ToolsMenu")); + + menuItem = new JMenuItem(loc.getMessage("ToolsMenu.Configuration"), KeyEvent.VK_C); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/tools-configuration.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + this.add(menu); + + menu = new JMenu(loc.getMessage("ViewMenu")); + + menuItem = new JMenuItem(loc.getMessage("Tray.ToTray"), KeyEvent.VK_B); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/view-totray.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + this.add(menu); + // + + menu = new JMenu(loc.getMessage("HelpMenu")); + + menuItem = new JMenuItem(loc.getMessage("HelpMenu.ReportBug"), KeyEvent.VK_B); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-reportbug.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + + menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckForUpdates"), KeyEvent.VK_U); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkforupdates.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + + menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckChangelog"), KeyEvent.VK_U); + menuItem.setActionCommand("CheckChangelog"); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkchangelog.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + + menu.addSeparator(); + + menuItem = new JMenuItem(loc.getMessage("HelpMenu.About"), KeyEvent.VK_A); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-about.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + this.add(menu); + } + + public void updatesAvailable() + { + // Create and add exclamation mark. + final DynamicLocalisation loc = m_MainFrame.getLocalisation(); + m_UpdateNotifier = new JLabel(); + final Font oldFont = m_UpdateNotifier.getFont(); + + URL imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/updater-updatesavailable.png"); + m_UpdateNotifier.setIcon(new ImageIcon(imgURL)); + m_UpdateNotifier.addMouseListener(new MouseListener() + { + public void mouseExited(MouseEvent eve) + { + m_UpdateNotifier.setFont(oldFont); + m_UpdateNotifier.setText(""); + } + + public void mouseEntered(MouseEvent eve) + { + m_UpdateNotifier.setFont(new Font(oldFont.getFontName(), Font.BOLD, oldFont.getSize())); + m_UpdateNotifier.setText(loc.getMessage("Updater.Notifier.Icon.UpdatesFound")); + } + + public void mouseReleased(MouseEvent eve) + { + } + + public void mousePressed(MouseEvent eve) + { + } + + public void mouseClicked(MouseEvent eve) + { + new UpdateWizard(m_MainFrame); + } + }); + this.add(Box.createRigidArea(new Dimension(10, 0))); + this.add(m_UpdateNotifier); + this.revalidate(); + } + + public void updatesInstalled() + { + if (m_UpdateNotifier != null) + { + this.remove(m_UpdateNotifier); + m_UpdateNotifier = null; + this.repaint(); + } + } + + public void exceptionOccured() + { + // Create and add exclamation mark. + final DynamicLocalisation loc = m_MainFrame.getLocalisation(); + m_ExceptionList = new JLabel(); + final Font oldFont = m_ExceptionList.getFont(); + + URL imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/log-exceptions.png"); + m_ExceptionList.setIcon(new ImageIcon(imgURL)); + m_ExceptionList.addMouseListener(new MouseListener() + { + public void mouseExited(MouseEvent eve) + { + m_ExceptionList.setFont(oldFont); + m_ExceptionList.setText(""); + } + + public void mouseEntered(MouseEvent eve) + { + m_ExceptionList.setFont(new Font(oldFont.getFontName(), Font.BOLD, oldFont.getSize())); + m_ExceptionList.setText(loc.getMessage("Logger.ErrorList")); + } + + public void mouseReleased(MouseEvent eve) + { + } + + public void mousePressed(MouseEvent eve) + { + } + + public void mouseClicked(MouseEvent eve) + { + ErrorDialog dlg = new ErrorDialog(m_MainFrame, true, m_MainFrame.getCoreInitializer().getExceptionList()); + } + }); + this.add(Box.createRigidArea(new Dimension(10, 0))); + this.add(m_ExceptionList); + this.revalidate(); + } + + public void exceptionsCleared() + { + // Remove the exclamation mark again. + + if (m_ExceptionList != null) + { + this.remove(m_ExceptionList); + m_ExceptionList = null; + this.repaint(); + } + } + + public void actionPerformed(ActionEvent event) + { + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + String e = event.getActionCommand(); + + if (e.equals(loc.getMessage("FileMenu.Close"))) + { + Util.unlock(); + } + else if (e.equals(loc.getMessage("HelpMenu.About"))) + { + AboutDialog dlg = new AboutDialog(m_MainFrame, true); + } + else if (e.equals(loc.getMessage("HelpMenu.CheckForUpdates"))) + { + new UpdateWizard(m_MainFrame); + } + else if (e.equals(loc.getMessage("HelpMenu.ReportBug"))) + { + ReportBug dlg = new ReportBug(m_MainFrame, true); + } + else if (e.equals(loc.getMessage("ToolsMenu.Configuration"))) + { + ConfigurationManager.getInstance().startSession(); + if (m_ConfDialog == null) + { + m_ConfDialog = new ConfigurationDialog(m_MainFrame, true); + } + else + { + if (m_ConfDialog.isVisible()) + { + return; + } + else + { + m_ConfDialog.setVisible(true); + } + } + } + else if (e.equals(loc.getMessage("Tray.ToTray"))) + { + m_MainFrame.getTrayManager().toTray(); + } + else if (e.equals("CheckChangelog")) + { + new ChangelogDialog(m_MainFrame, true); + } + } + + public void settingChanged(String key, Str... [truncated message content] |
From: <ch...@us...> - 2008-12-13 17:46:26
|
Revision: 223 http://opencds.svn.sourceforge.net/opencds/?rev=223&view=rev Author: chl501 Date: 2008-12-13 17:46:21 +0000 (Sat, 13 Dec 2008) Log Message: ----------- Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/Initializer.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/Initializer.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/Initializer.java 2008-09-13 11:42:56 UTC (rev 222) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/Initializer.java 2008-12-13 17:46:21 UTC (rev 223) @@ -1,54 +1,57 @@ -/* - OpenCDS - Copyright (C) 2007 - 2008 The OpenCDS team - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - ---------------------------------------------------------------------------- - * Author: Lars 'Levia' Wesselius - ---------------------------------------------------------------------------- -*/ -package org.opencdspowered.opencds.ui; - -import org.opencdspowered.opencds.ui.main.*; -import javax.swing.JFrame; -import javax.swing.JDialog; - -/** - * The class that initializes and starts our application. We do not have to - * set a Look And Feel (LAF) here as thats already done in the core initializer. - * - * @author Lars 'Levia' Wesselius -*/ -public class Initializer -{ - public static void main(String[] args) - { - System.setProperty("substancelaf.heapStatusPanel", ""); - JFrame.setDefaultLookAndFeelDecorated(true); - JDialog.setDefaultLookAndFeelDecorated(true); - - final MainFrame mf = new MainFrame(); - mf.initialize(); - - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - mf.setVisible(true); - } - } - ); - } -} \ No newline at end of file +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui; + +import org.opencdspowered.opencds.ui.util.Util; +import org.opencdspowered.opencds.ui.main.*; +import javax.swing.JFrame; +import javax.swing.JDialog; + +/** + * The class that initializes and starts our application. We do not have to + * set a Look And Feel (LAF) here as thats already done in the core initializer. + * + * @author Lars 'Levia' Wesselius +*/ +public class Initializer +{ + public static void main(String[] args) + { + System.setProperty("substancelaf.heapStatusPanel", ""); + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + + Util.lock(); + + final MainFrame mf = new MainFrame(); + mf.initialize(); + + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + mf.setVisible(true); + } + } + ); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-13 11:42:47
|
Revision: 222 http://opencds.svn.sourceforge.net/opencds/?rev=222&view=rev Author: levia Date: 2008-09-13 11:42:56 +0000 (Sat, 13 Sep 2008) Log Message: ----------- - Forgot to upload a file. Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/view-totray.png Property changes on: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/view-totray.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-13 11:39:06
|
Revision: 221 http://opencds.svn.sourceforge.net/opencds/?rev=221&view=rev Author: levia Date: 2008-09-13 11:39:11 +0000 (Sat, 13 Sep 2008) Log Message: ----------- - Bug fixed where Localisation wouldn't be set. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/DynamicLocalisation.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/DynamicLocalisation.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/DynamicLocalisation.java 2008-09-13 11:23:53 UTC (rev 220) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/DynamicLocalisation.java 2008-09-13 11:39:11 UTC (rev 221) @@ -86,6 +86,10 @@ ConfigurationManager.getInstance().setValue("Locale", code); } } + else + { + setLanguage("en_US"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-13 11:23:44
|
Revision: 220 http://opencds.svn.sourceforge.net/opencds/?rev=220&view=rev Author: levia Date: 2008-09-13 11:23:53 +0000 (Sat, 13 Sep 2008) Log Message: ----------- - Added necessary libraries. - Changes to download system, kinda broken right now though. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java Added Paths: ----------- OpenCDS/trunk/javolution.jar OpenCDS/trunk/substance.jar OpenCDS/trunk/xom-1.1.jar Property changes on: OpenCDS/trunk/javolution.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-03 22:35:39 UTC (rev 219) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-13 11:23:53 UTC (rev 220) @@ -26,6 +26,10 @@ import org.opencdspowered.opencds.core.logging.*; import java.net.URL; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.math.BigInteger; +import java.security.MessageDigest; import java.util.Iterator; /** @@ -148,12 +152,15 @@ { Index index = it.next(); - Download dl = new Download(baseUrl + index.getURL(), installTo + index.getURL()); - relDl.addSize(index.getFileSize()); - System.out.println("baseURL: " + baseUrl); - System.out.println("IndexURL: " + index.getURL()); - System.out.println("InstallTo: " + installTo); - relDl.addDownload(dl); + if (checkHash(index, installTo)) + { + Download dl = new Download(baseUrl + index.getURL(), installTo + index.getURL()); + relDl.addSize(index.getFileSize()); + System.out.println("baseURL: " + baseUrl); + System.out.println("IndexURL: " + index.getURL()); + System.out.println("InstallTo: " + installTo); + relDl.addDownload(dl); + } } m_DownloadManager.enqueueDownload(relDl); } @@ -194,6 +201,47 @@ } + + private boolean checkHash(Index index, String installTo) + { + File localFile = new File(installTo + index.getURL()); + + if (!localFile.exists()) + { + return true; + } + try + { + MessageDigest digest = MessageDigest.getInstance("MD5"); + InputStream is = new FileInputStream(localFile); + byte[] buffer = new byte[8192]; + int read = 0; + + while((read = is.read(buffer)) > 0) + { + digest.update(buffer, 0, read); + } + byte[] md5sum = digest.digest(); + BigInteger bigInt = new BigInteger(1, md5sum); + String output = bigInt.toString(16); + is.close(); + + System.out.println("File: " + index.getURL()); + System.out.println("Index: " + index.getHash()); + System.out.println("Output: " + output); + if (!output.equals(index.getHash())) + { + System.out.println("return true"); + return true; + } + return false; + } + catch (Exception e) + { + Logger.getInstance().logException(e, false); + } + return true; + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java 2008-09-03 22:35:39 UTC (rev 219) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java 2008-09-13 11:23:53 UTC (rev 220) @@ -22,7 +22,7 @@ package org.opencdspowered.opencds.core.update; import org.opencdspowered.opencds.core.util.Constants; -import org.opencdspowered.opencds.core.download.*; +import javolution.util.*; import java.net.*; import java.util.*; import java.io.*; @@ -36,7 +36,7 @@ */ public class UpdateChecker { - private Enumeration<Update> m_FoundUpdates; + private Iterator<Update> m_FoundUpdates; private int m_NumberOfUpdates; /** @@ -50,11 +50,11 @@ * Check for updates. * * @param ignore Ignore updates starting with given string. - * @return A Enumeration with all the updates. + * @return A iterator with all the updates. */ - public Enumeration<Update> checkForUpdates(String ignore) + public Iterator<Update> checkForUpdates(String ignore) { - Vector<Update> updateVector = new Vector<Update>(); + FastTable<Update> updateVector = new FastTable<Update>(); try { URL scriptUrl = new URL(Constants.UPDATE_SCRIPT); @@ -80,12 +80,12 @@ { if (!update.getPath().startsWith(ignore)) { - updateVector.addElement(update); + updateVector.add(update); } } else { - updateVector.addElement(update); + updateVector.add(update); } } } @@ -95,7 +95,7 @@ { org.opencdspowered.opencds.core.logging.Logger.getInstance().logException(e); } - m_FoundUpdates = updateVector.elements(); + m_FoundUpdates = updateVector.iterator(); m_NumberOfUpdates = updateVector.size(); return m_FoundUpdates; } @@ -103,9 +103,9 @@ /** * Check for updates. * - * @return A Enumeration with all the updates. + * @return A Iterator with all the updates. */ - public Enumeration<Update> checkForUpdates() + public Iterator<Update> checkForUpdates() { return checkForUpdates(null); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-09-03 22:35:39 UTC (rev 219) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-09-13 11:23:53 UTC (rev 220) @@ -326,7 +326,8 @@ } else if (e.equals("Update")) { - //TODO: Update + ProjectDownloader downloader = m_MainFrame.getProjectDownloader(); + downloader.downloadProject(project); } else if (e.equals("Remove")) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-03 22:35:39 UTC (rev 219) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-13 11:23:53 UTC (rev 220) @@ -37,7 +37,8 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.util.Enumeration; +import java.util.Iterator; +import org.opencdspowered.opencds.core.exceptions.InvalidActionException; /** * The class that initializes our frame. @@ -202,7 +203,7 @@ { UpdateChecker checker = new UpdateChecker(); //Enumeration<Update> entries = checker.checkForUpdates("./plugins"); - Enumeration<Update> entries = checker.checkForUpdates(); + Iterator<Update> entries = checker.checkForUpdates(); int updateCount = checker.getUpdateCount(); System.out.println(updateCount); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java 2008-09-03 22:35:39 UTC (rev 219) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java 2008-09-13 11:23:53 UTC (rev 220) @@ -36,6 +36,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -116,7 +117,7 @@ m_UpdateCount.setText(m_MainFrame.getLocalisation().getMessage("Updater.CheckingForUpdates")); UpdateChecker checker = new UpdateChecker(); //Enumeration<Update> updateEnum = checker.checkForUpdates("./plugins"); - Enumeration<Update> updateEnum = checker.checkForUpdates(); + Iterator<Update> updateEnum = checker.checkForUpdates(); if (m_UpdateList.getRowCount() > 0) { @@ -130,9 +131,9 @@ int updateCount = 0; int languageCount = 0; - for (;updateEnum.hasMoreElements();) + for (;updateEnum.hasNext();) { - Update upd = updateEnum.nextElement(); + Update upd = updateEnum.next(); System.out.println(upd.getPath()); if (upd.toString().startsWith("lang")) { Property changes on: OpenCDS/trunk/substance.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: OpenCDS/trunk/xom-1.1.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-03 22:35:39 UTC (rev 219) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-13 11:23:53 UTC (rev 220) @@ -26,6 +26,9 @@ import java.net.URLConnection; import java.net.URL; import java.io.*; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class HTTPHandler extends DownloadHandler { @@ -46,7 +49,7 @@ m_DownloadTab = new HTTPDownloadTab(m_Interface, download); while ((dl = download.getNextInLine()) != null) { - OutputStream out = null; + FileOutputStream out = null; URLConnection conn = null; InputStream in = null; try @@ -57,6 +60,7 @@ File file = new File(dl.getToFile()); System.out.println("Tofile:" + dl.getToFile()); + System.out.println("addr: " + dl.getAddress()); if (!file.exists()) { if (file.isDirectory()) @@ -75,15 +79,18 @@ } } - out = new BufferedOutputStream(new FileOutputStream(file)); + out = new FileOutputStream(file); conn = url.openConnection(); double fileSize = conn.getContentLength(); dl.setFileSize((fileSize*1024)*1024); in = conn.getInputStream(); - byte[] buffer = new byte[1024]; + + + + byte[] buffer = new byte[2048]; int numRead; long numWritten = 0; - + while (((numRead = in.read(buffer)) != -1) && !m_Cancel) { out.write(buffer, 0, numRead); @@ -91,6 +98,7 @@ dl.setProgress(numWritten); } in.close(); + out.flush(); out.close(); if (m_Cancel) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-03 22:35:43
|
Revision: 219 http://opencds.svn.sourceforge.net/opencds/?rev=219&view=rev Author: levia Date: 2008-09-03 22:35:39 +0000 (Wed, 03 Sep 2008) Log Message: ----------- - Release 0.2.219. Modified Paths: -------------- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Modified: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java 2008-09-03 22:10:14 UTC (rev 218) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java 2008-09-03 22:35:39 UTC (rev 219) @@ -28,7 +28,7 @@ */ public class Constants { - public static final String OPENCDS_VERSION = "0.2.203"; + public static final String OPENCDS_VERSION = "0.2.219"; } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-03 22:10:14 UTC (rev 218) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-03 22:35:39 UTC (rev 219) @@ -25,6 +25,7 @@ import org.opencdspowered.opencds.core.init.*; import org.opencdspowered.opencds.core.exceptions.InvalidActionException; import java.util.*; +import org.opencdspowered.opencds.core.project.Release; /** * The ReleaseDownloadManager handles all ReleaseDownloads that have been given. It ReleaseDownloads @@ -94,7 +95,7 @@ * @param toFile The destination of the ReleaseDownload. * @return The ReleaseDownload created. */ - public ReleaseDownload addDownload(String address, String toFile) throws InvalidActionException + public ReleaseDownload addDownload(String address, String toFile, Release rel) throws InvalidActionException { if (address == null || toFile == null) { @@ -103,7 +104,7 @@ } Download dl = new Download(address, toFile, STATE_IDLE); - ReleaseDownload relDl = new ReleaseDownload(address, null); + ReleaseDownload relDl = new ReleaseDownload(address, rel); relDl.addDownload(dl); m_ReleaseDownloadList.add(relDl); fireDownloadAdded(relDl); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-03 22:10:14 UTC (rev 218) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-03 22:35:39 UTC (rev 219) @@ -86,7 +86,7 @@ Logger.getInstance().logException(ex); } } - download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); + download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName(), exe); } else { @@ -95,7 +95,7 @@ { dir.mkdirs(); } - download = m_DownloadManager.addDownload(exe.getFileUrl(), exe.getInstallTo()); + download = m_DownloadManager.addDownload(exe.getFileUrl(), exe.getInstallTo(), exe); } m_DownloadManager.enqueueDownload(download); } @@ -181,7 +181,7 @@ } } - ReleaseDownload download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); + ReleaseDownload download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName(), exe); m_DownloadManager.enqueueDownload(download); } m_DownloadManager.startQueue(); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java 2008-09-03 22:10:14 UTC (rev 218) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java 2008-09-03 22:35:39 UTC (rev 219) @@ -33,7 +33,7 @@ public static final String AUTHORS = "Lars 'Levia' Wesselius"; public static final String THANKS_TO = "Kirill Grouchnikov (Substance),Sai_Co (OpenCDS logo),Quaim(Swedish translation)"; - public static final String OPENCDS_VERSION = "0.2.203"; + public static final String OPENCDS_VERSION = "0.2.219"; public static final String UPDATE_DIR = "http://opencdspowered.org/update/"; public static final String UPDATE_SCRIPT = "http://opencdspowered.org/update/listfiles.php"; Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-03 22:10:14 UTC (rev 218) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-03 22:35:39 UTC (rev 219) @@ -221,17 +221,23 @@ public void totalProgress(long totalDownloaded, long totalSize) { - m_TotalProgress.setValue((int)totalDownloaded); - System.out.println("Totla " + totalDownloaded + " : " + totalSize); - System.out.println(totalDownloaded/totalSize); - double percent = ((double)((double)totalDownloaded/(double)totalSize)*100); - System.out.println(percent); - - BigDecimal bd = new BigDecimal(percent); - bd = bd.setScale(2, BigDecimal.ROUND_UP); - - ParameterList pmList = ParameterList.makeParameterList("percent:" + bd.intValue()); - m_TotalProgress.setString(m_Interface.getLocalisation().getLocalisedMessageParams("DownloadTab.TotalProgress", pmList)); + if (m_Download.getDownloadAmount() > 1) + { + m_TotalProgress.setValue((int)totalDownloaded); + double percent = ((double)((double)totalDownloaded/(double)totalSize)*100); + + BigDecimal bd = new BigDecimal(percent); + bd = bd.setScale(2, BigDecimal.ROUND_UP); + + ParameterList pmList = ParameterList.makeParameterList("percent:" + bd.intValue()); + m_TotalProgress.setString(m_Interface.getLocalisation().getLocalisedMessageParams("DownloadTab.TotalProgress", pmList)); + } + else + { + m_TotalProgress.setString(m_Progress.getString()); + m_TotalProgress.setMaximum(m_Progress.getMaximum()); + m_TotalProgress.setValue(m_Progress.getValue()); + } } public void actionPerformed(ActionEvent event) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-03 22:10:19
|
Revision: 218 http://opencds.svn.sourceforge.net/opencds/?rev=218&view=rev Author: levia Date: 2008-09-03 22:10:14 +0000 (Wed, 03 Sep 2008) Log Message: ----------- - Fixed some stuff I can't remember. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/tray/Tray.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/UpdateWizard.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-03 22:10:14 UTC (rev 218) @@ -103,7 +103,7 @@ } Download dl = new Download(address, toFile, STATE_IDLE); - ReleaseDownload relDl = new ReleaseDownload(address); + ReleaseDownload relDl = new ReleaseDownload(address, null); relDl.addDownload(dl); m_ReleaseDownloadList.add(relDl); fireDownloadAdded(relDl); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-03 22:10:14 UTC (rev 218) @@ -23,6 +23,7 @@ import java.util.NoSuchElementException; import javolution.util.FastTable; +import org.opencdspowered.opencds.core.project.Release; /** * The ReleaseDownload contains multiple Download objects, to download a complete @@ -41,6 +42,8 @@ private FastTable<ReleaseDownloadListener> m_ReleaseDownloadListeners = new FastTable<ReleaseDownloadListener>(); + private Release m_Release; + private String m_Protocol; private Download m_CurrentDownload = null; @@ -49,9 +52,10 @@ private int m_TotalDownloads = 0; private long m_Previous = 0; - public ReleaseDownload(String baseURL) + public ReleaseDownload(String baseURL, Release release) { m_Protocol = baseURL; + m_Release = release; } /** @@ -260,6 +264,16 @@ return m_TotalDownloads - m_ReleaseDownloads.size(); } + /** + * Get the release associated. + * + * @return The release. + */ + public Release getRelease() + { + return m_Release; + } + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) { for (int i = 0; i < m_DownloadProgressListeners.size(); i++) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-09-03 22:10:14 UTC (rev 218) @@ -30,6 +30,7 @@ FileMenu = File FileMenu.Close = Exit FileMenu.Close.Description = Close the program +ViewMenu = View HelpMenu = Help HelpMenu.About = About.. HelpMenu.About.Description = Show the about dialog Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java 2008-09-03 22:10:14 UTC (rev 218) @@ -21,15 +21,12 @@ */ package org.opencdspowered.opencds.core.plugin; -import org.opencdspowered.opencds.core.exceptions.*; -import org.opencdspowered.opencds.core.logging.*; -import org.opencdspowered.opencds.core.lang.*; import org.opencdspowered.opencds.core.download.*; -import org.opencdspowered.opencds.core.init.*; import org.opencdspowered.opencds.core.project.*; import org.opencdspowered.opencds.ui.main.*; import javax.swing.*; +import org.opencdspowered.opencds.ui.tray.Tray; /** * This is the class that is passed to plugins. Plugins get their additional @@ -96,6 +93,11 @@ return m_MainFrame.getProjectDownloader(); } + public Tray getTray() + { + return m_MainFrame.getTrayManager(); + } + public int addTab(String title, ImageIcon icon, JComponent panel) { return m_MainFrame.addTab(title, icon, panel); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java 2008-09-03 22:10:14 UTC (rev 218) @@ -26,6 +26,7 @@ import org.opencdspowered.opencds.core.project.*; import javax.swing.*; +import org.opencdspowered.opencds.ui.tray.Tray; /** * This is the class that is passed to plugins. Plugins get their additional @@ -85,6 +86,13 @@ public ProjectDownloader getProjectDownloader(); /** + * Get the tray manager + * + * @return The tray manager. + */ + public Tray getTray(); + + /** * Add a tab to the main view. * * @param title The title of the tab. Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-03 22:10:14 UTC (rev 218) @@ -140,7 +140,10 @@ int slashIndex = exe.getFileUrl().lastIndexOf("/"); String baseUrl = exe.getFileUrl().substring(0, slashIndex); - ReleaseDownload relDl = new ReleaseDownload(baseUrl); + ReleaseDownload relDl = new ReleaseDownload(baseUrl, exe); + + // Add Release to the ReleaseDownload - it must know what release it was. + // Tab hhtpdownloadtab for (Iterator<Index> it = reader.getIndexes(); it.hasNext();) { Index index = it.next(); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/update/UpdateChecker.java 2008-09-03 22:10:14 UTC (rev 218) @@ -74,9 +74,19 @@ for (int i = 0; i != stringUpdates.length; ++i) { Update update = parseUpdate(stringUpdates[i]); - if (update != null && !update.getPath().startsWith("./changelog.html") && ignore != null && !update.getPath().startsWith(ignore)) + if (update != null && !update.getPath().startsWith("./changelog.html")) { - updateVector.addElement(update); + if (ignore != null) + { + if (!update.getPath().startsWith(ignore)) + { + updateVector.addElement(update); + } + } + else + { + updateVector.addElement(update); + } } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-03 22:10:14 UTC (rev 218) @@ -201,7 +201,8 @@ public void run() { UpdateChecker checker = new UpdateChecker(); - Enumeration<Update> entries = checker.checkForUpdates("./plugins"); + //Enumeration<Update> entries = checker.checkForUpdates("./plugins"); + Enumeration<Update> entries = checker.checkForUpdates(); int updateCount = checker.getUpdateCount(); System.out.println(updateCount); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-09-03 22:10:14 UTC (rev 218) @@ -90,6 +90,18 @@ menu.add(menuItem); this.add(menu); + menu = new JMenu(loc.getMessage("ViewMenu")); + + menuItem = new JMenuItem(loc.getMessage("Tray.ToTray"), KeyEvent.VK_B); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/view-totray.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + this.add(menu); + // + menu = new JMenu(loc.getMessage("HelpMenu")); menuItem = new JMenuItem(loc.getMessage("HelpMenu.ReportBug"), KeyEvent.VK_B); @@ -276,7 +288,6 @@ else if (e.equals(loc.getMessage("Tray.ToTray"))) { m_MainFrame.getTrayManager().toTray(); - m_MainFrame.getTrayManager().showMessage("Tray", "Now I am in tray, you can't control me!", Tray.INFO); } else if (e.equals("CheckChangelog")) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/tray/Tray.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/tray/Tray.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/tray/Tray.java 2008-09-03 22:10:14 UTC (rev 218) @@ -38,6 +38,8 @@ public class Tray implements MouseListener, ActionListener { public static final boolean isTraySupported = SystemTray.isSupported(); + + public boolean m_IsInTray; public static final TrayIcon.MessageType ERROR = TrayIcon.MessageType.ERROR; public static final TrayIcon.MessageType INFO = TrayIcon.MessageType.INFO; @@ -114,6 +116,7 @@ try { tray.add(m_TrayIcon); + m_IsInTray = true; } catch (AWTException e) { @@ -132,6 +135,7 @@ SystemTray.getSystemTray().remove(m_TrayIcon); m_TrayIcon = null; m_MainFrame.getFrame().setVisible(true); + m_IsInTray = false; } public void showMessage(String caption, String message, TrayIcon.MessageType type) @@ -157,6 +161,10 @@ } } + public boolean isInTray() + { + return m_IsInTray; + } public void mouseExited(MouseEvent eve) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/SelectUpdatesPage.java 2008-09-03 22:10:14 UTC (rev 218) @@ -115,7 +115,8 @@ { m_UpdateCount.setText(m_MainFrame.getLocalisation().getMessage("Updater.CheckingForUpdates")); UpdateChecker checker = new UpdateChecker(); - Enumeration<Update> updateEnum = checker.checkForUpdates("./plugins"); + //Enumeration<Update> updateEnum = checker.checkForUpdates("./plugins"); + Enumeration<Update> updateEnum = checker.checkForUpdates(); if (m_UpdateList.getRowCount() > 0) { @@ -132,6 +133,7 @@ for (;updateEnum.hasMoreElements();) { Update upd = updateEnum.nextElement(); + System.out.println(upd.getPath()); if (upd.toString().startsWith("lang")) { if (doLanguage(upd)) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/UpdateWizard.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/UpdateWizard.java 2008-09-03 15:21:59 UTC (rev 217) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/UpdateWizard.java 2008-09-03 22:10:14 UTC (rev 218) @@ -52,7 +52,8 @@ public void run() { UpdateChecker checker = new UpdateChecker(); - checker.checkForUpdates("./plugins"); + //checker.checkForUpdates("./plugins"); + checker.checkForUpdates(); if (checker.getUpdateCount() < 1) { Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-03 15:21:59 UTC (rev 217) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-03 22:10:14 UTC (rev 218) @@ -94,10 +94,10 @@ m_ContentPane.setOpaque(false); m_Index = m_Interface.addTab( - loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getCurrentDownload().getName(), + loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getRelease().getName(), new ImageIcon(DownloadManager.class.getResource("/org/opencdspowered/opencds/ui/icons/download-icon.png")), m_ContentPane, - loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getCurrentDownload().getName() + loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getRelease().getName() ); @@ -243,16 +243,23 @@ m_Interface.getDownloadManager().cancelDownload(m_Download); m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.Cancelled")); } + else if (e.equals("Ok")) + { + m_Interface.removeTab(m_Index); + } } public void allCompleted() { + Localisation loc = m_Interface.getLocalisation(); m_TotalProgress.setValue(m_TotalProgress.getMaximum()); - m_TotalProgress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.AllCompleted")); + m_TotalProgress.setString(loc.getMessage("DownloadTab.AllCompleted")); m_Download.removeListener(this); m_Download.removeProgressListener(this); - m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.AllCompleted")); + m_Progress.setString(loc.getMessage("DownloadTab.AllCompleted")); m_Progress.setValue(m_Progress.getMaximum()); + m_Cancel.setText(loc.getMessage("DownloadTab.Ok")); + m_Cancel.setActionCommand("Ok"); } Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-03 15:21:59 UTC (rev 217) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-03 22:10:14 UTC (rev 218) @@ -10,4 +10,5 @@ DownloadTab.Cancelled = Download cancelled. DownloadTab.NumberDownloads = %number out of %outOf DownloadTab.TotalProgress = Total progress (%percent %) -DownloadTab.AllCompleted = All completed \ No newline at end of file +DownloadTab.AllCompleted = All completed +DownloadTab.Ok = Ok \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-03 15:22:02
|
Revision: 217 http://opencds.svn.sourceforge.net/opencds/?rev=217&view=rev Author: levia Date: 2008-09-03 15:21:59 +0000 (Wed, 03 Sep 2008) Log Message: ----------- - Downloading now works fine. Statistics are also working again. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-02 18:26:37 UTC (rev 216) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-03 15:21:59 UTC (rev 217) @@ -274,6 +274,11 @@ System.out.println("Current progress: " + m_CurrentProgress); fireTotalProgress(); + + if (totalFileSize <= currentFileSize) + { + dl.setState(DownloadManager.STATE_DONE); + } } public void stateChanged(Download dl, int oldState, int newState) @@ -287,13 +292,12 @@ public void completed(Download dl) { - fireDownloadCompleted(dl); for (int i = 0; i < m_DownloadListeners.size(); i++) { DownloadListener listener = m_DownloadListeners.get(i); listener.completed(dl); } - System.out.println("Size: " + m_ReleaseDownloads.size()); + fireDownloadCompleted(dl); } private void fireDownloadStarted() @@ -314,6 +318,12 @@ ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); listener.downloadCompleted(dl); } + System.out.println("Completed: " + dl.getAddress()); + System.out.println("Size: " + m_ReleaseDownloads.size()); + if (m_ReleaseDownloads.isEmpty()) + { + fireAllCompleted(); + } } private void fireTotalProgress() Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-02 18:26:37 UTC (rev 216) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-03 15:21:59 UTC (rev 217) @@ -48,6 +48,8 @@ private JLabel m_FileSize; private JLabel m_FileNow; private JLabel m_DownloadNumber; + private JLabel m_DownloadTo; + private JLabel m_FileAddress; private JButton m_Cancel; @@ -120,11 +122,11 @@ infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.PAGE_AXIS)); infoPanel.setBorder(BorderFactory.createTitledBorder("Information")); - JLabel file = new JLabel(loc.getMessage("DownloadTab.Downloading") + ": " + m_Download.getCurrentDownload().getAddress()); - file.setOpaque(false); + m_FileAddress = new JLabel(loc.getMessage("DownloadTab.Downloading") + ": " + m_Download.getCurrentDownload().getAddress()); + m_FileAddress.setOpaque(false); - JLabel to = new JLabel(loc.getMessage("DownloadTab.To") + ": " + m_Download.getCurrentDownload().getToFile()); - to.setOpaque(false); + m_DownloadTo = new JLabel(loc.getMessage("DownloadTab.To") + ": " + m_Download.getCurrentDownload().getToFile()); + m_DownloadTo.setOpaque(false); m_AverageKB = new JLabel(loc.getMessage("DownloadTab.AverageKBSec") + ": " + m_Download.getCurrentDownload().getAverageKBSec()); m_AverageKB.setOpaque(false); @@ -139,9 +141,9 @@ m_Cancel.setActionCommand("Cancel"); m_Cancel.addActionListener(this); - infoPanel.add(file); + infoPanel.add(m_FileAddress); infoPanel.add(Box.createRigidArea(new Dimension(0, 5))); - infoPanel.add(to); + infoPanel.add(m_DownloadTo); infoPanel.add(Box.createRigidArea(new Dimension(0, 5))); infoPanel.add(m_AverageKB); infoPanel.add(Box.createRigidArea(new Dimension(0, 5))); @@ -163,7 +165,6 @@ public void completed(Download dl) { - m_Progress.setString(m_Interface.getLocalisation().getMessage("Download.Completed")); } public void stateChanged(Download dl, int oldState, int newState) @@ -172,13 +173,14 @@ public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) { + System.out.println("progress"); if (m_Progress.getMaximum() != (int)totalFileSize) { m_Progress.setMaximum((int)totalFileSize); m_Progress.setValue(0); } Localisation loc = m_Interface.getLocalisation(); - if (m_FileSize.getText().endsWith("unknown")) + if (!m_FileSize.getText().equals(loc.getMessage("DownloadTab.FileSize") + ": " + ByteParser.convert(totalFileSize, ByteParser.FORMAT_MB, 2) + " MB")) { m_FileSize.setText(loc.getMessage("DownloadTab.FileSize") + ": " + ByteParser.convert(totalFileSize, ByteParser.FORMAT_MB, 2) + " MB"); } @@ -202,13 +204,19 @@ public void downloadStarted(Download dl, int number, int total) { + Localisation loc = m_Interface.getLocalisation(); ParameterList pmList = ParameterList.makeParameterList("number:" + String.valueOf(number) + ";outOf:" + String.valueOf(total)); - m_DownloadNumber.setText(m_Interface.getLocalisation().getLocalisedMessageParams("DownloadTab.NumberDownloads", pmList)); + m_DownloadNumber.setText(loc.getLocalisedMessageParams("DownloadTab.NumberDownloads", pmList)); + m_DownloadTo.setText(loc.getMessage("DownloadTab.To") + ": " + dl.getToFile()); + m_FileAddress.setText(loc.getMessage("DownloadTab.Downloading") + ": " + dl.getAddress()); + m_FileSize.setText(loc.getMessage("DownloadTab.FileSize") + ": " + ByteParser.convert(dl.getFileSize(), ByteParser.FORMAT_MB, 2) + " MB"); } public void downloadCompleted(Download dl) { - + Localisation loc = m_Interface.getLocalisation(); + m_Progress.setString(loc.getMessage("DownloadTab.Completed")); + m_FileNow.setText(loc.getMessage("DownloadTab.Downloaded") + ": " + ByteParser.convert(dl.getFileSize(), ByteParser.FORMAT_MB, 2) + " MB"); } public void totalProgress(long totalDownloaded, long totalSize) @@ -233,7 +241,7 @@ if (e.equals("Cancel")) { m_Interface.getDownloadManager().cancelDownload(m_Download); - m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.Cancalled")); + m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.Cancelled")); } } @@ -241,6 +249,12 @@ { m_TotalProgress.setValue(m_TotalProgress.getMaximum()); m_TotalProgress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.AllCompleted")); + m_Download.removeListener(this); + m_Download.removeProgressListener(this); + m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.AllCompleted")); + m_Progress.setValue(m_Progress.getMaximum()); + + } } Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-02 18:26:37 UTC (rev 216) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-03 15:21:59 UTC (rev 217) @@ -2,7 +2,7 @@ DownloadTab.AverageKBSec = Average Kb Sec DownloadTab.To = To DownloadTab.FileSize = File size -DownloadTab.Unknown = unknown +DownloadTab.Unknown = Unknown DownloadTab.Downloaded = Downloaded DownloadTab.Downloading = Downloading DownloadTab.Cancel = Cancel This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-02 18:27:28
|
Revision: 216 http://opencds.svn.sourceforge.net/opencds/?rev=216&view=rev Author: levia Date: 2008-09-02 18:26:37 +0000 (Tue, 02 Sep 2008) Log Message: ----------- - Sigh. Got downloading to work, just the listener system isn't working properly yet. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/Localisation.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginLocalisation.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-02 15:01:47 UTC (rev 215) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-02 18:26:37 UTC (rev 216) @@ -21,6 +21,7 @@ */ package org.opencdspowered.opencds.core.download; +import java.util.NoSuchElementException; import javolution.util.FastTable; /** @@ -46,6 +47,7 @@ private long m_TotalSize = 0; private long m_CurrentProgress = 0; private int m_TotalDownloads = 0; + private long m_Previous = 0; public ReleaseDownload(String baseURL) { @@ -132,11 +134,20 @@ public void addDownload(Download dl) { m_ReleaseDownloads.add(dl); - m_TotalSize += dl.getFileSize(); m_TotalDownloads += 1; } /** + * Add a long to the total size. + * + * @param amount The amount of bytes to add. + */ + public void addSize(long size) + { + m_TotalSize += size; + } + + /** * Remove a download from the system. * * @param dl The download to remove. @@ -154,11 +165,25 @@ */ public Download getNextInLine() { - Download dl = m_ReleaseDownloads.getFirst(); - removeDownload(dl); - m_CurrentDownload = dl; - fireDownloadStarted(); - return dl; + try + { + Download dl = m_ReleaseDownloads.getFirst(); + removeDownload(dl); + if (m_CurrentDownload != null) + { + m_CurrentDownload.removeProgressListener(this); + m_CurrentDownload.removeListener(this); + } + m_CurrentDownload = dl; + dl.addListener(this); + dl.addProgressListener(this); + fireDownloadStarted(); + return dl; + } + catch (NoSuchElementException e) + { + return null; + } } /** @@ -172,19 +197,6 @@ } /** - * Set the progress. - * - * @param amount Amount downloaded so far. - */ - public void setProgress(double size) - { - long downloadedNow = ((long)(size - (double)m_CurrentDownload.getFileSize())); - m_CurrentProgress += downloadedNow; - m_CurrentDownload.setProgress(size); - fireTotalProgress(); - } - - /** * Set the state for the download. * * @param state The state of the download. @@ -228,6 +240,26 @@ return m_TotalSize; } + /** + * Get the total number of downloads. + * + * @return Integer with the number of downloads. + */ + public int getDownloadAmount() + { + return m_TotalDownloads; + } + + /** + * Get the download it is at right now. + * + * @return Integer with the current number. + */ + public int getCurrentDownloadNumber() + { + return m_TotalDownloads - m_ReleaseDownloads.size(); + } + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) { for (int i = 0; i < m_DownloadProgressListeners.size(); i++) @@ -235,6 +267,13 @@ DownloadProgressListener listener = m_DownloadProgressListeners.get(i); listener.progress(dl, totalFileSize, currentFileSize, percentage, kbsec); } + + m_CurrentProgress += currentFileSize - m_Previous; + + m_Previous = (long)currentFileSize; + + System.out.println("Current progress: " + m_CurrentProgress); + fireTotalProgress(); } public void stateChanged(Download dl, int oldState, int newState) @@ -254,6 +293,7 @@ DownloadListener listener = m_DownloadListeners.get(i); listener.completed(dl); } + System.out.println("Size: " + m_ReleaseDownloads.size()); } private void fireDownloadStarted() @@ -264,6 +304,7 @@ listener.downloadStarted(m_CurrentDownload, m_TotalDownloads - m_ReleaseDownloads.size(), m_TotalDownloads); } + m_Previous = 0; } private void fireDownloadCompleted(Download dl) @@ -272,7 +313,6 @@ { ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); listener.downloadCompleted(dl); - } } @@ -284,6 +324,15 @@ listener.totalProgress(m_CurrentProgress, m_TotalSize); } } + + private void fireAllCompleted() + { + for (int i = 0; i < m_ReleaseDownloadListeners.size(); i++) + { + ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); + listener.allCompleted(); + } + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java 2008-09-02 15:01:47 UTC (rev 215) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java 2008-09-02 18:26:37 UTC (rev 216) @@ -51,6 +51,11 @@ * @param totalSize The total amount of bytes that need to be downloaded. */ public void totalProgress(long totalDownloaded, long totalSize); + + /** + * Called when everything has been completed. + */ + public void allCompleted(); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/Localisation.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/Localisation.java 2008-09-02 15:01:47 UTC (rev 215) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/Localisation.java 2008-09-02 18:26:37 UTC (rev 216) @@ -45,6 +45,24 @@ public abstract Object getLocalisedObject(String key); /** + * Get a message with given parameters. + * + * @param key The key. + * @param paramList The parameter list. + * @return The message. + */ + public abstract String getLocalisedMessageParams(String key, ParameterList paramList); + + /** + * Get a message with given parameters. + * + * @param key The key. + * @param paramList The parameter list. + * @return The message. + */ + public abstract String getMessageWithParams(String key, ParameterList list); + + /** * Returns a localised message. Same as getLocalisedMessage. * * @return A localised message. Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginLocalisation.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginLocalisation.java 2008-09-02 15:01:47 UTC (rev 215) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginLocalisation.java 2008-09-02 18:26:37 UTC (rev 216) @@ -23,10 +23,12 @@ import org.opencdspowered.opencds.core.config.ConfigurationManager; import org.opencdspowered.opencds.core.logging.Logger; -import org.opencdspowered.opencds.core.lang.Localisation; +import org.opencdspowered.opencds.core.lang.*; import java.util.Vector; import java.util.Enumeration; +import java.util.Iterator; import java.util.Locale; +import java.util.Map; import java.util.jar.JarFile; import java.util.jar.JarEntry; @@ -325,6 +327,46 @@ return ret; } + /** + * Get a message with given parameters. + * + * @param key The key. + * @param paramList The parameter list. + * @return The message. + */ + public String getLocalisedMessageParams(String key, ParameterList paramList) + { + if (m_CurrentLanguage == null) + { + return null; + } + String ret = null; + if ((ret = m_CurrentLanguage.getLocalisedMessage(key)) == null) + { + if ((ret = m_Languages.get(0).getLocalisedMessage(key)) == null) + { + return null; + } + } + + for (Iterator<Map.Entry<String, String>> it = paramList.entrySet().iterator(); it.hasNext();) + { + Map.Entry<String, String> entry = it.next(); + + if (ret.indexOf("%" + entry.getKey()) != -1) + { + ret = ret.replaceAll("%" + entry.getKey(), entry.getValue()); + } + } + + return ret; + } + + public String getMessageWithParams(String key, ParameterList list) + { + return getLocalisedMessageParams(key, list); + } + public Object getLocalisedObject(String key) { if (m_CurrentLanguage == null) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-02 15:01:47 UTC (rev 215) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-02 18:26:37 UTC (rev 216) @@ -146,7 +146,7 @@ Index index = it.next(); Download dl = new Download(baseUrl + index.getURL(), installTo + index.getURL()); - dl.setFileSize(index.getFileSize()); + relDl.addSize(index.getFileSize()); System.out.println("baseURL: " + baseUrl); System.out.println("IndexURL: " + index.getURL()); System.out.println("InstallTo: " + installTo); Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-02 15:01:47 UTC (rev 215) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-02 18:26:37 UTC (rev 216) @@ -30,6 +30,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import org.opencdspowered.opencds.core.lang.ParameterList; /** * The class that initializes and shows a download tab. @@ -46,6 +47,7 @@ private JLabel m_AverageKB; private JLabel m_FileSize; private JLabel m_FileNow; + private JLabel m_DownloadNumber; private JButton m_Cancel; @@ -108,6 +110,11 @@ m_TotalProgress.setBackground(Color.BLACK); m_TotalProgress.setMaximum((int)m_Download.getTotalSize()); + String currentNumber = String.valueOf(m_Download.getCurrentDownloadNumber()); + String total = String.valueOf(m_Download.getDownloadAmount()); + ParameterList pmList = ParameterList.makeParameterList("number:" + currentNumber + ";outOf:" + total); + m_DownloadNumber = new JLabel(loc.getLocalisedMessageParams("DownloadTab.NumberDownloads", pmList)); + JPanel infoPanel = new JPanel(); infoPanel.setOpaque(false); infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.PAGE_AXIS)); @@ -141,8 +148,10 @@ infoPanel.add(m_FileSize); infoPanel.add(Box.createRigidArea(new Dimension(0, 5))); infoPanel.add(m_FileNow); - + m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); + m_ContentPane.add(m_DownloadNumber); + m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); m_ContentPane.add(m_Progress); m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); m_ContentPane.add(m_TotalProgress); @@ -193,7 +202,8 @@ public void downloadStarted(Download dl, int number, int total) { - System.out.println("download: " + String.valueOf(number) + " out of " + String.valueOf(total) + " started."); + ParameterList pmList = ParameterList.makeParameterList("number:" + String.valueOf(number) + ";outOf:" + String.valueOf(total)); + m_DownloadNumber.setText(m_Interface.getLocalisation().getLocalisedMessageParams("DownloadTab.NumberDownloads", pmList)); } public void downloadCompleted(Download dl) @@ -204,6 +214,16 @@ public void totalProgress(long totalDownloaded, long totalSize) { m_TotalProgress.setValue((int)totalDownloaded); + System.out.println("Totla " + totalDownloaded + " : " + totalSize); + System.out.println(totalDownloaded/totalSize); + double percent = ((double)((double)totalDownloaded/(double)totalSize)*100); + System.out.println(percent); + + BigDecimal bd = new BigDecimal(percent); + bd = bd.setScale(2, BigDecimal.ROUND_UP); + + ParameterList pmList = ParameterList.makeParameterList("percent:" + bd.intValue()); + m_TotalProgress.setString(m_Interface.getLocalisation().getLocalisedMessageParams("DownloadTab.TotalProgress", pmList)); } public void actionPerformed(ActionEvent event) @@ -217,5 +237,11 @@ } } + public void allCompleted() + { + m_TotalProgress.setValue(m_TotalProgress.getMaximum()); + m_TotalProgress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.AllCompleted")); + } + } Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-02 15:01:47 UTC (rev 215) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-09-02 18:26:37 UTC (rev 216) @@ -7,4 +7,7 @@ DownloadTab.Downloading = Downloading DownloadTab.Cancel = Cancel DownloadTab.Completed = Download completed. -DownloadTab.Cancelled = Download cancelled. \ No newline at end of file +DownloadTab.Cancelled = Download cancelled. +DownloadTab.NumberDownloads = %number out of %outOf +DownloadTab.TotalProgress = Total progress (%percent %) +DownloadTab.AllCompleted = All completed \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-02 15:01:47
|
Revision: 215 http://opencds.svn.sourceforge.net/opencds/?rev=215&view=rev Author: levia Date: 2008-09-02 15:01:47 +0000 (Tue, 02 Sep 2008) Log Message: ----------- - Big change in the download system. Download is now used internally, and ReleaseDownload has made it's introduction. - Downloading project releases almost completely works now, just some small issues persist. Modified Paths: -------------- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManagerListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadQueue.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java Modified: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java 2008-09-02 11:05:57 UTC (rev 214) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java 2008-09-02 15:01:47 UTC (rev 215) @@ -133,6 +133,7 @@ Element fileElem = m_Document.createElement("file"); fileElem.setAttribute("file", file.getName()); fileElem.setAttribute("hash", getMD5FromFile(file)); + fileElem.setAttribute("size", String.valueOf(file.length())); elem.appendChild(fileElem); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java 2008-09-02 15:01:47 UTC (rev 215) @@ -21,8 +21,6 @@ */ package org.opencdspowered.opencds.core.download; -import java.util.*; - /** * The DownloadProtocol class represents one DownloadProtocol. * @@ -91,13 +89,13 @@ * @param download The download to get. * @return True if the download was succesful. */ - public abstract boolean download(Download download); + public abstract boolean download(ReleaseDownload download); /** * Cancel a download. * * @param download The download that needs to be cancelled */ - public abstract void cancel(Download download); + public abstract void cancel(ReleaseDownload download); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-09-02 15:01:47 UTC (rev 215) @@ -21,7 +21,6 @@ */ package org.opencdspowered.opencds.core.download; -import org.opencdspowered.opencds.core.exceptions.*; import java.util.*; public class DownloadHandlerManager @@ -136,12 +135,12 @@ * @param download The download given. * @return A reference to a DownloadHandler object, null otherwise. */ - public DownloadHandler getHandler(Download download) + public DownloadHandler getHandler(ReleaseDownload download) { for (Enumeration<DownloadHandler> entries = m_DownloadHandlers.elements(); entries.hasMoreElements();) { DownloadHandler proto = (DownloadHandler)entries.nextElement(); - if (download.getAddress().startsWith(proto.getProtocol()) || download.getAddress().startsWith(proto.getFullName())) + if (download.getProtocol().startsWith(proto.getProtocol()) || download.getProtocol().startsWith(proto.getFullName())) { return proto; } @@ -182,13 +181,13 @@ * @param download The download to initiate using given handler * @return True if the handler was fired, false if not. */ - public boolean fireHandler(Download download) + public boolean fireHandler(ReleaseDownload download) { for (Enumeration<DownloadHandler> entries = m_DownloadHandlers.elements(); entries.hasMoreElements();) { DownloadHandler proto = (DownloadHandler)entries.nextElement(); - if (download.getAddress().startsWith(proto.getProtocol())) + if (download.getProtocol().startsWith(proto.getProtocol())) { return proto.download(download); } @@ -201,7 +200,7 @@ * * @param dl The download that needs to be cancelled. */ - public void cancelDownload(Download dl) + public void cancelDownload(ReleaseDownload dl) { DownloadHandler handler = getHandler(dl); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-02 15:01:47 UTC (rev 215) @@ -23,40 +23,37 @@ import org.opencdspowered.opencds.core.logging.Logger; import org.opencdspowered.opencds.core.init.*; -import org.opencdspowered.opencds.core.exceptions.DownloadException; import org.opencdspowered.opencds.core.exceptions.InvalidActionException; import java.util.*; -import java.io.*; -import java.net.*; /** - * The DownloadManager handles all downloads that have been given. It downloads + * The ReleaseDownloadManager handles all ReleaseDownloads that have been given. It ReleaseDownloads * the files in a seperate thread so you can continue doing your stuff. * * @author Lars 'Levia' Wesselius */ public class DownloadManager { - /** The download is still busy downloading. */ + /** The ReleaseDownload is still busy ReleaseDownloading. */ public static final int STATE_DOWNLOADING = 0; - /** The download is queued and waiting for download. */ + /** The ReleaseDownload is queued and waiting for ReleaseDownload. */ public static final int STATE_QUEUED = 1; - /** The download is added to the system, but is not queued, thus not being - downloaded as of this moment. */ + /** The ReleaseDownload is added to the system, but is not queued, thus not being + ReleaseDownloaded as of this moment. */ public static final int STATE_IDLE = 2; - /** The download has completed and is about to be removed from the system */ + /** The ReleaseDownload has completed and is about to be removed from the system */ public static final int STATE_DONE = 3; - /** The download has failed. Either we couldn't connect to the address, we + /** The ReleaseDownload has failed. Either we couldn't connect to the address, we couldn't log in when it is an FTP server, or any additional checks failed. */ public static final int STATE_FAILED = 4; private DownloadQueue m_Queue; - private List<Download> m_DownloadList = new ArrayList<Download>(); + private List<ReleaseDownload> m_ReleaseDownloadList = new ArrayList<ReleaseDownload>(); private List<DownloadManagerListener> m_Listeners = new ArrayList<DownloadManagerListener>(); private DownloadHandlerManager m_DownloadHandlerManager; @@ -64,7 +61,7 @@ boolean m_QueueStop = false; /** - * The DownloadManager constructor. + * The ReleaseDownloadManager constructor. */ public DownloadManager() { @@ -75,9 +72,9 @@ { public void onShutdown() { - for (Iterator<Download> it = m_DownloadList.iterator(); it.hasNext();) + for (Iterator<ReleaseDownload> it = m_ReleaseDownloadList.iterator(); it.hasNext();) { - Download dl = (Download)it.next(); + ReleaseDownload dl = (ReleaseDownload)it.next(); if (dl.getState() == STATE_DOWNLOADING) { dl.setState(STATE_FAILED); @@ -90,95 +87,93 @@ } /** - * Adds a download to the system. The download is added with the state IDLE - * and can be downloaded via <i>queueDownload</i>. + * Adds a ReleaseDownload to the system. The ReleaseDownload is added with the state IDLE + * and can be ReleaseDownloaded via <i>queueReleaseDownload</i>. * - * @param address The address of the download. - * @param toFile The destination of the download. - * @return The download created. + * @param address The address of the ReleaseDownload. + * @param toFile The destination of the ReleaseDownload. + * @return The ReleaseDownload created. */ - public Download addDownload(String address, String toFile) throws InvalidActionException + public ReleaseDownload addDownload(String address, String toFile) throws InvalidActionException { if (address == null || toFile == null) { - throw new InvalidActionException("The download does not contain" + + throw new InvalidActionException("The ReleaseDownload does not contain" + "an address or an destination."); } + Download dl = new Download(address, toFile, STATE_IDLE); - m_DownloadList.add(dl); - fireDownloadAdded(dl); - return dl; + ReleaseDownload relDl = new ReleaseDownload(address); + relDl.addDownload(dl); + m_ReleaseDownloadList.add(relDl); + fireDownloadAdded(relDl); + return relDl; } /** - * Adds a download to the system. The download is added with the state IDLE - * and can be download via <i>queueDownload</i>. If the state of the given - * download is not IDLE, it will be set to IDLE, therefore two events will - * be fired when you have a listener: downloadAdded, and - * downloadStateChanged. + * Adds a ReleaseDownload to the system. The ReleaseDownload is added with the state IDLE + * and can be ReleaseDownload via <i>queueReleaseDownload</i>. If the state of the given + * ReleaseDownload is not IDLE, it will be set to IDLE, therefore two events will + * be fired when you have a listener: ReleaseDownloadAdded, and + * ReleaseDownloadStateChanged. * - * @param download The download to add. + * @param ReleaseDownload The ReleaseDownload to add. */ - public void addDownload(Download download) throws InvalidActionException + public void addReleaseDownload(ReleaseDownload dl) throws InvalidActionException { int oldState = -1; - if (download.getState() != STATE_IDLE) + if (dl.getState() != STATE_IDLE) { - oldState = download.getState(); - download.setState(STATE_IDLE); + oldState = dl.getState(); + dl.setState(STATE_IDLE); } - if (download.getAddress() == null || download.getToFile() == null) - { - throw new InvalidActionException("The download does not contain" + - "an address or an destination."); - } - m_DownloadList.add(download); - fireDownloadAdded(download); + m_ReleaseDownloadList.add(dl); + fireDownloadAdded(dl); if (oldState != -1) { - fireDownloadStateChanged(download, oldState, STATE_IDLE); + fireDownloadStateChanged(dl, oldState, STATE_IDLE); } } /** - * Remove an download. + * Remove an ReleaseDownload. * - * @param download The download to remove. + * @param dl The ReleaseDownload to remove. * @return True if successful, false if not. */ - public boolean removeDownload(Download download) + public boolean removeReleaseDownload(ReleaseDownload dl) { - boolean ret = m_DownloadList.remove(download); - fireDownloadRemoved(download); + boolean ret = m_ReleaseDownloadList.remove(dl); + fireDownloadRemoved(dl); return ret; } /** - * Remove an download. + * Remove an ReleaseDownload. * - * @param index The index of the download. + * @param index The index of the ReleaseDownload. * @return True if successful, false if not. */ - public boolean removeDownload(int index) + public boolean removeReleaseDownload(int index) { - Download dl = m_DownloadList.get(index); - boolean ret = m_DownloadList.remove(dl); + ReleaseDownload dl = m_ReleaseDownloadList.get(index); + boolean ret = m_ReleaseDownloadList.remove(dl); fireDownloadRemoved(dl); return ret; } /** - * Get a download. + * Get a ReleaseDownload. * - * @param index The index of the download. - * @return Reference to the download. + * @param index The index of the ReleaseDownload. + * @return Reference to the ReleaseDownload. */ - public Download getDownload(int index) throws InvalidActionException + public ReleaseDownload getDownload(int index) throws InvalidActionException { - Download dl = null; + ReleaseDownload dl = null; try { - dl = m_DownloadList.get(index); + dl = m_ReleaseDownloadList.get(index); } catch (IndexOutOfBoundsException e) { @@ -191,39 +186,19 @@ } /** - * Get a download. + * Get a ReleaseDownload. * - * @param address The address of the download to get. - * @param toFile The destination of the download to get. - * @return Reference to the download, otherwise null. + * @param address The address of the ReleaseDownload to get. + * @return Reference to the ReleaseDownload, otherwise null. */ - public Download getDownload(String address, String toFile) + public ReleaseDownload getDownload(String address) { - for (Iterator<Download> it = m_DownloadList.iterator(); it.hasNext();) + for (Iterator<ReleaseDownload> it = m_ReleaseDownloadList.iterator(); it.hasNext();) { - Download dl = (Download)it.next(); - if (dl.getAddress().equals(address) && dl.getToFile().equals(toFile)) - { - return dl; - } - } - return null; - } - - /** - * Get a download. - * - * @param address The address of the download to get. - * @return Reference to the download, otherwise null. - */ - public Download getDownload(String address) - { - for (Iterator<Download> it = m_DownloadList.iterator(); it.hasNext();) - { - Download dl = (Download)it.next(); + ReleaseDownload dl = (ReleaseDownload)it.next(); synchronized (dl) { - if (dl.getAddress().equals(address)) + if (dl.getProtocol().equals(address)) { return dl; } @@ -234,22 +209,22 @@ } /** - * Checks whether this download is present in the system or not. + * Checks whether this ReleaseDownload is present in the system or not. * - * @param dl The download to check. + * @param dl The ReleaseDownload to check. * @return True if so, false if not. */ - public boolean isDownloadPresent(Download dl) + public boolean isDownloadPresent(ReleaseDownload dl) { - return m_DownloadList.contains(dl); + return m_ReleaseDownloadList.contains(dl); } /** - * Cancel a download, if it's currently running. + * Cancel a ReleaseDownload, if it's currently running. * - * @param dl The download to cancel. + * @param dl The ReleaseDownload to cancel. */ - public void cancelDownload(Download dl) + public void cancelDownload(ReleaseDownload dl) { switch (dl.getState()) { @@ -272,17 +247,17 @@ } /** - * Enqueue a download. Creates one if it does not exist. This method - * differs from <i>addDownload</i> (only if the download does not exist + * Enqueue a ReleaseDownload. Creates one if it does not exist. This method + * differs from <i>addReleaseDownload</i> (only if the ReleaseDownload does not exist * within the system) that it sets the state to QUEUE, and so that it will - * be downloaded as soon as possible. Same as for <i>addDownload</i>, the - * events fired are: downloadAdded and downloadStateChanged, as this will + * be ReleaseDownloaded as soon as possible. Same as for <i>addReleaseDownload</i>, the + * events fired are: ReleaseDownloadAdded and ReleaseDownloadStateChanged, as this will * set the state to QUEUED, whatever state it was in. * - * @param dl The download enqueue. + * @param dl The ReleaseDownload enqueue. * @return True if successful, false if not. */ - public boolean enqueueDownload(Download dl) + public boolean enqueueDownload(ReleaseDownload dl) { if (m_QueueRunning) { @@ -291,24 +266,18 @@ } if (!isDownloadPresent(dl)) { - if (dl.getAddress() != null && dl.getToFile() != null) - { - m_DownloadList.add(dl); - m_Queue.addDownload(dl); - int oldState = dl.getState(); - dl.setState(STATE_QUEUED); - fireDownloadAdded(dl); - fireDownloadStateChanged(dl, oldState, STATE_QUEUED); - return true; - } - else - { - return false; - } + + m_ReleaseDownloadList.add(dl); + m_Queue.addDownload(dl); + int oldState = dl.getState(); + dl.setState(STATE_QUEUED); + fireDownloadAdded(dl); + fireDownloadStateChanged(dl, oldState, STATE_QUEUED); + return true; } else { - //Add download to queue. + //Add ReleaseDownload to queue. m_Queue.addDownload(dl); int oldState = dl.getState(); if (oldState != STATE_QUEUED) @@ -321,13 +290,13 @@ } /** - * Dequeues a download. Dequeues means that it's removed from the download + * Dequeues a ReleaseDownload. Dequeues means that it's removed from the ReleaseDownload * queue and then set back to IDLE. * - * @param dl The download to dequeue. + * @param dl The ReleaseDownload to dequeue. * @return True if successful, false if not. */ - public boolean dequeueDownload(Download dl) throws InvalidActionException + public boolean dequeueDownload(ReleaseDownload dl) throws InvalidActionException { if (dl.getState() != STATE_DOWNLOADING) { @@ -349,7 +318,7 @@ } /** - * Starts the queue, so all the downloads in the queue are started once + * Starts the queue, so all the ReleaseDownloads in the queue are started once * at a time. */ public void startQueue() @@ -365,7 +334,7 @@ { public void run() { - Download dl = null; + ReleaseDownload dl = null; while (m_Queue.getNext() != null) { @@ -386,9 +355,8 @@ else { newState = STATE_FAILED; - Logger.getInstance().log(Logger.LOG_ERROR, "Download: " + dl.getAddress() + " failed downloading. Protocol not supported."); + Logger.getInstance().log(Logger.LOG_ERROR, "The release failed downloading. Protocol not supported."); } - System.out.println("status: " + newState); dl.setState(newState); fireDownloadStateChanged(dl, STATE_DOWNLOADING, newState); m_Queue.removeDownload(dl); @@ -402,7 +370,7 @@ } /** - * Stops the queue. If theres a download currently in progress, it is + * Stops the queue. If theres a ReleaseDownload currently in progress, it is * finished first. */ public void stopQueue() throws InvalidActionException @@ -434,9 +402,9 @@ } /** - * Gets the download handler manager. + * Gets the ReleaseDownload handler manager. * - * @return A reference to the Download Handler Manager. + * @return A reference to the ReleaseDownload Handler Manager. */ public DownloadHandlerManager getDownloadHandlerManager() { @@ -464,60 +432,60 @@ } /** - * Fire an downloadAdded event. + * Fire an ReleaseDownloadAdded event. * - * @param download The download that has been added. + * @param dl The ReleaseDownload that has been added. */ - private void fireDownloadAdded(Download download) + private void fireDownloadAdded(ReleaseDownload dl) { for (int i = 0; i < m_Listeners.size(); i++) { DownloadManagerListener listener = (DownloadManagerListener)m_Listeners.get(i); - listener.downloadAdded(download); + listener.downloadAdded(dl); } } /** - * Fire an downloadRemoved event. + * Fire an ReleaseDownloadRemoved event. * - * @param download The download that has been removed. + * @param dl The ReleaseDownload that has been removed. */ - private void fireDownloadRemoved(Download download) + private void fireDownloadRemoved(ReleaseDownload dl) { for (int i = 0; i < m_Listeners.size(); i++) { DownloadManagerListener listener = (DownloadManagerListener)m_Listeners.get(i); - listener.downloadRemoved(download); + listener.downloadRemoved(dl); } } /** - * Fire an downloadStateChanged event. + * Fire an ReleaseDownloadStateChanged event. * - * @param download The download that has been added. - * @param oldState The old state of the download. - * @param newState The new state of the download. + * @param dl The ReleaseDownload that has been added. + * @param oldState The old state of the ReleaseDownload. + * @param newState The new state of the ReleaseDownload. */ - private void fireDownloadStateChanged(Download download, int oldState, int newState) + private void fireDownloadStateChanged(ReleaseDownload dl, int oldState, int newState) { for (int i = 0; i < m_Listeners.size(); i++) { DownloadManagerListener listener = (DownloadManagerListener)m_Listeners.get(i); - listener.downloadStateChanged(download, oldState, newState); + listener.downloadStateChanged(dl, oldState, newState); } } /** - * Fire an downloadCompleted event. + * Fire an ReleaseDownloadCompleted event. * - * @param download The download that has been completed. + * @param ReleaseDownload The ReleaseDownload that has been completed. */ - private void fireDownloadCompleted(Download download) + private void fireReleaseDownloadCompleted(ReleaseDownload ReleaseDownload) { for (int i = 0; i < m_Listeners.size(); i++) { DownloadManagerListener listener = (DownloadManagerListener)m_Listeners.get(i); - listener.downloadDone(download); + listener.downloadDone(ReleaseDownload); } } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManagerListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManagerListener.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManagerListener.java 2008-09-02 15:01:47 UTC (rev 215) @@ -38,28 +38,28 @@ * @param oldState The old state of the download. * @param newState The new state of the download. */ - public void downloadStateChanged(Download download, int oldState, int newState); + public void downloadStateChanged(ReleaseDownload download, int oldState, int newState); /** * This function is fired when a download has completed downloading. * * @param download The download which has completed downloading. */ - public void downloadDone(Download download); + public void downloadDone(ReleaseDownload download); /** * This function is fired when a download has been removed from the system. * * @param download The download which has been, or will be removed. */ - public void downloadRemoved(Download download); + public void downloadRemoved(ReleaseDownload download); /** * This function is fired when a download has been added to the system. * * @param download The download which has been added. */ - public void downloadAdded(Download download); + public void downloadAdded(ReleaseDownload download); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadQueue.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadQueue.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadQueue.java 2008-09-02 15:01:47 UTC (rev 215) @@ -32,14 +32,14 @@ */ class DownloadQueue { - private Queue<Download> m_DownloadQueue; + private Queue<ReleaseDownload> m_DownloadQueue; /** * The DownloadQueue constructor. */ public DownloadQueue() { - m_DownloadQueue = new LinkedList<Download>(); + m_DownloadQueue = new LinkedList<ReleaseDownload>(); } /** @@ -47,7 +47,7 @@ * * @param download The download to add. */ - public void addDownload(Download dl) + public void addDownload(ReleaseDownload dl) { m_DownloadQueue.add(dl); } @@ -58,7 +58,7 @@ * @param download The download to remove. * @return True if successful, false if not. */ - public boolean removeDownload(Download dl) + public boolean removeDownload(ReleaseDownload dl) { return m_DownloadQueue.remove(dl); } @@ -79,7 +79,7 @@ * * @return A reference to a Download object. */ - public Download retrieveNext() + public ReleaseDownload retrieveNext() { return m_DownloadQueue.poll(); } @@ -89,7 +89,7 @@ * * @return A reference to a Download object. */ - public Download getNext() throws InvalidActionException + public ReleaseDownload getNext() throws InvalidActionException { return m_DownloadQueue.peek(); } Added: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownload.java 2008-09-02 15:01:47 UTC (rev 215) @@ -0,0 +1,291 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.core.download; + +import javolution.util.FastTable; + +/** + * The ReleaseDownload contains multiple Download objects, to download a complete + * project. + * + * @author Lars 'Levia' Wesselius +*/ +public class ReleaseDownload implements DownloadProgressListener, DownloadListener +{ + private FastTable<Download> m_ReleaseDownloads = new FastTable<Download>(); + + private FastTable<DownloadProgressListener> m_DownloadProgressListeners = new FastTable<DownloadProgressListener>(); + private FastTable<DownloadListener> m_DownloadListeners = new FastTable<DownloadListener>(); + + private int m_State = DownloadManager.STATE_IDLE; + + private FastTable<ReleaseDownloadListener> m_ReleaseDownloadListeners = new FastTable<ReleaseDownloadListener>(); + + private String m_Protocol; + + private Download m_CurrentDownload = null; + private long m_TotalSize = 0; + private long m_CurrentProgress = 0; + private int m_TotalDownloads = 0; + + public ReleaseDownload(String baseURL) + { + m_Protocol = baseURL; + } + + /** + * Get the protocol for the downloads. + * + * @return The protocol string. + */ + public String getProtocol() + { + return m_Protocol; + } + + /** + * Adds a progress listener for the download. + * + * @param listener The listener. + */ + public void addProgressListener(DownloadProgressListener listener) + { + m_DownloadProgressListeners.add(listener); + } + + /** + * Removes a progress listener from the download. + * + * @param listener The listener to remove. + */ + public void removeProgressListener(DownloadProgressListener listener) + { + m_DownloadProgressListeners.remove(listener); + } + + /** + * Adds a listener for the download. + * + * @param listener The listener. + */ + public void addListener(DownloadListener listener) + { + m_DownloadListeners.add(listener); + } + + /** + * Removes a listener from the download. + * + * @param listener The listener to remove. + */ + public void removeListener(DownloadListener listener) + { + m_DownloadListeners.remove(listener); + } + + /** + * Adds a progress listener for the release. + * + * @param listener The listener. + */ + public void addReleaseListener(ReleaseDownloadListener listener) + { + m_ReleaseDownloadListeners.add(listener); + } + + /** + * Removes a progress listener from the release. + * + * @param listener The listener to remove. + */ + public void removeReleaseListener(ReleaseDownloadListener listener) + { + m_ReleaseDownloadListeners.remove(listener); + } + + /** + * Add a download to the release. + * + * @param dl The download to download. + * @return A Download reference. + * @see #Download + */ + public void addDownload(Download dl) + { + m_ReleaseDownloads.add(dl); + m_TotalSize += dl.getFileSize(); + m_TotalDownloads += 1; + } + + /** + * Remove a download from the system. + * + * @param dl The download to remove. + */ + public void removeDownload(Download dl) + { + m_ReleaseDownloads.remove(dl); + } + + /** + * Get the next file that requires downloading. The download is immediatly + * removed from the system. + * + * @return A Download reference. + */ + public Download getNextInLine() + { + Download dl = m_ReleaseDownloads.getFirst(); + removeDownload(dl); + m_CurrentDownload = dl; + fireDownloadStarted(); + return dl; + } + + /** + * Peek next in line. + * + * @return A download reference. + */ + public Download peek() + { + return m_ReleaseDownloads.getFirst(); + } + + /** + * Set the progress. + * + * @param amount Amount downloaded so far. + */ + public void setProgress(double size) + { + long downloadedNow = ((long)(size - (double)m_CurrentDownload.getFileSize())); + m_CurrentProgress += downloadedNow; + m_CurrentDownload.setProgress(size); + fireTotalProgress(); + } + + /** + * Set the state for the download. + * + * @param state The state of the download. + */ + public void setState(int state) + { + m_State = state; + } + + /** + * Get the state of the download. + * + * @return The state of the download. + */ + public int getState() + { + return m_State; + } + + /** + * Get the current download. + * + * @return The current download. + */ + public Download getCurrentDownload() + { + if (m_CurrentDownload == null) + { + return peek(); + } + return m_CurrentDownload; + } + + /** + * Get the total size of all the downloads. + * + * @return A long with the size. + */ + public long getTotalSize() + { + return m_TotalSize; + } + + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) + { + for (int i = 0; i < m_DownloadProgressListeners.size(); i++) + { + DownloadProgressListener listener = m_DownloadProgressListeners.get(i); + listener.progress(dl, totalFileSize, currentFileSize, percentage, kbsec); + } + } + + public void stateChanged(Download dl, int oldState, int newState) + { + for (int i = 0; i < m_DownloadListeners.size(); i++) + { + DownloadListener listener = m_DownloadListeners.get(i); + listener.stateChanged(dl, oldState, newState); + } + } + + public void completed(Download dl) + { + fireDownloadCompleted(dl); + for (int i = 0; i < m_DownloadListeners.size(); i++) + { + DownloadListener listener = m_DownloadListeners.get(i); + listener.completed(dl); + } + } + + private void fireDownloadStarted() + { + for (int i = 0; i < m_ReleaseDownloadListeners.size(); i++) + { + ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); + listener.downloadStarted(m_CurrentDownload, m_TotalDownloads - m_ReleaseDownloads.size(), m_TotalDownloads); + + } + } + + private void fireDownloadCompleted(Download dl) + { + for (int i = 0; i < m_ReleaseDownloadListeners.size(); i++) + { + ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); + listener.downloadCompleted(dl); + + } + } + + private void fireTotalProgress() + { + for (int i = 0; i < m_ReleaseDownloadListeners.size(); i++) + { + ReleaseDownloadListener listener = m_ReleaseDownloadListeners.get(i); + listener.totalProgress(m_CurrentProgress, m_TotalSize); + } + } +} + + + + Added: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/ReleaseDownloadListener.java 2008-09-02 15:01:47 UTC (rev 215) @@ -0,0 +1,58 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.core.download; + +/** + * The listener for a ReleaseDownload. It listens for progress changes etc. + * + * @author Lars 'Levia' Wesselius +*/ +public interface ReleaseDownloadListener +{ + /** + * Notification for when a new download has started. + * + * @param dl The download that was started. + * @param number The number of the download. + * @param total The total number of downloads. + */ + public void downloadStarted(Download dl, int number, int total); + + /** + * Notification for when a download has been completed. + * + * @param dl The download that was completed. + */ + public void downloadCompleted(Download dl); + + /** + * Notification for when there is a progress update. + * + * @param totalDownloaded The amount that has been downloaded already. + * @param totalSize The total amount of bytes that need to be downloaded. + */ + public void totalProgress(long totalDownloaded, long totalSize); +} + + + + Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java 2008-09-02 15:01:47 UTC (rev 215) @@ -36,18 +36,21 @@ { private String m_URL; private String m_MD5Hash; + private long m_Size; /** * Index constructor. * - * @param URL The url of the index. - * @param hash The hash of the associated file. + * @param URL The url of the index. + * @param hash The hash of the associated file. + * @param fileSize The size of the file in bytes. */ - public Index(String URL, String hash) + public Index(String URL, String hash, long fileSize) { m_URL = URL; m_MD5Hash = hash; + m_Size = fileSize; } /** @@ -70,5 +73,15 @@ return m_MD5Hash; } + /** + * Get the file size in bytes. + * + * @return The file size in bytes. + */ + public long getFileSize() + { + return m_Size; + } + } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-02 15:01:47 UTC (rev 215) @@ -40,6 +40,8 @@ { FastTable<Index> m_IndexTable = new FastTable<Index>(); + private String m_Protocol = null; + /** * Reads an index file from URL. * @@ -152,7 +154,9 @@ { parentName += "/"; } - Index ind = new Index(parentName + elem.getAttributeValue("file"), elem.getAttributeValue("hash")); + System.out.println(elem.getAttributeValue("size")); + Index ind = new Index(parentName + elem.getAttributeValue("file"), elem.getAttributeValue("hash"), Long.parseLong(elem.getAttributeValue("size"))); + m_IndexTable.add(ind); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-02 15:01:47 UTC (rev 215) @@ -65,7 +65,7 @@ int index = exe.getName().lastIndexOf("."); String fileName = exe.getName().substring(0, index); - Download download = null; + ReleaseDownload download = null; if (exe.getInstallTo().equals("$ProjectRoot")) { String downloadToDir = "data/" + project.getName() + "/" + fileName + "/"; @@ -140,16 +140,19 @@ int slashIndex = exe.getFileUrl().lastIndexOf("/"); String baseUrl = exe.getFileUrl().substring(0, slashIndex); + ReleaseDownload relDl = new ReleaseDownload(baseUrl); for (Iterator<Index> it = reader.getIndexes(); it.hasNext();) { Index index = it.next(); - Download dl = m_DownloadManager.addDownload(baseUrl + index.getURL(), installTo + index.getURL()); + Download dl = new Download(baseUrl + index.getURL(), installTo + index.getURL()); + dl.setFileSize(index.getFileSize()); System.out.println("baseURL: " + baseUrl); System.out.println("IndexURL: " + index.getURL()); System.out.println("InstallTo: " + installTo); - m_DownloadManager.enqueueDownload(dl); + relDl.addDownload(dl); } + m_DownloadManager.enqueueDownload(relDl); } } else @@ -175,7 +178,7 @@ } } - Download download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); + ReleaseDownload download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); m_DownloadManager.enqueueDownload(download); } m_DownloadManager.startQueue(); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-02 15:01:47 UTC (rev 215) @@ -22,7 +22,6 @@ package org.opencdspowered.opencds.ui.main; import org.opencdspowered.opencds.core.init.CoreInitializer; -import org.opencdspowered.opencds.core.index.*; import org.opencdspowered.opencds.core.config.ConfigurationManager; import org.opencdspowered.opencds.core.lang.DynamicLocalisation; import org.opencdspowered.opencds.core.update.*; @@ -38,7 +37,6 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.io.File; import java.util.Enumeration; /** Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-09-02 15:01:47 UTC (rev 215) @@ -112,7 +112,7 @@ Executable exe = elem.nextElement(); - Download dl = dlManager.getDownload(exe.getFileUrl()); + ReleaseDownload dl = dlManager.getDownload(exe.getFileUrl()); JProgressBar bar = new JProgressBar(); @@ -167,7 +167,7 @@ { Library lib = elem.nextElement(); - Download dl = dlManager.getDownload(lib.getFileUrl()); + ReleaseDownload dl = dlManager.getDownload(lib.getFileUrl()); JProgressBar bar = new JProgressBar(); bar.setStringPainted(true); @@ -220,7 +220,7 @@ { Source src = elem.nextElement(); - Download dl = dlManager.getDownload(src.getFileUrl()); + ReleaseDownload dl = dlManager.getDownload(src.getFileUrl()); JProgressBar bar = new JProgressBar(); bar.setStringPainted(true); @@ -353,7 +353,7 @@ Release rel = (Release)model.getValueAt(m_TitleTable.getSelectedRow(), 0); - Download dl = mgr.getDownload(rel.getFileUrl()); + ReleaseDownload dl = mgr.getDownload(rel.getFileUrl()); m_Tabs.addTab(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Release"), new ReleaseTab(m_MainFrame, m_Tabs, rel, dl)); m_Tabs.setSelectedIndex(1); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java 2008-09-02 11:05:57 UTC (rev 214) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java 2008-09-02 15:01:47 UTC (rev 215) @@ -22,18 +22,11 @@ package org.opencdspowered.opencds.ui.project; import org.opencdspowered.opencds.ui.main.MainFrame; -import org.opencdspowered.opencds.ui.util.Util; -import org.opencdspowered.opencds.core.logging.Logger; import org.opencdspowered.opencds.core.project.*; import org.opencdspowered.opencds.core.lang.*; import org.opencdspowered.opencds.core.download.*; import javax.swing.*; -import javax.swing.table.*; -import javax.swing.event.*; import java.awt.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; /** * Release tab shows information about a release. @@ -44,14 +37,14 @@ { private MainFrame m_MainFrame; private Release m_Release; - private Download m_Download = null; + private ReleaseDownload m_Download = null; private JTabbedPane m_Tabs; private JProgressBar m_ProgressBar; /** * The information tabs constructor. */ - public ReleaseTab(MainFrame mainFrame, JTabbedPane pane, Release release, Download download) + public ReleaseTab(MainFrame mainFrame, JTabbedPane pane, Release release, ReleaseDownload download) { m_Tabs = pane; m_Release = release; Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java 2008-09-02 11:05:57 UTC (rev 214) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java 2008-09-02 15:01:47 UTC (rev 215) @@ -31,35 +31,39 @@ super("File Transfer Protocol (FTP)", "ftp"); } - public boolean download(Download dl) + public boolean download(ReleaseDownload download) { try { // Parse the address string. - String address = dl.getAddress(); - String[] parts = address.split("/"); - String host = parts[2]; - - int dirStart = address.indexOf(host); - String dirName = address.substring(dirStart + host.length(), address.length()); - - int dirWhFile = dirName.lastIndexOf("/"); - String dirWithoutFile = dirName.substring(0, dirWhFile); - String fileName = dirName.substring(dirWhFile+1, dirName.length()); - - FTP ftp = new FTP(dl); - ftp.open(host); - if (!ftp.login("anonymous", "ope...@du...")) + Download dl; + while ((dl = download.getNextInLine()) != null) { - // We couldn't log in to the FTP server. - return false; + String address = dl.getAddress(); + String[] parts = address.split("/"); + String host = parts[2]; + + int dirStart = address.indexOf(host); + String dirName = address.substring(dirStart + host.length(), address.length()); + + int dirWhFile = dirName.lastIndexOf("/"); + String dirWithoutFile = dirName.substring(0, dirWhFile); + String fileName = dirName.substring(dirWhFile+1, dirName.length()); + + FTP ftp = new FTP(dl); + ftp.open(host); + if (!ftp.login("anonymous", "ope...@du...")) + { + // We couldn't log in to the FTP server. + return false; + } + if (dirWithoutFile.length() != 0) + { + ftp.cd(dirWithoutFile); + } + dl.setFileSize(ftp.size(fileName)); + ftp.get(fileName, new File(dl.getToFile())); } - if (dirWithoutFile.length() != 0) - { - ftp.cd(dirWithoutFile); - } - dl.setFileSize(ftp.size(fileName)); - ftp.get(fileName, new File(dl.getToFile())); } catch (Exception e) { @@ -68,7 +72,7 @@ return true; } - public void cancel(Download dl) + public void cancel(ReleaseDownload dl) { } } \ No newline at end of file Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-02 11:05:57 UTC (rev 214) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-09-02 15:01:47 UTC (rev 215) @@ -36,12 +36,13 @@ * * @author Lars 'Levia' Wesselius */ -public class HTTPDownloadTab implements DownloadProgressListener, DownloadListener, ActionListener +public class HTTPDownloadTab implements DownloadProgressListener, DownloadListener, ActionListener, ReleaseDownloadListener { private JPanel m_ContentPane; - private Download m_Download; + private ReleaseDownload m_Download; private JProgressBar m_Progress; + private JProgressBar m_TotalProgress; private JLabel m_AverageKB; private JLabel m_FileSize; private JLabel m_FileNow; @@ -55,12 +56,13 @@ /** * The HTTPDownloadTab constructor. */ - public HTTPDownloadTab(PluginInterface pluginInterface, Download download) + public HTTPDownloadTab(PluginInterface pluginInterface, ReleaseDownload download) { m_Interface = pluginInterface; m_Download = download; m_Download.addListener(this); m_Download.addProgressListener(this); + m_Download.addReleaseListener(this); initialize(); } @@ -88,10 +90,10 @@ m_ContentPane.setOpaque(false); m_Index = m_Interface.addTab( - loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getName(), + loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getCurrentDownload().getName(), new ImageIcon(DownloadManager.class.getResource("/org/opencdspowered/opencds/ui/icons/download-icon.png")), m_ContentPane, - loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getName() + loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getCurrentDownload().getName() ); @@ -100,18 +102,24 @@ m_Progress.setForeground(new Color(65, 105, 255)); m_Progress.setBackground(Color.BLACK); + m_TotalProgress = new JProgressBar(); + m_TotalProgress.setStringPainted(true); + m_TotalProgress.setForeground(new Color(65, 105, 255)); + m_TotalProgress.setBackground(Color.BLACK); + m_TotalProgress.setMaximum((int)m_Download.getTotalSize()); + JPanel infoPanel = new JPanel(); infoPanel.setOpaque(false); infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.PAGE_AXIS)); infoPanel.setBorder(BorderFactory.createTitledBorder("Information")); - JLabel file = new JLabel(loc.getMessage("DownloadTab.Downloading") + ": " + m_Download.getAddress()); + JLabel file = new JLabel(loc.getMessage("DownloadTab.Downloading") + ": " + m_Download.getCurrentDownload().getAddress()); file.setOpaque(false); - JLabel to = new JLabel(loc.getMessage("DownloadTab.To") + ": " + m_Download.getToFile()); + JLabel to = new JLabel(loc.getMessage("DownloadTab.To") + ": " + m_Download.getCurrentDownload().getToFile()); to.setOpaque(false); - m_AverageKB = new JLabel(loc.getMessage("DownloadTab.AverageKBSec") + ": " + m_Download.getAverageKBSec()); + m_AverageKB = new JLabel(loc.getMessage("DownloadTab.AverageKBSec") + ": " + m_Download.getCurrentDownload().getAverageKBSec()); m_AverageKB.setOpaque(false); m_FileSize = new JLabel(loc.getMessage("DownloadTab.FileSize") + ": " + loc.getMessage("DownloadTab.Unknown")); @@ -136,6 +144,8 @@ m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); m_ContentPane.add(m_Progress); + m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); + m_ContentPane.add(m_TotalProgress); m_ContentPane.add(Box.createRigidArea(new Dimension(0, 10))); m_ContentPane.add(infoPanel); m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); @@ -170,9 +180,9 @@ m_Progress.setValue((int)progress + add); BigDecimal bd = new BigDecimal(kbsec); bd = bd.setScale(2, BigDecimal.ROUND_UP); - m_Progress.setString(loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getName() + "(" + bd.toString() + " KB/Sec)"); + m_Progress.setString(loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getCurrentDownload().getName() + "(" + bd.toString() + " KB/Sec)"); - bd = new BigDecimal(m_Download.getAverageKBSec()); + bd = new BigDecimal(m_Download.getCurrentDownload().getAverageKBSec()); bd = bd.setScale(2, BigDecimal.ROUND_UP); m_AverageKB.setText(loc.getMessage("DownloadTab.AverageKBSec") + ": " + bd.toString()); @@ -181,6 +191,21 @@ } } + public void downloadStarted(Download dl, int number, int total) + { + System.out.println("download: " + String.valueOf(number) + " out of " + String.valueOf(total) + " started."); + } + + public void downloadCompleted(Download dl) + { + + } + + public void totalProgress(long totalDownloaded, long totalSize) + { + m_TotalProgress.setValue((int)totalDownloaded); + } + public void actionPerformed(ActionEvent event) { String e = event.getActionCommand(); Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-02 11:05:57 UTC (rev 214) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-02 15:01:47 UTC (rev 215) @@ -40,87 +40,91 @@ m_Interface = pluginInterface; } - public boolean download(Download dl) + public boolean download(ReleaseDownload download) { - m_DownloadTab = new HTTPDownloadTab(m_Interface, dl); - OutputStream out = null; - URLConnection conn = null; - InputStream in = null; - try + Download dl; + m_DownloadTab = new HTTPDownloadTab(m_Interface, download); + while ((dl = download.getNextInLine()) != null) { - URL url = new URL(dl.getAddress()); - - - File file = new File(dl.getToFile()); + OutputStream out = null; + URLConnection conn = null; + InputStream in = null; + try + { + URL url = new URL(dl.getAddress()); - System.out.println("Tofile:" + dl.getToFile()); - if (!file.exists()) - { - if (file.isDirectory()) + + File file = new File(dl.getToFile()); + + System.out.println("Tofile:" + dl.getToFile()); + if (!file.exists()) { - file.mkdirs(); - } - else - { - System.out.println("PATH: " + file.getCanonicalPath()); - File dir = new File(file.getCanonicalPath().substring(0, file.getCanonicalPath().lastIndexOf("\\"))); - if (!dir.exists()) + if (file.isDirectory()) { - dir.mkdirs(); + file.mkdirs(); } - file.createNewFile(); + else + { + System.out.println("PATH: " + file.getCanonicalPath()); + File dir = new File(file.getCanonicalPath().substring(0, file.getCanonicalPath().lastIndexOf("\\"))); + if (!dir.exists()) + { + dir.mkdirs(); + } + file.createNewFile(); + } } - } - - out = new BufferedOutputStream(new FileOutputStream(file)); - conn = url.openConnection(... [truncated message content] |
From: <le...@us...> - 2008-09-02 11:05:48
|
Revision: 214 http://opencds.svn.sourceforge.net/opencds/?rev=214&view=rev Author: levia Date: 2008-09-02 11:05:57 +0000 (Tue, 02 Sep 2008) Log Message: ----------- - You can now choose where you want to save the language file. Modified Paths: -------------- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java Modified: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java 2008-09-01 22:22:46 UTC (rev 213) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java 2008-09-02 11:05:57 UTC (rev 214) @@ -24,6 +24,7 @@ import java.awt.Dimension; import javax.swing.*; import java.awt.event.*; +import java.io.File; import java.io.FileOutputStream; import java.util.Iterator; import java.util.Locale; @@ -169,6 +170,23 @@ } } fileString += ".properties"; + + JFileChooser chooser = new JFileChooser(new java.io.File(".")); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = chooser.showSaveDialog(m_MainFrame); + + try + { + if (returnVal == JFileChooser.APPROVE_OPTION) + { + prop.store(new FileOutputStream(new File(chooser.getSelectedFile().getCanonicalPath() + "/" + fileString)), null); + JOptionPane.showMessageDialog(m_MainFrame, "The language file has been saved. Drop it in the lang directory of OpenCDS, and it will be available inside OpenCDS. Please submit the language to our team to have it be accepted as a 'official' language.", "Thank you!", JOptionPane.INFORMATION_MESSAGE); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } prop.store(new FileOutputStream(fileString), null); } catch (Exception ex) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-01 22:22:40
|
Revision: 213 http://opencds.svn.sourceforge.net/opencds/?rev=213&view=rev Author: levia Date: 2008-09-01 22:22:46 +0000 (Mon, 01 Sep 2008) Log Message: ----------- - Added TranslatorTool, it's already working well enough to be done. Added Paths: ----------- TranslatorTool/ TranslatorTool/tags/ TranslatorTool/trunk/ TranslatorTool/trunk/src/ TranslatorTool/trunk/src/org/ TranslatorTool/trunk/src/org/opencdspowered/ TranslatorTool/trunk/src/org/opencdspowered/opencds/ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/Initializer.java TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/DynamicLocalisation.java TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/Language.java TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/ParameterList.java TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/messages_en_US.properties TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/util/ Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/Initializer.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/Initializer.java (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/Initializer.java 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,63 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.translatortool; + +import org.opencdspowered.opencds.translatortool.main.*; +import javax.swing.JFrame; +import javax.swing.JDialog; +import javax.swing.UIManager; + +/** + * The class that initializes and starts our application. We do not have to + * set a Look And Feel (LAF) here as thats already done in the core initializer. + * + * @author Lars 'Levia' Wesselius +*/ +public class Initializer +{ + public static void main(String[] args) + { + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + final MainFrame mf = new MainFrame(); + mf.initialize(); + + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + mf.setVisible(true); + } + } + ); + } +} \ No newline at end of file Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/DynamicLocalisation.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/DynamicLocalisation.java (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/DynamicLocalisation.java 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,100 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.translatortool.lang; + +import java.util.*; +import java.io.*; +import javax.swing.JOptionPane; + +/** + * This class is a dynamic language file loader. It loads messages files from + * given subdirectory, then extracts the keys inside and stores them. You are + * also able to get the list of languages currently supported, so that you + * can make a very dynamic language system. + * <p> + * This class provides your users with the ability to make a custom messages + * file, appriopiate for their native language. In combination with the + * download system, you can also provide a service to download language files. + * Again, make sure the syntax of the language files are + * <p> + * <i>messages_[language]_[country].properties</i> + * + * @author Lars 'Levia' Wesselius +*/ +public class DynamicLocalisation +{ + private Language m_Language; + + /** + * The DynamicLocalisation constructor. + */ + public DynamicLocalisation() + { + m_Language = new Language("en", "US", "messages_en_US.properties"); + } + + public Language getLanguage() + { + return m_Language; + } + + public String getLocalisedMessage(String key) + { + return m_Language.getLocalisedMessage(key); + } + + /** + * Get a message with given parameters. + * + * @param key The key. + * @param paramList The parameter list. + * @return The message. + */ + public String getLocalisedMessageParams(String key, ParameterList paramList) + { + String ret = m_Language.getLocalisedMessage(key); + + for (Iterator<Map.Entry<String, String>> it = paramList.entrySet().iterator(); it.hasNext();) + { + Map.Entry<String, String> entry = it.next(); + + if (ret.indexOf("%" + entry.getKey()) != -1) + { + ret = ret.replaceAll("%" + entry.getKey(), entry.getValue()); + } + } + + return ret; + } + + public String getMessageWithParams(String key, ParameterList list) + { + return getLocalisedMessageParams(key, list); + } +} + + + + + + + Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/Language.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/Language.java (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/Language.java 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,210 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.translatortool.lang; + +import java.io.*; +import java.util.*; +import java.io.FileInputStream; + +/** + * The Language class is used to specify one language, in combination with a + * file. + * + * @author Lars 'Levia' Wesselius +*/ +public class Language +{ + private Locale m_Locale; + private File m_File; + private String m_StringFile; + private String m_Code; + private String m_Folder; + private Properties m_Properties; + private String m_Language; + private String m_Country; + + /** + * The Language constructor. + * + * @param language The language of the file. + * @param country The country of the file. + * @param file The file itself. + */ + public Language(String language, String country, File file, String folder) + { + m_Language = language; + m_Country = country; + m_Locale = new Locale(language, country); + m_File = file; + m_Code = language + "_" + country; + m_Folder = folder; + m_Properties = new Properties(); + initKeys(); + } + + /** + * The Language constructor. + * + * @param language The language of the file. + * @param country The country of the file. + * @param file The file itself. + */ + public Language(String language, String country, String file) + { + m_Language = language; + m_Country = country; + m_Locale = new Locale(language, country); + m_File = null; + m_StringFile = file; + m_Code = language + "_" + country; + m_Properties = new Properties(); + m_Folder = null; + initKeys(); + } + + /** + * Initializes the keys found inside the file. + */ + private void initKeys() + { + try + { + if (m_Folder != null) + { + m_Properties.load(new FileInputStream(m_Folder + "/messages_" + getLanguage() + "_" + getCountry() + ".properties")); + } + else + { + java.net.URL url = getClass().getResource(m_StringFile); + m_Properties.load(url.openStream()); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * Get the language of this file. + * + * @return A string with the language. + */ + public String getLanguage() + { + return m_Language; + } + + /** + * Get the country of the file. + * + * @return A string with the country. + */ + public String getCountry() + { + return m_Country; + } + + /** + * Get the country/language combination code. + * + * @return The code. Syntax: <i>en_US</i> + */ + public String getCode() + { + return m_Code; + } + + /** + * Get the languages display name. + * + * @return A string with the display name. + */ + public String getDisplayLanguage() + { + return m_Locale.getDisplayLanguage(); + } + + /** + * Get the locales displayname. + * + * @return A string with the display name. + */ + public String getDisplayName() + { + return m_Locale.getDisplayName(); + } + + /** + * Get the country's display name + * + * @return A string with the country's display name. + */ + public String getDisplayCountry() + { + return m_Locale.getDisplayCountry(); + } + + + /** + * Get localised message. + * + * @param key The key to use. + * @return A string with the localised message. + */ + public String getLocalisedMessage(String key) + { + return m_Properties.getProperty(key); + } + + /** + * Get localised object. + * + * @param key The key to use. + * @return A Object with the localised message. + */ + public Object getLocalisedObject(String key) + { + return m_Properties.getProperty(key); + } + + /** + * Get all the entries. + * + * @return Iterator with all the entries. + */ + public Set<Map.Entry<Object, Object>> getAllEntries() + { + return m_Properties.entrySet(); + } + + /** + * Get the locale. + * + * @return The locale. + */ + public Locale getLocale() + { + return m_Locale; + } +} + Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/ParameterList.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/ParameterList.java (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/ParameterList.java 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,80 @@ +/* + Kiwirc + Copyright (C) 2008 Kiwirc Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.translatortool.lang; + +import java.util.*; + +/** + * This class represents a list of parameters. + * + * @author Lars 'Levia' Wesselius +*/ +public class ParameterList extends HashMap<String, String> +{ + public ParameterList() + { + super(new HashMap<String, String>()); + } + + public void setParameter(String key, String param) + { + put(key, param); + } + + public static ParameterList makeParameterList(String[][] params) + { + ParameterList pList = new ParameterList(); + + for (int i = 0; i != params.length; ++i) + { + pList.setParameter(params[i][0], params[i][1]); + } + return pList; + } + + public static ParameterList makeParameterList(String parameters, String paramDelim, String varDelim) + { + ParameterList pList = new ParameterList(); + + String[] parts = parameters.split(paramDelim); + + for (int i = 0; i != parts.length; ++i) + { + String parameter = parts[i]; + + int index = parameter.indexOf(varDelim); + if (index != -1) + { + String var = parameter.substring(0, index); + String param = parameter.substring(index + 1, parameter.length()); + pList.setParameter(var, param); + } + } + return pList; + } + + public static ParameterList makeParameterList(String parameters) + { + return makeParameterList(parameters, ";", ":"); + } + +} + + Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/messages_en_US.properties =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/messages_en_US.properties (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/lang/messages_en_US.properties 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,152 @@ +Updater.UpdateList.ColumnName = Name +Updater.UpdateList.ColumnSize = Size +Updater.CheckForUpdates = Check for updates +Updater.InstallUpdates = Install updates +Updater.CheckingForUpdates = Checking for updates.. +Updater.WaitingForOpenCDSClose = Waiting for OpenCDS to close.. +Updater.DownloadingUpdates = Downloading updates.. +Updater.Downloading = Downloading +Updater.CompletedAllUpdates = Completed all updates. +Updater.NoUpdatesDownloaded = No updates installed. +Updater.NoUpdates = There are no updates to install. +Updater.NoUpdates.Caption = No updates. +Updater.UpdatesFound = # update(s) found. +Updater.Languages = Languages +Updater.Notifier.UpdatesFound = There are updates available. Would you like to install them now? +Updater.Notifier.Icon.UpdatesFound = There are updates available! +Updater.Notifier.Caption = Updates found! +Updater.CouldNotBeFound.Caption = Updater file not found. +Updater.CouldNotBeFound.Message = The updater could not be found. Please copy the files from the 'updater' directory to the root OpenCDS directory. It is recommended, though, to reinstall OpenCDS. +Updater = Updater +Updater.Back = << Back +Updater.Next = Next >> +Updater.Cancel = Cancel +Updater.Finish = Finish +Updater.Pages.Welcome = This wizard will guide you through the update process.<br> This may take several minutes, depending on your internet connection.<br><br>Please 'Next' to continue. +Updater.Pages.SelectUpdates = Select the updates you wish to install. +Updater.Pages.Completed = Updates are downloaded. Press Finish to install the updates and restart OpenCDS. +Updater.Pages.NoUpdatesDownloaded = Press Finish to close this window. +Cancel = Cancel +FileMenu = File +FileMenu.Close = Exit +FileMenu.Close.Description = Close the program +HelpMenu = Help +HelpMenu.About = About.. +HelpMenu.About.Description = Show the about dialog +HelpMenu.CheckChangelog = Check changelog.. +AboutDialog.Caption = About +AboutDialog.Info = Information +AboutDialog.Authors = Authors +ChangelogDialog.Caption = Updates installed successfully! +ChangelogDialog.Changelog = Changelog +HelpMenu.CheckForUpdates = Check for updates.. +HelpMenu.CheckForUpdates.Description = Check if there is a new version available +HelpMenu.ReportBug = Report a bug.. +HelpMenu.ReportBug.Description = Report a bug +Tray.ToTray = To Tray +ReportBug.Caption = Report bug +ReportBug.EmailAddress = Email address (can be left empty if you do not wish to receive a reply.) +ReportBug.Subject = Subject +ReportBug.Description = Description +ReportBug.Submit = Submit +ReportBug.SentMessage = The report has been sent, and if a email-address was provided you can expect a reply within a few days. Thank you for your report. +ToolsMenu = Tools +ToolsMenu.Configuration = Configuration.. +ToolsMenu.Configuration.Description = The configuration menu where you can adjust settings +ConfigurationDialog.Caption = Configuration +ConfigurationDialog.Save = Apply +ConfigurationDialog.GeneralSection = General +ConfigurationDialog.GeneralSection.Language = Language +ConfigurationDialog.GeneralSection.Language.DesiredLanguage = Desired language (becomes active when OpenCDS is restarted) +ConfigurationDialog.GeneralSection.Language.DownloadMore = Download more languages via the updater. +ConfigurationDialog.GeneralSection.Logging = Logging +ConfigurationDialog.GeneralSection.Logging.Enable = Enable logging +ConfigurationDialog.GeneralSection.Logging.Appearance = Appearance +ConfigurationDialog.GeneralSection.Logging.FileLog = File log +ConfigurationDialog.GeneralSection.Logging.FileEnable = Enable file log +ConfigurationDialog.GeneralSection.Logging.LogEverything = Log everything +ConfigurationDialog.GeneralSection.Logging.LogError = Log errors +ConfigurationDialog.GeneralSection.Logging.LogWarning = Log warnings +ConfigurationDialog.GeneralSection.Logging.ErrorLog = Error log +ConfigurationDialog.GeneralSection.Logging.IgnoreErrors = Ignore errors (exceptions), so that the exclamination mark won't be shown +ConfigurationDialog.GeneralSection.Logging.AutoSubmit = Automatically submit errors (exceptions) to OpenCDS Team +ConfigurationDialog.GeneralSection.View = View +ConfigurationDialog.GeneralSection.View.General = General +ConfigurationDialog.GeneralSection.View.MinimizeToTray = Minimize to tray +ConfigurationDialog.GeneralSection.View.ShowMemoryStatus = Show memory status panel +ConfigurationDialog.GeneralSection.View.EnableTooltips = Enable tooltips +ConfigurationDialog.GeneralSection.Updater = Updater +ConfigurationDialog.ConnectionSection = Connection +ConfigurationDialog.ConnectionSection.HTTP = HTTP +ConfigurationDialog.ConnectionSection.FTP = FTP +ConfigurationDialog.ConnectionSection.FTPHTTP.ProxyGroup = Proxy settings +ConfigurationDialog.ConnectionSection.FTPHTTP.UseProxy = Use a proxy server +ConfigurationDialog.ConnectionSection.FTPHTTP.ProxyServer = Proxy server +ConfigurationDialog.ConnectionSection.FTPHTTP.ProxyPort = Proxy port +ConfigurationDialog.ConnectionSection.Updater = Updater +ConfigurationDialog.GeneralSection.Themes = Themes +ConfigurationDialog.GeneralSection.Themes.SystemNative = Systeem native +ConfigurationDialog.GeneralSection.Themes.Default = Default +Logger = Log +Logger.Description = A log that shows recent events +Logger.SaveLog = Save +Logger.Clear = Clear +Logger.CopyToClipboard = Copy to clipboard +Logger.ErrorList = Error list +Logger.IgnoreClear = Ignore & clear +Logger.Submit = Submit to OpenCDS Team +Logger.Explanation = Selected items are reportable. +Logger.Errors = Error(s) +MyGear = My Gear +MyGear.Description = The My Gear tab where you keep track of your chosen projects +MyGear.Table.Name = Title +MyGear.Table.Genre = Genre +MyGear.Table.Developer = Developer +MyGear.PopupMenu.Run = Run +MyGear.PopupMenu.Info = Info +MyGear.PopupMenu.Update = Update +MyGear.PopupMenu.Remove = Remove +MyGear.PopupMenu.RemoveData = Do you want to remove the project its data aswell? (Removes everything related to this project from your computer) +MyGear.PopupMenu.RemoveDataCaption = Remove data +Browser = Browser +Browser.Description = Browse projects from the added XML's here +Tray.Restore = Restore +General.Ok = OK +Splash.StartingServics = Starting services.. +Splash.CreatingMenubar = Creating menubar.. +Splash.MenubarCreated = Menubar created. +Splash.StartingLogger = Starting logger.. +Splash.InitializingSettings = Initializing settings.. +Splash.CreatingWindow = Creating window.. +Splash.CreatingComponents = Creating components.. +Splash.ComponentsInitialized = Components initialized. +Splash.StartingPluginManager = Starting plugin manager.. +Splash.LoadingPlugins = Loading plugins.. +Splash.PluginsLoaded = Plugins loaded. +Splash.Done = Done +ProjectInfo = Project info for %project +ProjectInfo.Information = Information +ProjectInfo.Release = Release +ProjectInfo.Project = Project +ProjectInfo.URL = URL +ProjectInfo.Description = Description +ProjectInfo.Developer = Developer +ProjectInfo.Genre = Genre +ProjectInfo.Titles = Titles +ProjectInfo.Title = Title +ProjectInfo.Type = Type +ProjectInfo.Type.Executable = Executable +ProjectInfo.Type.Library = Library +ProjectInfo.Type.Source = Source +ProjectInfo.Target = Target audience +ProjectInfo.Status = Status +ProjectInfo.Download.Done = Done +ProjectInfo.Download.Failed = Failed +ProjectInfo.Download.Idle = Idle +ProjectInfo.Download.Queued = Queued +ProjectInfo.Download.NotDownloaded = Not downloaded yet +ProjectInfo.Name = Name +ProjectInfo.Target = Target +ProjectInfo.Stability = Stability +ProjectInfo.Version = Version +ProjectInfo.FileUrl = File url \ No newline at end of file Added: TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java =================================================================== --- TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java (rev 0) +++ TranslatorTool/trunk/src/org/opencdspowered/opencds/translatortool/main/MainFrame.java 2008-09-01 22:22:46 UTC (rev 213) @@ -0,0 +1,188 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.translatortool.main; + +import java.awt.Dimension; +import javax.swing.*; +import java.awt.event.*; +import java.io.FileOutputStream; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import javax.swing.table.DefaultTableModel; +import org.opencdspowered.opencds.translatortool.lang.DynamicLocalisation; + +/** + * The class that initializes our frame. + * + * @author Lars 'Levia' Wesselius +*/ +public class MainFrame implements ActionListener +{ + private JFrame m_MainFrame; + + private JComboBox m_LanguageChooser; + private JButton m_Write; + private JTable m_LanguageTable; + + private DynamicLocalisation m_Localisation; + + + public MainFrame() + { + m_MainFrame = new JFrame("OpenCDS Translator tool"); + } + + /** + * Creates our frame, then initializes all components. + */ + public void initialize() + { + m_Localisation = new DynamicLocalisation(); + m_MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + m_MainFrame.setLocation(200, 200); + m_MainFrame.setSize(700, 500); + + JPanel contentPane = new JPanel(); + contentPane.setOpaque(true); + BoxLayout bl = new BoxLayout(contentPane, BoxLayout.PAGE_AXIS); + contentPane.setLayout(bl); + contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 5, 3)); + + + JLabel langLabel = new JLabel("Choose language you are translating to"); + langLabel.setAlignmentX(JComponent.LEFT_ALIGNMENT); + m_LanguageChooser = new JComboBox(); + m_LanguageChooser.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + Locale[] locales = Locale.getAvailableLocales(); + for (int i = 0; i != locales.length; ++i) + { + Locale locale = locales[i]; + m_LanguageChooser.addItem(locale.getDisplayName()); + } + + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("English"); + model.addColumn("Your language"); + + + Set<Map.Entry<Object, Object>> entrySet = m_Localisation.getLanguage().getAllEntries(); + for (Iterator<Map.Entry<Object, Object>> it = entrySet.iterator(); it.hasNext();) + { + Map.Entry<Object, Object> obj = it.next(); + + Object[] row = { + (String)obj.getValue(), + "" + }; + model.addRow(row); + } + + m_LanguageTable = new JTable(model); + m_LanguageTable.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + JScrollPane langPane = new JScrollPane(m_LanguageTable); + langPane.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_Write = new JButton("Done!"); + m_Write.setActionCommand("Done"); + m_Write.addActionListener(this); + m_Write.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + contentPane.add(langLabel); + contentPane.add(m_LanguageChooser); + contentPane.add(Box.createRigidArea(new Dimension(0, 5))); + contentPane.add(langPane); + contentPane.add(Box.createRigidArea(new Dimension(0, 5))); + contentPane.add(m_Write); + m_MainFrame.setContentPane(contentPane); + + + } + + public void actionPerformed(ActionEvent event) + { + String e = event.getActionCommand(); + + if (e.equals("Done")) + { + Properties prop = new Properties(); + + DefaultTableModel model = (DefaultTableModel)m_LanguageTable.getModel(); + + Set<Map.Entry<Object, Object>> entrySet = m_Localisation.getLanguage().getAllEntries(); + + int rowCount = model.getRowCount(); + for (int i = 0; i != rowCount; ++i) + { + String englishLang = (String)model.getValueAt(i, 0); + String otherLang = (String)model.getValueAt(i, 1); + + for (Iterator<Map.Entry<Object, Object>> it = entrySet.iterator(); it.hasNext();) + { + Map.Entry<Object, Object> obj = it.next(); + + String key = (String)obj.getKey(); + String value = (String)obj.getValue(); + + if (englishLang.equals(value)) + { + prop.setProperty(key, otherLang); + } + } + } + + try + { + String fileString = "messages_"; + + Locale[] locales = Locale.getAvailableLocales(); + for (int i = 0; i != locales.length; ++i) + { + Locale loc = locales[i]; + if (loc.getDisplayName().equals((String)m_LanguageChooser.getSelectedItem())) + { + fileString += loc.getLanguage() + "_" + loc.getCountry(); + break; + } + } + fileString += ".properties"; + prop.store(new FileOutputStream(fileString), null); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + } + + public void setVisible(boolean visible) + { + m_MainFrame.setVisible(visible); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-01 19:53:04
|
Revision: 212 http://opencds.svn.sourceforge.net/opencds/?rev=212&view=rev Author: levia Date: 2008-09-01 19:53:12 +0000 (Mon, 01 Sep 2008) Log Message: ----------- - Don't look in ProjectDownloader.java. - Downloading works. Again, don't look in ProjectDownloader.java :) Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-01 19:53:12 UTC (rev 212) @@ -44,19 +44,20 @@ * Reads an index file from URL. * * @param url The url of the index file. + * @return True if successful, false if not. */ - public void readXML(URL url) + public boolean readXML(URL url) { try { m_IndexTable.clear(); Builder builder = new Builder(); - Document doc = builder.build(url.getPath()); + Document doc = builder.build(url.toString()); if (!doc.getRootElement().getAttributeValue("version").equals(Constants.OPENCDS_VERSION)) { Logger.getInstance().logException(new InvalidActionException("The index file is of incompatible version (" + doc.getRootElement().getAttributeValue("version") + ")"), false); - return; + return false; } Elements rootChildren = doc.getRootElement().getChildElements(); @@ -73,10 +74,12 @@ parseFile("", elem); } } + return true; } catch (Exception e) { Logger.getInstance().logException(e, false); + return false; } } @@ -84,8 +87,9 @@ * Reads an index file from URL. * * @param file The file to read. + * @return True if successful, false if not. */ - public void readXML(File file) + public boolean readXML(File file) { try { @@ -96,7 +100,7 @@ if (!doc.getRootElement().getAttributeValue("version").equals(Constants.OPENCDS_VERSION)) { Logger.getInstance().logException(new InvalidActionException("The index file is of incompatible version (" + doc.getRootElement().getAttributeValue("version") + ")"), false); - return; + return false; } Elements rootChildren = doc.getRootElement().getChildElements(); @@ -113,10 +117,12 @@ parseFile("", elem); } } + return true; } catch (Exception e) { Logger.getInstance().logException(e, false); + return false; } } @@ -142,7 +148,11 @@ private void parseFile(String parentName, Element elem) { - Index ind = new Index(elem.getAttributeValue("file"), elem.getAttributeValue("hash")); + if (!parentName.endsWith("/")) + { + parentName += "/"; + } + Index ind = new Index(parentName + elem.getAttributeValue("file"), elem.getAttributeValue("hash")); m_IndexTable.add(ind); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java 2008-09-01 19:53:12 UTC (rev 212) @@ -226,7 +226,17 @@ } exe.setOpen(childElement.getAttribute("value")); + childNodes = element.getElementsByTagName("install"); + childElement = (Element)childNodes.item(0); + if (childElement == null) + { + logger.log(Logger.LOG_WARNING, "A executable didn't have a install element. Discarding."); + return null; + } + exe.setInstallTo(childElement.getAttribute("path")); + + childNodes = element.getElementsByTagName("cmdline"); childElement = (Element)childNodes.item(0); @@ -279,6 +289,19 @@ } lib.setFileUrl(childElement.getAttribute("url")); + childNodes = element.getElementsByTagName("install"); + childElement = (Element)childNodes.item(0); + + if (childElement == null) + { + logger.log(Logger.LOG_WARNING, "A executable didn't have a install element. Discarding."); + return null; + } + lib.setInstallTo(childElement.getAttribute("path")); + + + + return lib; } catch (Exception e) @@ -321,6 +344,17 @@ } src.setFileUrl(childElement.getAttribute("url")); + childNodes = element.getElementsByTagName("install"); + childElement = (Element)childNodes.item(0); + + if (childElement == null) + { + logger.log(Logger.LOG_WARNING, "A executable didn't have a install element. Discarding."); + return null; + } + src.setInstallTo(childElement.getAttribute("path")); + + return src; } catch (Exception e) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-01 19:53:12 UTC (rev 212) @@ -23,6 +23,10 @@ import org.opencdspowered.opencds.core.download.*; import org.opencdspowered.opencds.core.index.*; +import org.opencdspowered.opencds.core.logging.*; +import java.net.URL; +import java.io.File; +import java.util.Iterator; /** * This class makes downloading a project alot easier. @@ -45,7 +49,144 @@ */ public void downloadProject(Project project) { + Executable exe = project.getLatestExecutable(); + IndexReader reader = new IndexReader(); + String fileUrl = exe.getFileUrl(); + try + { + // Check if it's an xml file. + if (fileUrl.endsWith(".xml")) + { + // Check if the indexer successfully read it. + if (!reader.readXML(new URL(exe.getFileUrl()))) + { + // No it did not, it's a single file XML! Oh my! + int index = exe.getName().lastIndexOf("."); + String fileName = exe.getName().substring(0, index); + + Download download = null; + if (exe.getInstallTo().equals("$ProjectRoot")) + { + String downloadToDir = "data/" + project.getName() + "/" + fileName + "/"; + File file = new File(downloadToDir); + if (!file.exists()) + { + file.mkdirs(); + } + File fileTo = new File(downloadToDir + exe.getName()); + if (!fileTo.exists()) + { + try + { + fileTo.createNewFile(); + } + catch (Exception ex) + { + Logger.getInstance().logException(ex); + } + } + download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); + } + else + { + File dir = new File(exe.getInstallTo()); + if (!dir.exists()) + { + dir.mkdirs(); + } + download = m_DownloadManager.addDownload(exe.getFileUrl(), exe.getInstallTo()); + } + m_DownloadManager.enqueueDownload(download); + } + else + { + // It was read successfully. + String installTo = ""; + if (exe.getInstallTo().equals("$ProjectRoot")) + { + int index = exe.getName().lastIndexOf("."); + String fileName = exe.getName().substring(0, index); + String downloadToDir = "data/" + project.getName() + "/" + fileName; + File file = new File(downloadToDir); + if (!file.exists()) + { + file.mkdirs(); + } + File fileTo = new File(downloadToDir + exe.getName()); + if (!fileTo.exists()) + { + try + { + fileTo.createNewFile(); + } + catch (Exception ex) + { + Logger.getInstance().logException(ex); + } + } + installTo = downloadToDir; + } + else + { + File dir = new File(exe.getInstallTo()); + if (!dir.exists()) + { + dir.mkdirs(); + } + installTo = exe.getInstallTo(); + } + + int slashIndex = exe.getFileUrl().lastIndexOf("/"); + String baseUrl = exe.getFileUrl().substring(0, slashIndex); + + for (Iterator<Index> it = reader.getIndexes(); it.hasNext();) + { + Index index = it.next(); + + Download dl = m_DownloadManager.addDownload(baseUrl + index.getURL(), installTo + index.getURL()); + System.out.println("baseURL: " + baseUrl); + System.out.println("IndexURL: " + index.getURL()); + System.out.println("InstallTo: " + installTo); + m_DownloadManager.enqueueDownload(dl); + } + } + } + else + { + int index = exe.getName().lastIndexOf("."); + String fileName = exe.getName().substring(0, index); + String downloadToDir = "data/" + project.getName() + "/" + fileName + "/"; + File file = new File(downloadToDir); + if (!file.exists()) + { + file.mkdirs(); + } + File fileTo = new File(downloadToDir + exe.getName()); + if (!fileTo.exists()) + { + try + { + fileTo.createNewFile(); + } + catch (Exception ex) + { + Logger.getInstance().logException(ex); + } + } + + Download download = m_DownloadManager.addDownload(exe.getFileUrl(), downloadToDir + exe.getName()); + m_DownloadManager.enqueueDownload(download); + } + m_DownloadManager.startQueue(); + } + catch (Exception e) + { + Logger.getInstance().logException(e, false); + return; + } + + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java 2008-09-01 19:53:12 UTC (rev 212) @@ -36,6 +36,7 @@ protected String m_FileUrl; protected String m_Target; protected String m_Name; + protected String m_InstallTo; public Release() { @@ -111,6 +112,16 @@ return m_Name; } + public void setInstallTo(String installTo) + { + m_InstallTo = installTo; + } + + public String getInstallTo() + { + return m_InstallTo; + } + public String toString() { return m_Name; Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-09-01 19:53:12 UTC (rev 212) @@ -119,35 +119,7 @@ gearManager.addProject(project); log.log("Added '" + project.getName() + "' to the My Gear list."); - DownloadManager downloadManager = m_MainFrame.getDownloadManager(); - - Executable latestExe = project.getLatestExecutable(); - - int index = latestExe.getName().lastIndexOf("."); - String fileName = latestExe.getName().substring(0, index); - - - String downloadToDir = "data/" + project.getName() + "/" + fileName + "/"; - File file = new File(downloadToDir); - if (!file.exists()) - { - file.mkdirs(); - } - File fileTo = new File(downloadToDir + latestExe.getName()); - if (!fileTo.exists()) - { - try - { - fileTo.createNewFile(); - } - catch (Exception ex) - { - log.logException(ex); - } - } - Download download = downloadManager.addDownload(latestExe.getFileUrl(), downloadToDir + latestExe.getName()); - downloadManager.enqueueDownload(download); - downloadManager.startQueue(); + m_MainFrame.getProjectDownloader().downloadProject(project); } } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-01 17:06:42 UTC (rev 211) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-01 19:53:12 UTC (rev 212) @@ -244,9 +244,6 @@ } }); t.start(); - - IndexReader ind = new IndexReader(); - ind.readXML(new File("./opencds.xml")); } /** Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-01 17:06:42 UTC (rev 211) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-09-01 19:53:12 UTC (rev 212) @@ -52,7 +52,8 @@ File file = new File(dl.getToFile()); - + + System.out.println("Tofile:" + dl.getToFile()); if (!file.exists()) { if (file.isDirectory()) @@ -61,6 +62,12 @@ } else { + System.out.println("PATH: " + file.getCanonicalPath()); + File dir = new File(file.getCanonicalPath().substring(0, file.getCanonicalPath().lastIndexOf("\\"))); + if (!dir.exists()) + { + dir.mkdirs(); + } file.createNewFile(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-01 17:06:34
|
Revision: 211 http://opencds.svn.sourceforge.net/opencds/?rev=211&view=rev Author: levia Date: 2008-09-01 17:06:42 +0000 (Mon, 01 Sep 2008) Log Message: ----------- - Fixed javadoc errors. - Added ProjectDownloader, to make it easier to download projects. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/config/ConfigurationManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/logging/ExceptionListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/wizard/WizardPage.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/config/ConfigurationManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/config/ConfigurationManager.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/config/ConfigurationManager.java 2008-09-01 17:06:42 UTC (rev 211) @@ -103,8 +103,8 @@ * Cancel the made changes - old settings are restored. Only availbe when * she session is started. * - * @param stopSesstion True if the session must be stopped aswell. - * @see startSession() + * @param stopSession True if the session must be stopped aswell. + * @see #startSession() */ public void cancel(boolean stopSession) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-09-01 17:06:42 UTC (rev 211) @@ -199,7 +199,7 @@ /** * Cancel a download. * - * @param download The download that needs to be cancelled. + * @param dl The download that needs to be cancelled. */ public void cancelDownload(Download dl) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java 2008-09-01 17:06:42 UTC (rev 211) @@ -31,9 +31,9 @@ /** * Is fired when the Download state has changed. * + * @param dl The download associated. * @param oldState The old state of the download. * @param newState The new state of the download. - * @param download The download associated. */ public void stateChanged(Download dl, int oldState, int newState); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-09-01 17:06:42 UTC (rev 211) @@ -247,7 +247,7 @@ /** * Cancel a download, if it's currently running. * - * @param download The download to cancel. + * @param dl The download to cancel. */ public void cancelDownload(Download dl) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-01 17:06:42 UTC (rev 211) @@ -27,6 +27,7 @@ import java.net.URL; import java.io.File; import java.util.Iterator; +import java.util.ArrayList; import org.opencdspowered.opencds.core.exceptions.InvalidActionException; import org.opencdspowered.opencds.core.util.Constants; @@ -42,7 +43,7 @@ /** * Reads an index file from URL. * - * @param URL The url of the index file. + * @param url The url of the index file. */ public void readXML(URL url) { @@ -82,7 +83,7 @@ /** * Reads an index file from URL. * - * @param URL The url of the index file. + * @param file The file to read. */ public void readXML(File file) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/logging/ExceptionListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/logging/ExceptionListener.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/logging/ExceptionListener.java 2008-09-01 17:06:42 UTC (rev 211) @@ -37,5 +37,5 @@ * @param reportable Whether this exception can be reported. * @param timeStamp The timestamp of the event. */ - public void logException(Exception e, boolean reportable, Date timeStamp); + public void logException(Exception exception, boolean reportable, Date timeStamp); } \ No newline at end of file Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginCommunication.java 2008-09-01 17:06:42 UTC (rev 211) @@ -91,6 +91,11 @@ return m_MainFrame.getGearManager(); } + public ProjectDownloader getProjectDownloader() + { + return m_MainFrame.getProjectDownloader(); + } + public int addTab(String title, ImageIcon icon, JComponent panel) { return m_MainFrame.addTab(title, icon, panel); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/plugin/PluginInterface.java 2008-09-01 17:06:42 UTC (rev 211) @@ -21,11 +21,8 @@ */ package org.opencdspowered.opencds.core.plugin; -import org.opencdspowered.opencds.core.exceptions.*; -import org.opencdspowered.opencds.core.logging.*; import org.opencdspowered.opencds.core.lang.*; import org.opencdspowered.opencds.core.download.*; -import org.opencdspowered.opencds.core.plugin.*; import org.opencdspowered.opencds.core.project.*; import javax.swing.*; @@ -81,6 +78,13 @@ public GearManager getGearManager(); /** + * Get the project downloader + * + * @return The project downloader. + */ + public ProjectDownloader getProjectDownloader(); + + /** * Add a tab to the main view. * * @param title The title of the tab. Added: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectDownloader.java 2008-09-01 17:06:42 UTC (rev 211) @@ -0,0 +1,52 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.core.project; + +import org.opencdspowered.opencds.core.download.*; +import org.opencdspowered.opencds.core.index.*; + +/** + * This class makes downloading a project alot easier. + * + * @author Lars 'Levia' Wesselius +*/ +public class ProjectDownloader +{ + private DownloadManager m_DownloadManager; + + public ProjectDownloader(DownloadManager mgr) + { + m_DownloadManager = mgr; + } + + /** + * Download a project. + * + * @param project The project to download. + */ + public void downloadProject(Project project) + { + + } +} + + Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-01 17:06:42 UTC (rev 211) @@ -56,6 +56,7 @@ private BrowserManager m_BrowserManager; private GearManager m_GearManager; private LogManager m_LogManager; + private ProjectDownloader m_ProjectDownloader; private Tray m_Tray; private SplashWindow m_Splash; @@ -95,6 +96,8 @@ GearBrowser gearBrowser = new GearBrowser(this); Browser browser = new Browser(this); + m_ProjectDownloader = new ProjectDownloader(m_Core.getDownloadManager()); + incrementSplashProgress(loc.getMessage("Splash.StartingLogger"), 10); if (cfgMgr.getBoolValue("Logger.ShowTab")) { @@ -342,7 +345,7 @@ /** * Called when the windows state has been changed. * - * @param windowEvent The event associated. + * @param event The event associated. */ public void windowStateChanged(WindowEvent event) { @@ -493,6 +496,16 @@ } /** + * Get the project downloader. + * + * @return The project downloader. + */ + public ProjectDownloader getProjectDownloader() + { + return m_ProjectDownloader; + } + + /** * Get the tray manager. * * @return Reference to the tray manager. Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/wizard/WizardPage.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/wizard/WizardPage.java 2008-09-01 16:26:04 UTC (rev 210) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/wizard/WizardPage.java 2008-09-01 17:06:42 UTC (rev 211) @@ -38,9 +38,9 @@ /** * A WizardPage constructor. * - * @param panel The panel with the widgets. - * @param hasFinish Whether this page should have the finish button enabled. - * @param hasCancel Whether this page should have the cancel button enabled. + * @param panel The panel with the widgets. + * @param hasFinishEnabled Whether this page should have the finish button enabled. + * @param hasCancelEnabled Whether this page should have the cancel button enabled. */ public WizardPage(JPanel panel, boolean hasFinishEnabled, boolean hasCancelEnabled) { @@ -62,8 +62,8 @@ /** * A WizardPage constructor. * - * @param hasFinish Whether this page should have the finish button enabled. - * @param hasCancel Whether this page should have the cancel button enabled. + * @param hasFinishEnabled Whether this page should have the finish button enabled. + * @param hasCancelEnabled Whether this page should have the cancel button enabled. */ public WizardPage(boolean hasFinishEnabled, boolean hasCancelEnabled) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-01 16:25:55
|
Revision: 210 http://opencds.svn.sourceforge.net/opencds/?rev=210&view=rev Author: levia Date: 2008-09-01 16:26:04 +0000 (Mon, 01 Sep 2008) Log Message: ----------- - Added versioning information to the index writer tool. - Added IndexReader to OpenCDS. Modified Paths: -------------- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java Modified: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java 2008-08-31 19:18:57 UTC (rev 209) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java 2008-09-01 16:26:04 UTC (rev 210) @@ -28,7 +28,7 @@ */ public class Constants { - public static final String INDEXWRITER_VERSION = "0.1"; + public static final String OPENCDS_VERSION = "0.2.203"; } Modified: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java 2008-08-31 19:18:57 UTC (rev 209) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java 2008-09-01 16:26:04 UTC (rev 210) @@ -32,6 +32,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.opencdspowered.opencds.indexwriter.util.Constants; /** * The class that writes our XML. @@ -78,13 +79,11 @@ DocumentBuilder builder = factory.newDocumentBuilder(); m_Document = builder.getDOMImplementation().createDocument(null, null, null); - m_MainFrame.log("1"); Element root = m_Document.createElement("indexes"); + root.setAttribute("version", Constants.OPENCDS_VERSION); m_Document.appendChild(root); - m_MainFrame.log("2"); doDirectory(root, m_RootFolder); - m_MainFrame.log("10"); DOMSource domSource = new DOMSource(m_Document); TransformerFactory tf = TransformerFactory.newInstance(); @@ -134,9 +133,7 @@ Element fileElem = m_Document.createElement("file"); fileElem.setAttribute("file", file.getName()); fileElem.setAttribute("hash", getMD5FromFile(file)); - m_MainFrame.log("3"); elem.appendChild(fileElem); - m_MainFrame.log("4"); } public String getMD5FromFile(File file) Added: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/Index.java 2008-09-01 16:26:04 UTC (rev 210) @@ -0,0 +1,74 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.core.index; + +import org.opencdspowered.opencds.core.logging.Logger; +import javolution.util.FastTable; +import nu.xom.*; +import java.net.URL; +import java.io.File; + +/** + * Represents an index. + * + * @author Lars 'Levia' Wesselius +*/ +public class Index +{ + private String m_URL; + private String m_MD5Hash; + + + /** + * Index constructor. + * + * @param URL The url of the index. + * @param hash The hash of the associated file. + */ + public Index(String URL, String hash) + { + m_URL = URL; + m_MD5Hash = hash; + } + + /** + * Get the URL of the associated file. + * + * @return A string with the url. + */ + public String getURL() + { + return m_URL; + } + + /** + * Get the hash of the associated file. + * + * @return The hash. + */ + public String getHash() + { + return m_MD5Hash; + } + +} + Added: OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/index/IndexReader.java 2008-09-01 16:26:04 UTC (rev 210) @@ -0,0 +1,158 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.core.index; + +import org.opencdspowered.opencds.core.logging.Logger; +import javolution.util.FastTable; +import nu.xom.*; +import java.net.URL; +import java.io.File; +import java.util.Iterator; +import org.opencdspowered.opencds.core.exceptions.InvalidActionException; +import org.opencdspowered.opencds.core.util.Constants; + +/** + * Reads the index file. + * + * @author Lars 'Levia' Wesselius +*/ +public class IndexReader +{ + FastTable<Index> m_IndexTable = new FastTable<Index>(); + + /** + * Reads an index file from URL. + * + * @param URL The url of the index file. + */ + public void readXML(URL url) + { + try + { + m_IndexTable.clear(); + Builder builder = new Builder(); + Document doc = builder.build(url.getPath()); + + if (!doc.getRootElement().getAttributeValue("version").equals(Constants.OPENCDS_VERSION)) + { + Logger.getInstance().logException(new InvalidActionException("The index file is of incompatible version (" + doc.getRootElement().getAttributeValue("version") + ")"), false); + return; + } + Elements rootChildren = doc.getRootElement().getChildElements(); + + for (int i = 0; i != rootChildren.size(); ++i) + { + Element elem = rootChildren.get(i); + + if (elem.getLocalName().equals("folder")) + { + parseDirectory("", elem); + } + else + { + parseFile("", elem); + } + } + } + catch (Exception e) + { + Logger.getInstance().logException(e, false); + } + } + + /** + * Reads an index file from URL. + * + * @param URL The url of the index file. + */ + public void readXML(File file) + { + try + { + m_IndexTable.clear(); + Builder builder = new Builder(); + Document doc = builder.build(file); + + if (!doc.getRootElement().getAttributeValue("version").equals(Constants.OPENCDS_VERSION)) + { + Logger.getInstance().logException(new InvalidActionException("The index file is of incompatible version (" + doc.getRootElement().getAttributeValue("version") + ")"), false); + return; + } + Elements rootChildren = doc.getRootElement().getChildElements(); + + for (int i = 0; i != rootChildren.size(); ++i) + { + Element elem = rootChildren.get(i); + + if (elem.getLocalName().equals("folder")) + { + parseDirectory("", elem); + } + else + { + parseFile("", elem); + } + } + } + catch (Exception e) + { + Logger.getInstance().logException(e, false); + } + } + + private void parseDirectory(String folderName, Element elem) + { + Elements elems = elem.getChildElements(); + + for (int i = 0; i != elems.size(); ++i) + { + Element childElement = elems.get(i); + + if (childElement.getLocalName().equals("folder")) + { + parseDirectory(folderName + "/" + elem.getAttributeValue("name"), childElement); + } + else + { + parseFile(folderName + "/" + elem.getAttributeValue("name"), childElement); + } + + } + } + + private void parseFile(String parentName, Element elem) + { + Index ind = new Index(elem.getAttributeValue("file"), elem.getAttributeValue("hash")); + m_IndexTable.add(ind); + } + + /** + * Get all the indexes parsed from the XML file. + * + * @return An iterator with the indexes. + */ + public Iterator<Index> getIndexes() + { + return m_IndexTable.iterator(); + } +} + Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-08-31 19:18:57 UTC (rev 209) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-09-01 16:26:04 UTC (rev 210) @@ -22,6 +22,7 @@ package org.opencdspowered.opencds.ui.main; import org.opencdspowered.opencds.core.init.CoreInitializer; +import org.opencdspowered.opencds.core.index.*; import org.opencdspowered.opencds.core.config.ConfigurationManager; import org.opencdspowered.opencds.core.lang.DynamicLocalisation; import org.opencdspowered.opencds.core.update.*; @@ -37,6 +38,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.io.File; import java.util.Enumeration; /** @@ -239,6 +241,9 @@ } }); t.start(); + + IndexReader ind = new IndexReader(); + ind.readXML(new File("./opencds.xml")); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-31 19:18:56
|
Revision: 209 http://opencds.svn.sourceforge.net/opencds/?rev=209&view=rev Author: levia Date: 2008-08-31 19:18:57 +0000 (Sun, 31 Aug 2008) Log Message: ----------- - Added IndexWriter, a tool to write the index that is required by OpenCDS. Added Paths: ----------- IndexWriter/ IndexWriter/tags/ IndexWriter/trunk/ IndexWriter/trunk/ant/ IndexWriter/trunk/ant/build-impl.xml IndexWriter/trunk/ant/build.xml IndexWriter/trunk/src/ IndexWriter/trunk/src/org/ IndexWriter/trunk/src/org/opencdspowered/ IndexWriter/trunk/src/org/opencdspowered/opencds/ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/Initializer.java IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/main/ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/main/MainFrame.java IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java Added: IndexWriter/trunk/ant/build-impl.xml =================================================================== --- IndexWriter/trunk/ant/build-impl.xml (rev 0) +++ IndexWriter/trunk/ant/build-impl.xml 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,618 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +*** GENERATED FROM project.xml - DO NOT EDIT *** +*** EDIT ../build.xml INSTEAD *** + +For the purpose of easier reading the script +is divided into following sections: + + - initialization + - compilation + - jar + - execution + - debugging + - javadoc + - junit compilation + - junit execution + - junit debugging + - applet + - cleanup + + --> +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="IndexWriter-impl"> + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/> + <!-- + ====================== + INITIALIZATION SECTION + ====================== + --> + <target name="-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init" name="-init-private"> + <property file="nbproject/private/config.properties"/> + <property file="nbproject/private/configs/${config}.properties"/> + <property file="nbproject/private/private.properties"/> + </target> + <target depends="-pre-init,-init-private" name="-init-user"> + <property file="${user.properties.file}"/> + <!-- The two properties below are usually overridden --> + <!-- by the active platform. Just a fallback. --> + <property name="default.javac.source" value="1.4"/> + <property name="default.javac.target" value="1.4"/> + </target> + <target depends="-pre-init,-init-private,-init-user" name="-init-project"> + <property file="nbproject/configs/${config}.properties"/> + <property file="nbproject/project.properties"/> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init"> + <available file="${manifest.file}" property="manifest.available"/> + <condition property="manifest.available+main.class"> + <and> + <isset property="manifest.available"/> + <isset property="main.class"/> + <not> + <equals arg1="${main.class}" arg2="" trim="true"/> + </not> + </and> + </condition> + <condition property="manifest.available+main.class+mkdist.available"> + <and> + <istrue value="${manifest.available+main.class}"/> + <isset property="libs.CopyLibs.classpath"/> + </and> + </condition> + <condition property="have.tests"> + <or/> + </condition> + <condition property="have.sources"> + <or> + <available file="${src.dir}"/> + </or> + </condition> + <condition property="netbeans.home+have.tests"> + <and> + <isset property="netbeans.home"/> + <isset property="have.tests"/> + </and> + </condition> + <condition property="no.javadoc.preview"> + <and> + <isset property="javadoc.preview"/> + <isfalse value="${javadoc.preview}"/> + </and> + </condition> + <property name="run.jvmargs" value=""/> + <property name="javac.compilerargs" value=""/> + <property name="work.dir" value="${basedir}"/> + <condition property="no.deps"> + <and> + <istrue value="${no.dependencies}"/> + </and> + </condition> + <property name="javac.debug" value="true"/> + <property name="javadoc.preview" value="true"/> + <property name="application.args" value=""/> + <property name="source.encoding" value="${file.encoding}"/> + <condition property="javadoc.encoding.used" value="${javadoc.encoding}"> + <and> + <isset property="javadoc.encoding"/> + <not> + <equals arg1="${javadoc.encoding}" arg2=""/> + </not> + </and> + </condition> + <property name="javadoc.encoding.used" value="${source.encoding}"/> + <property name="includes" value="**"/> + <property name="excludes" value=""/> + <property name="do.depend" value="false"/> + <condition property="do.depend.true"> + <istrue value="${do.depend}"/> + </condition> + <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'"> + <and> + <isset property="jaxws.endorsed.dir"/> + <available file="nbproject/jaxws-build.xml"/> + </and> + </condition> + </target> + <target name="-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check"> + <fail unless="src.dir">Must set src.dir</fail> + <fail unless="build.dir">Must set build.dir</fail> + <fail unless="dist.dir">Must set dist.dir</fail> + <fail unless="build.classes.dir">Must set build.classes.dir</fail> + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail> + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> + <fail unless="dist.jar">Must set dist.jar</fail> + </target> + <target name="-init-macrodef-property"> + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${@{value}}"/> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-javac"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> + <attribute default="" name="sourcepath"/> + <element name="customize" optional="true"/> + <sequential> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/> + <customize/> + </javac> + </sequential> + </macrodef> + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <sequential> + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </depend> + </sequential> + </macrodef> + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${build.classes.dir}" name="destdir"/> + <sequential> + <fail unless="javac.includes">Must set javac.includes</fail> + <pathconvert pathsep="," property="javac.includes.binary"> + <path> + <filelist dir="@{destdir}" files="${javac.includes}"/> + </path> + <globmapper from="*.java" to="*.class"/> + </pathconvert> + <delete> + <files includes="${javac.includes.binary}"/> + </delete> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-junit"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <sequential> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true"> + <batchtest todir="${build.test.results.dir}"/> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg line="${run.jvmargs}"/> + </junit> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-nbjpda"> + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="name"/> + <attribute default="${debug.classpath}" name="classpath"/> + <attribute default="" name="stopclassname"/> + <sequential> + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </nbjpdastart> + </sequential> + </macrodef> + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${build.classes.dir}" name="dir"/> + <sequential> + <nbjpdareload> + <fileset dir="@{dir}" includes="${fix.classes}"> + <include name="${fix.includes}*.class"/> + </fileset> + </nbjpdareload> + </sequential> + </macrodef> + </target> + <target name="-init-debug-args"> + <property name="version-output" value="java version "${ant.java.version}"/> + <condition property="have-jdk-older-than-1.4"> + <or> + <contains string="${version-output}" substring="java version "1.0"/> + <contains string="${version-output}" substring="java version "1.1"/> + <contains string="${version-output}" substring="java version "1.2"/> + <contains string="${version-output}" substring="java version "1.3"/> + </or> + </condition> + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none"> + <istrue value="${have-jdk-older-than-1.4}"/> + </condition> + </target> + <target depends="-init-debug-args" name="-init-macrodef-debug"> + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${main.class}" name="classname"/> + <attribute default="${debug.classpath}" name="classpath"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" fork="true"> + <jvmarg line="${debug-args-line}"/> + <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-java"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="classname"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" fork="true"> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="${run.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-presetdef-jar"> + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> + <jar compress="${jar.compress}" jarfile="${dist.jar}"> + <j2seproject1:fileset dir="${build.classes.dir}"/> + </jar> + </presetdef> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/> + <!-- + =================== + COMPILATION SECTION + =================== + --> + <target depends="init" name="deps-jar" unless="no.deps"/> + <target depends="init,deps-jar" name="-pre-pre-compile"> + <mkdir dir="${build.classes.dir}"/> + </target> + <target name="-pre-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-depend"> + <j2seproject3:depend/> + </target> + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile"> + <j2seproject3:javac/> + <copy todir="${build.classes.dir}"> + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target name="-post-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/> + <target name="-pre-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile/> + <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/> + </target> + <target name="-post-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/> + <!-- + ==================== + JAR BUILDING SECTION + ==================== + --> + <target depends="init" name="-pre-pre-jar"> + <dirname file="${dist.jar}" property="dist.jar.dir"/> + <mkdir dir="${dist.jar.dir}"/> + </target> + <target name="-pre-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available"> + <j2seproject1:jar/> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class"> + <j2seproject1:jar manifest="${manifest.file}"/> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available"> + <j2seproject1:jar manifest="${manifest.file}"> + <j2seproject1:manifest> + <j2seproject1:attribute name="Main-Class" value="${main.class}"/> + </j2seproject1:manifest> + </j2seproject1:jar> + <echo>To run this application from the command line without Ant, try:</echo> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <pathconvert property="run.classpath.with.dist.jar"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> + </pathconvert> + <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries"> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <pathconvert property="run.classpath.without.build.classes.dir"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to=""/> + </pathconvert> + <pathconvert pathsep=" " property="jar.classpath"> + <path path="${run.classpath.without.build.classes.dir}"/> + <chainedmapper> + <flattenmapper/> + <globmapper from="*" to="lib/*"/> + </chainedmapper> + </pathconvert> + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> + <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> + <fileset dir="${build.classes.dir}"/> + <manifest> + <attribute name="Main-Class" value="${main.class}"/> + <attribute name="Class-Path" value="${jar.classpath}"/> + </manifest> + </copylibs> + <echo>To run this application from the command line without Ant, try:</echo> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <echo>java -jar "${dist.jar.resolved}"</echo> + </target> + <target name="-post-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/> + <!-- + ================= + EXECUTION SECTION + ================= + --> + <target depends="init,compile" description="Run a main class." name="run"> + <j2seproject1:java> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject1:java> + </target> + <target name="-do-not-recompile"> + <property name="javac.includes.binary" value=""/> + </target> + <target depends="init,-do-not-recompile,compile-single" name="run-single"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}"/> + </target> + <!-- + ================= + DEBUGGING SECTION + ================= + --> + <target depends="init" if="netbeans.home" name="-debug-start-debugger"> + <j2seproject1:nbjpdastart name="${debug.class}"/> + </target> + <target depends="init,compile" name="-debug-start-debuggee"> + <j2seproject3:debug> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/> + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto"> + <j2seproject1:nbjpdastart stopclassname="${main.class}"/> + </target> + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject3:debug classname="${debug.class}"/> + </target> + <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/> + <target depends="init" name="-pre-debug-fix"> + <fail unless="fix.includes">Must set fix.includes</fail> + <property name="javac.includes" value="${fix.includes}.java"/> + </target> + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix"> + <j2seproject1:nbjpdareload/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> + <!-- + =============== + JAVADOC SECTION + =============== + --> + <target depends="init" name="-javadoc-build"> + <mkdir dir="${dist.javadoc.dir}"/> + <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> + <classpath> + <path path="${javac.classpath}"/> + </classpath> + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}"> + <filename name="**/*.java"/> + </fileset> + </javadoc> + </target> + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview"> + <nbbrowse file="${dist.javadoc.dir}/index.html"/> + </target> + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/> + <!-- + ========================= + JUNIT COMPILATION SECTION + ========================= + --> + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test"> + <mkdir dir="${build.test.classes.dir}"/> + </target> + <target name="-pre-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-test-depend"> + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir=""/> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> + <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir=""/> + <copy todir="${build.test.classes.dir}"/> + </target> + <target name="-post-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/> + <target name="-pre-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> + <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="" srcdir=""/> + <copy todir="${build.test.classes.dir}"/> + </target> + <target name="-post-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/> + <!-- + ======================= + JUNIT EXECUTION SECTION + ======================= + --> + <target depends="init" if="have.tests" name="-pre-test-run"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run"> + <j2seproject3:junit testincludes="**/*Test.java"/> + </target> + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run"> + <fail if="tests.failed">Some tests failed; see details above.</fail> + </target> + <target depends="init" if="have.tests" name="test-report"/> + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/> + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/> + <target depends="init" if="have.tests" name="-pre-test-run-single"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single"> + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> + <j2seproject3:junit excludes="" includes="${test.includes}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single"> + <fail if="tests.failed">Some tests failed; see details above.</fail> + </target> + <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/> + <!-- + ======================= + JUNIT DEBUGGING SECTION + ======================= + --> + <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test"> + <fail unless="test.class">Must select one file in the IDE or set test.class</fail> + <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/> + <delete file="${test.report.file}"/> + <mkdir dir="${build.test.results.dir}"/> + <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}"> + <customize> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <arg value="${test.class}"/> + <arg value="showoutput=true"/> + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/> + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/> + </target> + <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/> + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test"> + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/> + <!-- + ========================= + APPLET EXECUTION SECTION + ========================= + --> + <target depends="init,compile-single" name="run-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject1:java classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject1:java> + </target> + <!-- + ========================= + APPLET DEBUGGING SECTION + ========================= + --> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject3:debug classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/> + <!-- + =============== + CLEANUP SECTION + =============== + --> + <target depends="init" name="deps-clean" unless="no.deps"/> + <target depends="init" name="-do-clean"> + <delete dir="${build.dir}"/> + <delete dir="${dist.dir}"/> + </target> + <target name="-post-clean"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/> +</project> Added: IndexWriter/trunk/ant/build.xml =================================================================== --- IndexWriter/trunk/ant/build.xml (rev 0) +++ IndexWriter/trunk/ant/build.xml 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- You may freely edit this file. See commented blocks below for --> +<!-- some examples of how to customize the build. --> +<!-- (If you delete it and reopen the project it will be recreated.) --> +<project name="IndexWriter" default="default" basedir="."> + <description>Builds, tests, and runs the project IndexWriter.</description> + <import file="nbproject/build-impl.xml"/> + <!-- + + There exist several targets which are by default empty and which can be + used for execution of your tasks. These targets are usually executed + before and after some main targets. They are: + + -pre-init: called before initialization of project properties + -post-init: called after initialization of project properties + -pre-compile: called before javac compilation + -post-compile: called after javac compilation + -pre-compile-single: called before javac compilation of single file + -post-compile-single: called after javac compilation of single file + -pre-compile-test: called before javac compilation of JUnit tests + -post-compile-test: called after javac compilation of JUnit tests + -pre-compile-test-single: called before javac compilation of single JUnit test + -post-compile-test-single: called after javac compilation of single JUunit test + -pre-jar: called before JAR building + -post-jar: called after JAR building + -post-clean: called after cleaning build products + + (Targets beginning with '-' are not intended to be called on their own.) + + Example of inserting an obfuscator after compilation could look like this: + + <target name="-post-compile"> + <obfuscate> + <fileset dir="${build.classes.dir}"/> + </obfuscate> + </target> + + For list of available properties check the imported + nbproject/build-impl.xml file. + + + Another way to customize the build is by overriding existing main targets. + The targets of interest are: + + -init-macrodef-javac: defines macro for javac compilation + -init-macrodef-junit: defines macro for junit execution + -init-macrodef-debug: defines macro for class debugging + -init-macrodef-java: defines macro for class execution + -do-jar-with-manifest: JAR building (if you are using a manifest) + -do-jar-without-manifest: JAR building (if you are not using a manifest) + run: execution of project + -javadoc-build: Javadoc generation + test-report: JUnit report generation + + An example of overriding the target for project execution could look like this: + + <target name="run" depends="IndexWriter-impl.jar"> + <exec dir="bin" executable="launcher.exe"> + <arg file="${dist.jar}"/> + </exec> + </target> + + Notice that the overridden target depends on the jar target and not only on + the compile target as the regular run target does. Again, for a list of available + properties which you can use, check the target you are overriding in the + nbproject/build-impl.xml file. + + --> +</project> Added: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/Initializer.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/Initializer.java (rev 0) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/Initializer.java 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,63 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.indexwriter; + +import org.opencdspowered.opencds.indexwriter.main.*; +import javax.swing.JFrame; +import javax.swing.JDialog; +import javax.swing.UIManager; + +/** + * The class that initializes and starts our application. We do not have to + * set a Look And Feel (LAF) here as thats already done in the core initializer. + * + * @author Lars 'Levia' Wesselius +*/ +public class Initializer +{ + public static void main(String[] args) + { + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + final MainFrame mf = new MainFrame(); + mf.initialize(); + + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + mf.setVisible(true); + } + } + ); + } +} \ No newline at end of file Added: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/main/MainFrame.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/main/MainFrame.java (rev 0) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/main/MainFrame.java 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,235 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.indexwriter.main; + +import java.awt.Color; +import java.awt.Dimension; +import org.opencdspowered.opencds.indexwriter.writer.XMLWriter; +import javax.swing.*; +import java.awt.event.*; +import java.text.SimpleDateFormat; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +/** + * The class that initializes our frame. + * + * @author Lars 'Levia' Wesselius +*/ +public class MainFrame implements ActionListener +{ + private JFrame m_MainFrame; + + private JLabel m_RootFolder; + private JLabel m_Destination; + private JButton m_BrowseRoot; + private JButton m_BrowseDestination; + private JButton m_Go; + + private JTextPane m_Log; + + private XMLWriter m_Writer; + + public MainFrame() + { + m_MainFrame = new JFrame("OpenCDS Index Writer"); + } + + /** + * Creates our frame, then initializes all components. + */ + public void initialize() + { + m_Writer = new XMLWriter(this); + m_MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + m_MainFrame.setLocation(400, 200); + m_MainFrame.setSize(400, 400); + + JPanel contentPane = new JPanel(); + contentPane.setOpaque(true); + BoxLayout bl = new BoxLayout(contentPane, BoxLayout.PAGE_AXIS); + contentPane.setLayout(bl); + contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 5, 3)); + + m_MainFrame.setContentPane(contentPane); + + m_RootFolder = new JLabel("Root folder: none chosen yet"); + m_RootFolder.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_Destination = new JLabel("Destination: none chosen yet"); + m_Destination.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_BrowseRoot = new JButton("Browse"); + m_BrowseRoot.setActionCommand("BrowseRoot"); + m_BrowseRoot.addActionListener(this); + m_BrowseRoot.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_BrowseDestination = new JButton("Browse"); + m_BrowseDestination.setActionCommand("BrowseDestination"); + m_BrowseDestination.addActionListener(this); + m_BrowseDestination.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_Go = new JButton("Go!"); + m_Go.setActionCommand("Go"); + m_Go.addActionListener(this); + m_Go.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + m_Log = new JTextPane(); + m_Log.setEditable(false); + m_Log.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + JScrollPane logPane = new JScrollPane(m_Log); + logPane.setAlignmentX(JComponent.LEFT_ALIGNMENT); + + + contentPane.add(m_RootFolder); + contentPane.add(m_BrowseRoot); + contentPane.add(Box.createRigidArea(new Dimension(0, 5))); + contentPane.add(m_Destination); + contentPane.add(m_BrowseDestination); + contentPane.add(Box.createRigidArea(new Dimension(0, 10))); + contentPane.add(m_Go); + contentPane.add(Box.createRigidArea(new Dimension(0, 10))); + contentPane.add(logPane); + + log("Welcome to OpenCDS Index Writer!\nThis application will write the index file,\nwhich will be used by OpenCDS to find your projects files."); + log("Just choose the project's main folder, choose the destination you want\nto write the XML to, and click Go!"); + log(); + + } + + public void actionPerformed(ActionEvent event) + { + String e = event.getActionCommand(); + + if (e.equals("BrowseRoot")) + { + JFileChooser chooser = new JFileChooser(new java.io.File(".")); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = chooser.showOpenDialog(m_MainFrame); + + try + { + if (returnVal == JFileChooser.APPROVE_OPTION) + { + m_RootFolder.setText("Root folder: " + chooser.getSelectedFile().getAbsolutePath()); + m_Writer.setRootFolder(chooser.getSelectedFile()); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + else if (e.equals("BrowseDestination")) + { + JFileChooser chooser = new JFileChooser(new java.io.File(".")); + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + int returnVal = chooser.showSaveDialog(m_MainFrame); + + try + { + if (returnVal == JFileChooser.APPROVE_OPTION) + { + m_Destination.setText("Destination folder: " + chooser.getSelectedFile().getAbsolutePath()); + m_Writer.setDestination(chooser.getSelectedFile()); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + else if (e.equals("Go")) + { + m_Writer.write(); + } + } + + public void setVisible(boolean visible) + { + m_MainFrame.setVisible(visible); + } + + public void log(String message, String color) + { + Document doc = m_Log.getStyledDocument(); + + SimpleAttributeSet set = new SimpleAttributeSet(); + + if (color.equals("error")) + { + StyleConstants.setBackground(set, new Color(242, 137, 137)); + } + else if (color.equals("warning")) + { + StyleConstants.setBackground(set, new Color(240, 207, 92)); + } + StyleConstants.setForeground(set, Color.BLACK); + + // Parse message. + String[] parts = message.split("\\n"); + for (int i = 0; i != parts.length; ++i) + { + String msg = null; + if (i == 0) + { + msg = parts[i]; + } + else + { + msg = " " + parts[i]; + } + try + { + m_Log.setCaretPosition(doc.getLength()); + doc.insertString(doc.getLength(), msg + "\n", set); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + } + + public void log(String message) + { + log(message, ""); + } + + public void log() + { + Document doc = m_Log.getStyledDocument(); + + try + { + m_Log.setCaretPosition(doc.getLength()); + doc.insertString(doc.getLength(), "\n", null); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} Added: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java (rev 0) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/util/Constants.java 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,34 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.indexwriter.util; + +/** + * The constants class. Holds version information and all that. + * + * @author Lars 'Levia' Wesselius +*/ +public class Constants +{ + public static final String INDEXWRITER_VERSION = "0.1"; +} + + Added: IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java =================================================================== --- IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java (rev 0) +++ IndexWriter/trunk/src/org/opencdspowered/opencds/indexwriter/writer/XMLWriter.java 2008-08-31 19:18:57 UTC (rev 209) @@ -0,0 +1,167 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.indexwriter.writer; + +import org.opencdspowered.opencds.indexwriter.main.MainFrame; +import org.w3c.dom.*; +import javax.xml.parsers.*; +import java.io.*; +import java.math.BigInteger; +import java.security.MessageDigest; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +/** + * The class that writes our XML. + * + * @author Lars 'Levia' Wesselius +*/ +public class XMLWriter +{ + private MainFrame m_MainFrame; + private File m_RootFolder = null; + private File m_Destination = null; + private Document m_Document = null; + + public XMLWriter(MainFrame frame) + { + m_MainFrame = frame; + } + + public void setRootFolder(File file) + { + m_RootFolder = file; + } + + public void setDestination(File file) + { + m_Destination = file; + } + + public void write() + { + if (m_RootFolder == null) + { + m_MainFrame.log("You did not choose a root folder!", "red"); + return; + } + if (m_Destination == null) + { + m_MainFrame.log("You did not choose a destination!", "red"); + return; + } + try + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + m_Document = builder.getDOMImplementation().createDocument(null, null, null); + + m_MainFrame.log("1"); + Element root = m_Document.createElement("indexes"); + m_Document.appendChild(root); + m_MainFrame.log("2"); + + doDirectory(root, m_RootFolder); + m_MainFrame.log("10"); + + DOMSource domSource = new DOMSource(m_Document); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + StreamResult sr = new StreamResult(m_Destination); + transformer.transform(domSource, sr); + } + catch (Exception e) + { + m_MainFrame.log(e.getMessage(), "error"); + return; + } + m_Document = null; + } + + public void doDirectory(Element elem, File dir) + { + File[] subFiles = dir.listFiles(); + + Element dirElem = m_Document.createElement("folder"); + dirElem.setAttribute("name", dir.getName()); + elem.appendChild(dirElem); + + for (int i = 0; i != subFiles.length; ++i) + { + File file = subFiles[i]; + + if (file.isDirectory()) + { + doDirectory(dirElem, file); + } + else + { + doFile(dirElem, file); + } + } + } + + public void doFile(Element elem, File file) + { + Element fileElem = m_Document.createElement("file"); + fileElem.setAttribute("file", file.getName()); + fileElem.setAttribute("hash", getMD5FromFile(file)); + m_MainFrame.log("3"); + elem.appendChild(fileElem); + m_MainFrame.log("4"); + } + + public String getMD5FromFile(File file) + { + try + { + MessageDigest digest = MessageDigest.getInstance("MD5"); + InputStream is = new FileInputStream(file); + byte[] buffer = new byte[8192]; + int read = 0; + + while((read = is.read(buffer)) > 0) + { + digest.update(buffer, 0, read); + } + byte[] md5sum = digest.digest(); + BigInteger bigInt = new BigInteger(1, md5sum); + String output = bigInt.toString(16); + is.close(); + return output; + } + catch (Exception e) + { + m_MainFrame.log(e.getMessage(), "error"); + } + return null; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-31 11:41:11
|
Revision: 208 http://opencds.svn.sourceforge.net/opencds/?rev=208&view=rev Author: levia Date: 2008-08-31 11:41:18 +0000 (Sun, 31 Aug 2008) Log Message: ----------- - Added Release tab, the project info is pretty close to being finished. It needs a bit more information about stuff though. Will also add if you currently have it installed, but that'll require some changes in the project system. - Changes to Release, Executable, Library and Source. Target, Name and file url all moved to Release. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-31 11:41:18 UTC (rev 208) @@ -126,6 +126,7 @@ Splash.Done = Done ProjectInfo = Project info for %project ProjectInfo.Information = Information +ProjectInfo.Release = Release ProjectInfo.Project = Project ProjectInfo.URL = URL ProjectInfo.Description = Description @@ -138,4 +139,14 @@ ProjectInfo.Type.Library = Library ProjectInfo.Type.Source = Source ProjectInfo.Target = Target audience -ProjectInfo.Status = Status \ No newline at end of file +ProjectInfo.Status = Status +ProjectInfo.Download.Done = Done +ProjectInfo.Download.Failed = Failed +ProjectInfo.Download.Idle = Idle +ProjectInfo.Download.Queued = Queued +ProjectInfo.Download.NotDownloaded = Not downloaded yet +ProjectInfo.Name = Name +ProjectInfo.Target = Target +ProjectInfo.Stability = Stability +ProjectInfo.Version = Version +ProjectInfo.FileUrl = File url \ No newline at end of file Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java 2008-08-31 11:41:18 UTC (rev 208) @@ -31,10 +31,6 @@ */ public class Executable extends Release { - private String m_Target; - private String m_FileUrl; - private String m_Name; - private String m_Open; private String m_CommandLine; @@ -44,26 +40,6 @@ { } - public void setTarget(String target) - { - m_Target = target; - } - - public String getTarget() - { - return m_Target; - } - - public void setFileUrl(String url) - { - m_FileUrl = url; - } - - public String getFileUrl() - { - return m_FileUrl; - } - public void setOpen(String open) { m_Open = open; @@ -84,16 +60,6 @@ return m_CommandLine; } - public void setName(String name) - { - m_Name = name; - } - - public String getName() - { - return m_Name; - } - public void addDependency(Dependency dependency) { m_Depends.addElement(dependency); @@ -130,12 +96,5 @@ } } } - - public String toString() - { - return m_Name; - } - - } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java 2008-08-31 11:41:18 UTC (rev 208) @@ -28,50 +28,10 @@ * @author Lars 'Levia' Wesselius */ public class Library extends Release -{ - private String m_Target; - private String m_FileUrl; - private String m_Name; - +{ public Library() { } - - public void setName(String name) - { - m_Name = name; - } - - public String getName() - { - return m_Name; - } - - public void setTarget(String target) - { - m_Target = target; - } - - public String getTarget() - { - return m_Target; - } - - public void setFileUrl(String url) - { - m_FileUrl = url; - } - - public String getFileUrl() - { - return m_FileUrl; - } - - public String toString() - { - return m_Name; - } - } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Release.java 2008-08-31 11:41:18 UTC (rev 208) @@ -29,10 +29,13 @@ */ public class Release { - private int m_Major = 0; - private int m_Minor = 0; - private int m_Patch = 0; - private String m_Stability; + protected int m_Major = 0; + protected int m_Minor = 0; + protected int m_Patch = 0; + protected String m_Stability; + protected String m_FileUrl; + protected String m_Target; + protected String m_Name; public Release() { @@ -77,7 +80,41 @@ { return m_Stability; } - + + public void setFileUrl(String url) + { + m_FileUrl = url; + } + + public String getFileUrl() + { + return m_FileUrl; + } + + public void setTarget(String target) + { + m_Target = target; + } + + public String getTarget() + { + return m_Target; + } + + public void setName(String name) + { + m_Name = name; + } + + public String getName() + { + return m_Name; + } + + public String toString() + { + return m_Name; + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java 2008-08-31 11:41:18 UTC (rev 208) @@ -28,49 +28,10 @@ * @author Lars 'Levia' Wesselius */ public class Source extends Release -{ - private String m_Target; - private String m_FileUrl; - private String m_Name; - +{ public Source() { } - - public void setName(String name) - { - m_Name = name; - } - - public String getName() - { - return m_Name; - } - - public void setTarget(String target) - { - m_Target = target; - } - - public String getTarget() - { - return m_Target; - } - - public void setFileUrl(String url) - { - m_FileUrl = url; - } - - public String getFileUrl() - { - return m_FileUrl; - } - - public String toString() - { - return m_Name; - } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-31 11:41:18 UTC (rev 208) @@ -50,8 +50,9 @@ /** * The information tabs constructor. */ - public InformationTab(Project project, MainFrame mainFrame) + public InformationTab(JTabbedPane pane, Project project, MainFrame mainFrame) { + m_Tabs = pane; m_Project = project; m_MainFrame = mainFrame; initialize(); @@ -113,41 +114,42 @@ Download dl = dlManager.getDownload(exe.getFileUrl()); + JProgressBar bar = new JProgressBar(); bar.setStringPainted(true); bar.setMaximum(100); bar.setMinimum(0); + bar.setString(loc.getMessage("ProjectInfo.Download.NotDownloaded")); - dl.addListener(this); - switch (dl.getState()) + if (dl != null) { - case DownloadManager.STATE_DOWNLOADING: + dl.addListener(this); + switch (dl.getState()) { - System.out.println(11); - dl.addProgressListener(this); - }; break; - case DownloadManager.STATE_DONE: - { - System.out.println(12); - bar.setValue(100); - bar.setString("Done"); - }; break; - case DownloadManager.STATE_FAILED: - { - System.out.println(13); - bar.setString("Failed"); - }; break; - case DownloadManager.STATE_IDLE: - { - System.out.println(14); - bar.setString("Idle"); - }; break; - case DownloadManager.STATE_QUEUED: - { - System.out.println(15); - bar.setIndeterminate(true); - bar.setString("Queued"); - }; break; + case DownloadManager.STATE_DOWNLOADING: + { + bar.setString(null); + dl.addProgressListener(this); + }; break; + case DownloadManager.STATE_DONE: + { + bar.setValue(100); + bar.setString(loc.getMessage("ProjectInfo.Download.Done")); + }; break; + case DownloadManager.STATE_FAILED: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Failed")); + }; break; + case DownloadManager.STATE_IDLE: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Idle")); + }; break; + case DownloadManager.STATE_QUEUED: + { + bar.setIndeterminate(true); + bar.setString(loc.getMessage("ProjectInfo.Download.Queued")); + }; break; + } } @@ -164,6 +166,46 @@ for (Enumeration<Library> elem = m_Project.getAllLibraries(); elem.hasMoreElements();) { Library lib = elem.nextElement(); + + Download dl = dlManager.getDownload(lib.getFileUrl()); + + JProgressBar bar = new JProgressBar(); + bar.setStringPainted(true); + bar.setMaximum(100); + bar.setMinimum(0); + bar.setString(loc.getMessage("ProjectInfo.Download.NotDownloaded")); + + if (dl != null) + { + dl.addListener(this); + switch (dl.getState()) + { + case DownloadManager.STATE_DOWNLOADING: + { + bar.setString(null); + dl.addProgressListener(this); + }; break; + case DownloadManager.STATE_DONE: + { + bar.setValue(100); + bar.setString(loc.getMessage("ProjectInfo.Download.Done")); + }; break; + case DownloadManager.STATE_FAILED: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Failed")); + }; break; + case DownloadManager.STATE_IDLE: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Idle")); + }; break; + case DownloadManager.STATE_QUEUED: + { + bar.setIndeterminate(true); + bar.setString(loc.getMessage("ProjectInfo.Download.Queued")); + }; break; + } + } + Object[] data = { lib, loc.getMessage("ProjectInfo.Type.Library"), @@ -177,6 +219,46 @@ for (Enumeration<Source> elem = m_Project.getAllSources(); elem.hasMoreElements();) { Source src = elem.nextElement(); + + Download dl = dlManager.getDownload(src.getFileUrl()); + + JProgressBar bar = new JProgressBar(); + bar.setStringPainted(true); + bar.setMaximum(100); + bar.setMinimum(0); + bar.setString(loc.getMessage("ProjectInfo.Download.NotDownloaded")); + + if (dl != null) + { + dl.addListener(this); + switch (dl.getState()) + { + case DownloadManager.STATE_DOWNLOADING: + { + bar.setString(null); + dl.addProgressListener(this); + }; break; + case DownloadManager.STATE_DONE: + { + bar.setValue(100); + bar.setString(loc.getMessage("ProjectInfo.Download.Done")); + }; break; + case DownloadManager.STATE_FAILED: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Failed")); + }; break; + case DownloadManager.STATE_IDLE: + { + bar.setString(loc.getMessage("ProjectInfo.Download.Idle")); + }; break; + case DownloadManager.STATE_QUEUED: + { + bar.setIndeterminate(true); + bar.setString(loc.getMessage("ProjectInfo.Download.Queued")); + }; break; + } + } + Object[] data = { src, loc.getMessage("ProjectInfo.Type.Sources"), @@ -222,7 +304,6 @@ int rowCount = model.getRowCount(); DynamicLocalisation loc = m_MainFrame.getLocalisation(); - System.out.println(1231); JProgressBar bar = null; for (int i = 0; i != rowCount; ++i) { @@ -262,16 +343,20 @@ public void valueChanged(ListSelectionEvent event) { - System.out.println("value"); + if (m_Tabs.getTabCount() >= 2) + { + return; + } DefaultTableModel model = (DefaultTableModel)m_TitleTable.getModel(); JProgressBar bar = (JProgressBar)model.getValueAt(m_TitleTable.getSelectedRow(), 3); DownloadManager mgr = m_MainFrame.getDownloadManager(); - Executable exe = (Executable)model.getValueAt(m_TitleTable.getSelectedRow(), 0); + Release rel = (Release)model.getValueAt(m_TitleTable.getSelectedRow(), 0); - Download dl = mgr.getDownload(exe.getFileUrl()); - System.out.println(dl.getState()); - mgr.startQueue(); + Download dl = mgr.getDownload(rel.getFileUrl()); + + m_Tabs.addTab(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Release"), new ReleaseTab(m_MainFrame, m_Tabs, rel, dl)); + m_Tabs.setSelectedIndex(1); } public void stateChanged(Download dl, int oldState, int newState) @@ -284,11 +369,12 @@ { bar.setIndeterminate(false); } + bar.setString(null); dl.addProgressListener(this); } else if (newState == DownloadManager.STATE_FAILED) { - bar.setString("Failed"); + bar.setString(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Download.Failed")); } } @@ -297,7 +383,7 @@ dl.removeProgressListener(this); JProgressBar bar = getProgressBarForDownload(dl); - bar.setString("Done"); + bar.setString(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Download.Done")); } private JProgressBar getProgressBarForDownload(Download dl) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java 2008-08-29 14:16:41 UTC (rev 207) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java 2008-08-31 11:41:18 UTC (rev 208) @@ -88,9 +88,7 @@ m_Tabs = new JTabbedPane(); - m_Tabs.addTab(loc.getMessage("ProjectInfo.Information"), new InformationTab(m_Project, m_MainFrame)); - m_Tabs.addTab("Releases", new JPanel()); - m_Tabs.setEnabledAt(m_Tabs.getTabCount() - 1, false); + m_Tabs.addTab(loc.getMessage("ProjectInfo.Information"), new InformationTab(m_Tabs, m_Project, m_MainFrame)); Added: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ReleaseTab.java 2008-08-31 11:41:18 UTC (rev 208) @@ -0,0 +1,164 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.project; + +import org.opencdspowered.opencds.ui.main.MainFrame; +import org.opencdspowered.opencds.ui.util.Util; +import org.opencdspowered.opencds.core.logging.Logger; +import org.opencdspowered.opencds.core.project.*; +import org.opencdspowered.opencds.core.lang.*; +import org.opencdspowered.opencds.core.download.*; +import javax.swing.*; +import javax.swing.table.*; +import javax.swing.event.*; +import java.awt.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; + +/** + * Release tab shows information about a release. + * + * @author Lars 'Levia' Wesselius +*/ +public class ReleaseTab extends JPanel implements DownloadListener, DownloadProgressListener +{ + private MainFrame m_MainFrame; + private Release m_Release; + private Download m_Download = null; + private JTabbedPane m_Tabs; + private JProgressBar m_ProgressBar; + + /** + * The information tabs constructor. + */ + public ReleaseTab(MainFrame mainFrame, JTabbedPane pane, Release release, Download download) + { + m_Tabs = pane; + m_Release = release; + m_Download = download; + m_MainFrame = mainFrame; + initialize(); + } + + /** + * Initializes the dialog. + */ + public void initialize() + { + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); + + JLabel name = new JLabel(loc.getMessage("ProjectInfo.Name") + ": " + m_Release.getName()); + + JLabel target = new JLabel(loc.getMessage("ProjectInfo.Target") + ": " + m_Release.getTarget()); + + JLabel stability = new JLabel(loc.getMessage("ProjectInfo.Stability") + ": " + m_Release.getStability()); + + JLabel fileUrl = new JLabel(loc.getMessage("ProjectInfo.FileUrl") + ": " + m_Release.getFileUrl()); + + + String versionString = String.valueOf(m_Release.getMajor()); + versionString += "." + String.valueOf(m_Release.getMinor()); + versionString += "." + String.valueOf(m_Release.getPatch()); + JLabel version = new JLabel(loc.getMessage("ProjectInfo.Version") + " " + versionString); + + add(name); + add(target); + add(stability); + add(fileUrl); + add(version); + + if (m_Download != null) + { + m_Download.addListener(this); + + m_ProgressBar = new JProgressBar(0, 100); + m_ProgressBar.setStringPainted(true); + m_ProgressBar.setMaximum(100); + m_ProgressBar.setMinimum(0); + m_ProgressBar.setString(loc.getMessage("ProjectInfo.Download.NotDownloaded")); + + switch (m_Download.getState()) + { + case DownloadManager.STATE_DOWNLOADING: + { + m_ProgressBar.setString(null); + m_Download.addProgressListener(this); + }; break; + case DownloadManager.STATE_DONE: + { + m_ProgressBar.setValue(100); + m_ProgressBar.setString(loc.getMessage("ProjectInfo.Download.Done")); + }; break; + case DownloadManager.STATE_FAILED: + { + m_ProgressBar.setString(loc.getMessage("ProjectInfo.Download.Failed")); + }; break; + case DownloadManager.STATE_IDLE: + { + m_ProgressBar.setString(loc.getMessage("ProjectInfo.Download.Idle")); + }; break; + case DownloadManager.STATE_QUEUED: + { + m_ProgressBar.setIndeterminate(true); + m_ProgressBar.setString(loc.getMessage("ProjectInfo.Download.Queued")); + }; break; + } + + add(Box.createRigidArea(new Dimension(0, 10))); + add(m_ProgressBar); + } + } + + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) + { + m_ProgressBar.setValue((int)percentage); + } + + public void stateChanged(Download dl, int oldState, int newState) + { + if (newState == DownloadManager.STATE_DOWNLOADING) + { + if (m_ProgressBar.isIndeterminate()) + { + m_ProgressBar.setIndeterminate(false); + } + m_ProgressBar.setString(null); + dl.addProgressListener(this); + } + else if (newState == DownloadManager.STATE_FAILED) + { + m_ProgressBar.setString(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Download.Failed")); + } + } + + public void completed(Download dl) + { + dl.removeProgressListener(this); + m_ProgressBar.setString(m_MainFrame.getLocalisation().getMessage("ProjectInfo.Download.Done")); + } + +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-29 14:16:34
|
Revision: 207 http://opencds.svn.sourceforge.net/opencds/?rev=207&view=rev Author: levia Date: 2008-08-29 14:16:41 +0000 (Fri, 29 Aug 2008) Log Message: ----------- - You can now cancel downloads. Important stuff. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java 2008-08-28 22:12:45 UTC (rev 206) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandler.java 2008-08-29 14:16:41 UTC (rev 207) @@ -93,4 +93,11 @@ */ public abstract boolean download(Download download); + /** + * Cancel a download. + * + * @param download The download that needs to be cancelled + */ + public abstract void cancel(Download download); + } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-08-28 22:12:45 UTC (rev 206) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadHandlerManager.java 2008-08-29 14:16:41 UTC (rev 207) @@ -131,6 +131,25 @@ } /** + * Get a handler by give a download object. + * + * @param download The download given. + * @return A reference to a DownloadHandler object, null otherwise. + */ + public DownloadHandler getHandler(Download download) + { + for (Enumeration<DownloadHandler> entries = m_DownloadHandlers.elements(); entries.hasMoreElements();) + { + DownloadHandler proto = (DownloadHandler)entries.nextElement(); + if (download.getAddress().startsWith(proto.getProtocol()) || download.getAddress().startsWith(proto.getFullName())) + { + return proto; + } + } + return null; + } + + /** * Checks whether a handler is registered. * * @param handler Handler to check for. @@ -171,14 +190,25 @@ if (download.getAddress().startsWith(proto.getProtocol())) { - proto.download(download); - return true; + return proto.download(download); } } return false; } + /** + * Cancel a download. + * + * @param download The download that needs to be cancelled. + */ + public void cancelDownload(Download dl) + { + DownloadHandler handler = getHandler(dl); + + handler.cancel(dl); + } + } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-28 22:12:45 UTC (rev 206) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-29 14:16:41 UTC (rev 207) @@ -245,6 +245,33 @@ } /** + * Cancel a download, if it's currently running. + * + * @param download The download to cancel. + */ + public void cancelDownload(Download dl) + { + switch (dl.getState()) + { + case STATE_QUEUED: + { + this.dequeueDownload(dl); + return; + } + case STATE_DOWNLOADING: + { + break; + } + default: + { + return; + } + } + m_DownloadHandlerManager.cancelDownload(dl); + + } + + /** * Enqueue a download. Creates one if it does not exist. This method * differs from <i>addDownload</i> (only if the download does not exist * within the system) that it sets the state to QUEUE, and so that it will Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-28 22:12:45 UTC (rev 206) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-29 14:16:41 UTC (rev 207) @@ -40,7 +40,7 @@ * * @author Lars 'Levia' Wesselius */ -public class InformationTab extends JPanel implements DownloadProgressListener, DownloadListener +public class InformationTab extends JPanel implements DownloadProgressListener, DownloadListener, ListSelectionListener { private MainFrame m_MainFrame; private Project m_Project; @@ -117,9 +117,7 @@ bar.setStringPainted(true); bar.setMaximum(100); bar.setMinimum(0); - - System.out.println(10); - System.out.println(dl.getState()); + dl.addListener(this); switch (dl.getState()) { @@ -199,6 +197,7 @@ m_TitleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + m_TitleTable.getSelectionModel().addListSelectionListener(this); TableColumn col = m_TitleTable.getColumnModel().getColumn(model.getColumnCount() - 1); @@ -261,14 +260,31 @@ m_TitleTable.repaint(); } + public void valueChanged(ListSelectionEvent event) + { + System.out.println("value"); + DefaultTableModel model = (DefaultTableModel)m_TitleTable.getModel(); + JProgressBar bar = (JProgressBar)model.getValueAt(m_TitleTable.getSelectedRow(), 3); + DownloadManager mgr = m_MainFrame.getDownloadManager(); + + Executable exe = (Executable)model.getValueAt(m_TitleTable.getSelectedRow(), 0); + + Download dl = mgr.getDownload(exe.getFileUrl()); + System.out.println(dl.getState()); + mgr.startQueue(); + } + public void stateChanged(Download dl, int oldState, int newState) { JProgressBar bar = getProgressBarForDownload(dl); if (newState == DownloadManager.STATE_DOWNLOADING) { - //bar.setIndeterminate(false); - //dl.addProgressListener(this); + if (bar.isIndeterminate()) + { + bar.setIndeterminate(false); + } + dl.addProgressListener(this); } else if (newState == DownloadManager.STATE_FAILED) { Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java 2008-08-28 22:12:45 UTC (rev 206) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/ftp/FTPHandler.java 2008-08-29 14:16:41 UTC (rev 207) @@ -67,4 +67,8 @@ } return true; } + + public void cancel(Download dl) + { + } } \ No newline at end of file Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-08-28 22:12:45 UTC (rev 206) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-08-29 14:16:41 UTC (rev 207) @@ -24,22 +24,20 @@ import org.opencdspowered.opencds.core.download.*; import org.opencdspowered.opencds.core.plugin.PluginInterface; import org.opencdspowered.opencds.core.lang.Localisation; -import org.opencdspowered.opencds.core.logging.*; import org.opencdspowered.opencds.core.util.ByteParser; -import org.opencdspowered.opencds.ui.main.MainFrame; import java.math.BigDecimal; import javax.swing.*; -import java.util.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * The class that initializes and shows a download tab. * * @author Lars 'Levia' Wesselius */ -public class HTTPDownloadTab implements DownloadProgressListener, DownloadListener +public class HTTPDownloadTab implements DownloadProgressListener, DownloadListener, ActionListener { - private MainFrame m_MainFrame; private JPanel m_ContentPane; private Download m_Download; @@ -48,6 +46,8 @@ private JLabel m_FileSize; private JLabel m_FileNow; + private JButton m_Cancel; + private int m_Index = 0; private PluginInterface m_Interface; @@ -120,6 +120,10 @@ m_FileNow = new JLabel(loc.getMessage("DownloadTab.Downloaded") + ": " + loc.getMessage("DownloadTab.Unknown")); m_FileNow.setOpaque(false); + m_Cancel = new JButton(loc.getMessage("DownloadTab.Cancel")); + m_Cancel.setActionCommand("Cancel"); + m_Cancel.addActionListener(this); + infoPanel.add(file); infoPanel.add(Box.createRigidArea(new Dimension(0, 5))); infoPanel.add(to); @@ -134,11 +138,13 @@ m_ContentPane.add(m_Progress); m_ContentPane.add(Box.createRigidArea(new Dimension(0, 10))); m_ContentPane.add(infoPanel); + m_ContentPane.add(Box.createRigidArea(new Dimension(0, 5))); + m_ContentPane.add(m_Cancel); } public void completed(Download dl) { - m_Progress.setString("Download completed."); + m_Progress.setString(m_Interface.getLocalisation().getMessage("Download.Completed")); } public void stateChanged(Download dl, int oldState, int newState) @@ -175,6 +181,16 @@ } } + public void actionPerformed(ActionEvent event) + { + String e = event.getActionCommand(); + + if (e.equals("Cancel")) + { + m_Interface.getDownloadManager().cancelDownload(m_Download); + m_Progress.setString(m_Interface.getLocalisation().getMessage("DownloadTab.Cancalled")); + } + } } Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-08-28 22:12:45 UTC (rev 206) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-08-29 14:16:41 UTC (rev 207) @@ -26,12 +26,13 @@ import java.net.URLConnection; import java.net.URL; import java.io.*; -import java.awt.event.*; public class HTTPHandler extends DownloadHandler { private PluginInterface m_Interface; private HTTPDownloadTab m_DownloadTab; + private boolean m_Cancel = false; + private boolean m_Pause = false; public HTTPHandler(PluginInterface pluginInterface) { @@ -72,12 +73,20 @@ byte[] buffer = new byte[1024]; int numRead; long numWritten = 0; - while ((numRead = in.read(buffer)) != -1) + + while (((numRead = in.read(buffer)) != -1) && !m_Cancel) { out.write(buffer, 0, numRead); - numWritten += numRead; + numWritten += numRead; dl.setProgress(numWritten); } + in.close(); + out.close(); + if (m_Cancel) + { + return false; + } + return true; } catch (Exception exception) { @@ -102,6 +111,10 @@ return false; } } - return true; } + + public void cancel(Download dl) + { + m_Cancel = true; + } } \ No newline at end of file Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-08-28 22:12:45 UTC (rev 206) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/lang/messages_en_US.properties 2008-08-29 14:16:41 UTC (rev 207) @@ -4,4 +4,7 @@ DownloadTab.FileSize = File size DownloadTab.Unknown = unknown DownloadTab.Downloaded = Downloaded -DownloadTab.Downloading = Downloading \ No newline at end of file +DownloadTab.Downloading = Downloading +DownloadTab.Cancel = Cancel +DownloadTab.Completed = Download completed. +DownloadTab.Cancelled = Download cancelled. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-28 22:12:37
|
Revision: 206 http://opencds.svn.sourceforge.net/opencds/?rev=206&view=rev Author: levia Date: 2008-08-28 22:12:45 +0000 (Thu, 28 Aug 2008) Log Message: ----------- - #0000035: Exception when removing a project from My Gear: Fixed. - Got the progress bar in the table cell to work. That little fucker. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/error/ExceptionList.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java 2008-08-28 22:12:45 UTC (rev 206) @@ -57,6 +57,7 @@ * * @param address The address to get the file from. * @param toFile The place to download it to. + * @param state The state to set the download to. */ public Download(String address, String toFile, int state) { @@ -75,7 +76,6 @@ { m_Address = address; m_ToFile = toFile; - m_State = DownloadManager.STATE_IDLE; } /** @@ -83,7 +83,6 @@ */ public Download() { - m_State = DownloadManager.STATE_IDLE; } /** @@ -218,9 +217,7 @@ */ public void addProgressListener(DownloadProgressListener listener) { - System.out.println("adding"); m_ProgressListeners.add(listener); - System.out.println("done adding"); } /** @@ -298,7 +295,6 @@ m_PrevBytes = m_Progress; m_PrevTime = currTime; m_AvgKBSec = m_KBTotal / m_KBChecks; - System.out.println("Listeners: " + m_ProgressListeners.size()); } setPercentage(bd.intValue()); @@ -336,7 +332,7 @@ for (int i = 0; i < m_DownloadListeners.size(); i++) { DownloadListener listener = (DownloadListener)m_DownloadListeners.get(i); - listener.stateChanged(oldState, newState); + listener.stateChanged(this, oldState, newState); } } @@ -348,7 +344,7 @@ for (int i = 0; i < m_DownloadListeners.size(); i++) { DownloadListener listener = (DownloadListener)m_DownloadListeners.get(i); - listener.completed(); + listener.completed(this); } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadListener.java 2008-08-28 22:12:45 UTC (rev 206) @@ -33,13 +33,16 @@ * * @param oldState The old state of the download. * @param newState The new state of the download. + * @param download The download associated. */ - public void stateChanged(int oldState, int newState); + public void stateChanged(Download dl, int oldState, int newState); /** * Is fired when the Download has been completed. + * + * @param dl The download associated. */ - public void completed(); + public void completed(Download dl); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-28 22:12:45 UTC (rev 206) @@ -361,10 +361,10 @@ newState = STATE_FAILED; Logger.getInstance().log(Logger.LOG_ERROR, "Download: " + dl.getAddress() + " failed downloading. Protocol not supported."); } + System.out.println("status: " + newState); dl.setState(newState); fireDownloadStateChanged(dl, STATE_DOWNLOADING, newState); m_Queue.removeDownload(dl); - removeDownload(dl); } m_QueueStop = true; m_QueueRunning = false; Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-28 22:12:45 UTC (rev 206) @@ -146,7 +146,6 @@ } } Download download = downloadManager.addDownload(latestExe.getFileUrl(), downloadToDir + latestExe.getName()); - //m_MainFrame.addDownloadTab(download); downloadManager.enqueueDownload(download); downloadManager.startQueue(); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/error/ExceptionList.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/error/ExceptionList.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/error/ExceptionList.java 2008-08-28 22:12:45 UTC (rev 206) @@ -191,7 +191,6 @@ */ public void logException(Exception exception, boolean reportable, Date date) { - System.out.println(1); String cfg = ConfigurationManager.getInstance().getValue("Logging.IgnoreExceptions"); if (cfg == null || cfg.equals("false")) { Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-28 22:12:45 UTC (rev 206) @@ -267,13 +267,20 @@ DefaultTableModel model = (DefaultTableModel)m_GearTable.getModel(); int rowCount = model.getRowCount(); - for (int i = 0; i != model.getRowCount(); ++i) + for (int i = 0; i != rowCount; ++i) { - Project rowProject = (Project)model.getValueAt(i, 1); - if (rowProject.equals(project)) + try { - model.removeRow(i); + Project rowProject = (Project)model.getValueAt(i, 1); + if (rowProject.equals(project)) + { + model.removeRow(i); + } } + catch (Exception e) + { + Logger.getInstance().logException(e, false); + } } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-28 12:59:05 UTC (rev 205) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-28 22:12:45 UTC (rev 206) @@ -40,7 +40,7 @@ * * @author Lars 'Levia' Wesselius */ -public class InformationTab extends JPanel implements DownloadProgressListener +public class InformationTab extends JPanel implements DownloadProgressListener, DownloadListener { private MainFrame m_MainFrame; private Project m_Project; @@ -110,14 +110,54 @@ { Executable exe = elem.nextElement(); + Download dl = dlManager.getDownload(exe.getFileUrl()); - dl.addProgressListener(this); + JProgressBar bar = new JProgressBar(); + bar.setStringPainted(true); + bar.setMaximum(100); + bar.setMinimum(0); + + System.out.println(10); + System.out.println(dl.getState()); + dl.addListener(this); + switch (dl.getState()) + { + case DownloadManager.STATE_DOWNLOADING: + { + System.out.println(11); + dl.addProgressListener(this); + }; break; + case DownloadManager.STATE_DONE: + { + System.out.println(12); + bar.setValue(100); + bar.setString("Done"); + }; break; + case DownloadManager.STATE_FAILED: + { + System.out.println(13); + bar.setString("Failed"); + }; break; + case DownloadManager.STATE_IDLE: + { + System.out.println(14); + bar.setString("Idle"); + }; break; + case DownloadManager.STATE_QUEUED: + { + System.out.println(15); + bar.setIndeterminate(true); + bar.setString("Queued"); + }; break; + } + + Object[] data = { exe, loc.getMessage("ProjectInfo.Type.Executable"), exe.getTarget(), - new JProgressBar(0, 100) + bar }; model.addRow(data); @@ -174,21 +214,22 @@ public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) { - System.out.println(1); + if (m_TitleTable == null) + { + return; + } DefaultTableModel model = (DefaultTableModel)m_TitleTable.getModel(); int rowCount = model.getRowCount(); DynamicLocalisation loc = m_MainFrame.getLocalisation(); - System.out.println(2); - + + System.out.println(1231); JProgressBar bar = null; for (int i = 0; i != rowCount; ++i) { String type = (String)model.getValueAt(i, 1); - System.out.println(type); if (loc.getMessage("ProjectInfo.Type.Executable").equals(type)) { - System.out.println("exe"); Executable exe = (Executable)model.getValueAt(i, 0); if (exe.getFileUrl().equals(dl.getAddress())) { @@ -197,7 +238,6 @@ } else if (loc.getMessage("ProjectInfo.Type.Library").equals(type)) { - System.out.println("lib"); Library lib = (Library)model.getValueAt(i, 0); if (lib.getFileUrl().equals(dl.getAddress())) { @@ -220,6 +260,68 @@ bar.setValue((int)percentage); m_TitleTable.repaint(); } + + public void stateChanged(Download dl, int oldState, int newState) + { + JProgressBar bar = getProgressBarForDownload(dl); + + if (newState == DownloadManager.STATE_DOWNLOADING) + { + //bar.setIndeterminate(false); + //dl.addProgressListener(this); + } + else if (newState == DownloadManager.STATE_FAILED) + { + bar.setString("Failed"); + } + } + + public void completed(Download dl) + { + dl.removeProgressListener(this); + JProgressBar bar = getProgressBarForDownload(dl); + + bar.setString("Done"); + } + + private JProgressBar getProgressBarForDownload(Download dl) + { + DefaultTableModel model = (DefaultTableModel)m_TitleTable.getModel(); + + int rowCount = model.getRowCount(); + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + + JProgressBar bar = null; + for (int i = 0; i != rowCount; ++i) + { + String type = (String)model.getValueAt(i, 1); + if (loc.getMessage("ProjectInfo.Type.Executable").equals(type)) + { + Executable exe = (Executable)model.getValueAt(i, 0); + if (exe.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + else if (loc.getMessage("ProjectInfo.Type.Library").equals(type)) + { + Library lib = (Library)model.getValueAt(i, 0); + if (lib.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + else if (loc.getMessage("ProjectInfo.Type.Source").equals(type)) + { + Source src = (Source)model.getValueAt(i, 0); + if (src.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + } + return bar; + } } Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-08-28 12:59:05 UTC (rev 205) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPDownloadTab.java 2008-08-28 22:12:45 UTC (rev 206) @@ -136,16 +136,16 @@ m_ContentPane.add(infoPanel); } - public void completed() + public void completed(Download dl) { m_Progress.setString("Download completed."); } - public void stateChanged(int oldState, int newState) + public void stateChanged(Download dl, int oldState, int newState) { } - public void progress(double totalFileSize, double currentFileSize, double percentage, double kbsec) + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) { if (m_Progress.getMaximum() != (int)totalFileSize) { @@ -164,7 +164,7 @@ m_Progress.setValue((int)progress + add); BigDecimal bd = new BigDecimal(kbsec); bd = bd.setScale(2, BigDecimal.ROUND_UP); - m_Progress.setString(loc.getMessage("Updater.Downloading") + " " + m_Download.getName() + "(" + bd.toString() + " KB/Sec)"); + m_Progress.setString(loc.getMessage("DownloadTab.Downloading") + " " + m_Download.getName() + "(" + bd.toString() + " KB/Sec)"); bd = new BigDecimal(m_Download.getAverageKBSec()); bd = bd.setScale(2, BigDecimal.ROUND_UP); Modified: Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java =================================================================== --- Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-08-28 12:59:05 UTC (rev 205) +++ Plugins/StandardDownloadHandlers/src/org/opencdspowered/opencds/plugins/standarddownloadhandlers/http/HTTPHandler.java 2008-08-28 22:12:45 UTC (rev 206) @@ -26,6 +26,7 @@ import java.net.URLConnection; import java.net.URL; import java.io.*; +import java.awt.event.*; public class HTTPHandler extends DownloadHandler { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-28 12:59:00
|
Revision: 205 http://opencds.svn.sourceforge.net/opencds/?rev=205&view=rev Author: levia Date: 2008-08-28 12:59:05 +0000 (Thu, 28 Aug 2008) Log Message: ----------- - Added InformationTab. - Added ProjectInfoDialog. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadProgressListener.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/GearManager.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectHelper.java OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProgressBarCellRenderer.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/Download.java 2008-08-28 12:59:05 UTC (rev 205) @@ -37,6 +37,7 @@ private String m_Address; private String m_ToFile; + private double m_FileSize; private double m_Progress; private double m_Percent; @@ -217,7 +218,9 @@ */ public void addProgressListener(DownloadProgressListener listener) { + System.out.println("adding"); m_ProgressListeners.add(listener); + System.out.println("done adding"); } /** @@ -295,6 +298,7 @@ m_PrevBytes = m_Progress; m_PrevTime = currTime; m_AvgKBSec = m_KBTotal / m_KBChecks; + System.out.println("Listeners: " + m_ProgressListeners.size()); } setPercentage(bd.intValue()); @@ -356,7 +360,7 @@ for (int i = 0; i < m_ProgressListeners.size(); i++) { DownloadProgressListener listener = (DownloadProgressListener)m_ProgressListeners.get(i); - listener.progress(totalFileSize, currentFileSize, percentage, kbsec); + listener.progress(this, totalFileSize, currentFileSize, percentage, kbsec); } } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadManager.java 2008-08-28 12:59:05 UTC (rev 205) @@ -211,6 +211,29 @@ } /** + * Get a download. + * + * @param address The address of the download to get. + * @return Reference to the download, otherwise null. + */ + public Download getDownload(String address) + { + for (Iterator<Download> it = m_DownloadList.iterator(); it.hasNext();) + { + Download dl = (Download)it.next(); + synchronized (dl) + { + if (dl.getAddress().equals(address)) + { + return dl; + } + } + + } + return null; + } + + /** * Checks whether this download is present in the system or not. * * @param dl The download to check. Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadProgressListener.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadProgressListener.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/download/DownloadProgressListener.java 2008-08-28 12:59:05 UTC (rev 205) @@ -31,12 +31,13 @@ /** * Notification for progress changed. * + * @param dl The download associated. * @param totalFileSize The file size the file should become. * @param currentFileSize The file size it is now. * @param percentage The percentage the download is. * @param kbsec The current KB/Sec. */ - public void progress(double totalFileSize, double currentFileSize, double percentage, double kbsec); + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-28 12:59:05 UTC (rev 205) @@ -123,4 +123,19 @@ Splash.StartingPluginManager = Starting plugin manager.. Splash.LoadingPlugins = Loading plugins.. Splash.PluginsLoaded = Plugins loaded. -Splash.Done = Done \ No newline at end of file +Splash.Done = Done +ProjectInfo = Project info for %project +ProjectInfo.Information = Information +ProjectInfo.Project = Project +ProjectInfo.URL = URL +ProjectInfo.Description = Description +ProjectInfo.Developer = Developer +ProjectInfo.Genre = Genre +ProjectInfo.Titles = Titles +ProjectInfo.Title = Title +ProjectInfo.Type = Type +ProjectInfo.Type.Executable = Executable +ProjectInfo.Type.Library = Library +ProjectInfo.Type.Source = Source +ProjectInfo.Target = Target audience +ProjectInfo.Status = Status \ No newline at end of file Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/BrowserXMLParser.java 2008-08-28 12:59:05 UTC (rev 205) @@ -189,6 +189,7 @@ try { Executable exe = new Executable(); + exe.setName(element.getAttribute("name")); NodeList childNodes = element.getElementsByTagName("version"); Element childElement = (Element)childNodes.item(0); @@ -251,6 +252,7 @@ try { Library lib = new Library(); + lib.setName(element.getAttribute("name")); NodeList childNodes = element.getElementsByTagName("version"); Element childElement = (Element)childNodes.item(0); @@ -292,6 +294,7 @@ try { Source src = new Source(); + src.setName(element.getAttribute("name")); NodeList childNodes = element.getElementsByTagName("version"); Element childElement = (Element)childNodes.item(0); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Executable.java 2008-08-28 12:59:05 UTC (rev 205) @@ -33,6 +33,7 @@ { private String m_Target; private String m_FileUrl; + private String m_Name; private String m_Open; private String m_CommandLine; @@ -83,10 +84,14 @@ return m_CommandLine; } + public void setName(String name) + { + m_Name = name; + } + public String getName() { - String[] parts = m_FileUrl.split("/"); - return parts[parts.length-1]; + return m_Name; } public void addDependency(Dependency dependency) @@ -125,6 +130,11 @@ } } } + + public String toString() + { + return m_Name; + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/GearManager.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/GearManager.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/GearManager.java 2008-08-28 12:59:05 UTC (rev 205) @@ -23,6 +23,7 @@ import org.opencdspowered.opencds.core.init.*; import java.util.*; +import java.io.*; /** * This class keeps the projects in the My Gear list. @@ -231,9 +232,49 @@ private boolean removeDataForProject(Project project) { - return true; + File projectDir = new File("./data/" + project.getName()); + if (projectDir.exists()) + { + return deleteDirectory(projectDir); + } + return false; } + private boolean deleteDirectory(File dir) + { + boolean res = true; + File[] subFiles = dir.listFiles(); + for (int i = 0; i != subFiles.length; ++i) + { + File file = subFiles[i]; + + if (file.isDirectory()) + { + if (!deleteDirectory(file)) + { + res = false; + } + } + else + { + if (!deleteFile(file)) + { + res = false; + } + } + } + if (!dir.delete()) + { + res = false; + } + return res; + } + + private boolean deleteFile(File file) + { + return file.delete(); + } + /** * Fire event. */ Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Library.java 2008-08-28 12:59:05 UTC (rev 205) @@ -31,11 +31,22 @@ { private String m_Target; private String m_FileUrl; + private String m_Name; public Library() { } + public void setName(String name) + { + m_Name = name; + } + + public String getName() + { + return m_Name; + } + public void setTarget(String target) { m_Target = target; @@ -56,6 +67,10 @@ return m_FileUrl; } + public String toString() + { + return m_Name; + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectHelper.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectHelper.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/ProjectHelper.java 2008-08-28 12:59:05 UTC (rev 205) @@ -40,6 +40,11 @@ m_Executable.addElement(exe); } + public Enumeration<Executable> getAllExecutables() + { + return m_Executable.elements(); + } + public Executable getExecutable(int major, int minor, int patch, String stability) { for (Enumeration entries = m_Executable.elements(); entries.hasMoreElements(); ) @@ -146,6 +151,11 @@ m_Library.addElement(lib); } + public Enumeration<Library> getAllLibraries() + { + return m_Library.elements(); + } + public Library getLibrary(int major, int minor, int patch, String stability) { for (Enumeration entries = m_Library.elements(); entries.hasMoreElements(); ) @@ -192,6 +202,11 @@ m_Source.addElement(src); } + public Enumeration<Source> getAllSources() + { + return m_Source.elements(); + } + public Source getSource(int major, int minor, int patch, String stability) { for (Enumeration entries = m_Source.elements(); entries.hasMoreElements(); ) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/project/Source.java 2008-08-28 12:59:05 UTC (rev 205) @@ -31,11 +31,22 @@ { private String m_Target; private String m_FileUrl; + private String m_Name; public Source() { } + public void setName(String name) + { + m_Name = name; + } + + public String getName() + { + return m_Name; + } + public void setTarget(String target) { m_Target = target; @@ -56,7 +67,10 @@ return m_FileUrl; } - + public String toString() + { + return m_Name; + } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-28 12:59:05 UTC (rev 205) @@ -35,6 +35,7 @@ import java.net.URL; import java.awt.event.MouseEvent; import java.awt.event.MouseAdapter; +import java.net.MalformedURLException; /** * The class that shows the project browser list. @@ -173,6 +174,7 @@ column = cModel.getColumn(3); column.setPreferredWidth(100); + m_BrowserTable.setRowHeight(30); JScrollPane gearPane = new JScrollPane(m_BrowserTable); gearPane.setOpaque(false); gearPane.getViewport().setOpaque(false); @@ -204,7 +206,7 @@ { String iconUrl = project.getIcon(); ImageIcon icon = null; - if (!project.getIcon().equals("")) + if (!iconUrl.equals("")) { Image img = Toolkit.getDefaultToolkit().createImage(new URL(iconUrl)); img = img.getScaledInstance(16, 16, Image.SCALE_SMOOTH); @@ -213,15 +215,19 @@ Object[] data = { icon, - project.getName(), + project, project.getGenre(), project.getDeveloper() }; model.addRow(data); } + catch (MalformedURLException ex) + { + Logger.getInstance().logException(ex, false); + } catch (Exception e) { - Logger.getInstance().logException(e); + Logger.getInstance().logException(e, true); } } } @@ -253,7 +259,7 @@ Object[] data = { icon, - project.getName(), + project, project.getGenre(), project.getDeveloper() }; Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-28 12:59:05 UTC (rev 205) @@ -27,6 +27,7 @@ import org.opencdspowered.opencds.core.project.*; import org.opencdspowered.opencds.core.util.*; import org.opencdspowered.opencds.ui.main.MainFrame; +import org.opencdspowered.opencds.ui.project.*; import javax.swing.*; import javax.swing.table.*; import java.net.URL; @@ -242,7 +243,7 @@ if (!project.getIcon().equals("")) { Image img = Toolkit.getDefaultToolkit().createImage(new URL(iconUrl)); - img = img.getScaledInstance(16, 16, Image.SCALE_SMOOTH); + img = img.getScaledInstance(50, 50, Image.SCALE_SMOOTH); icon = new ImageIcon(img); } @@ -339,7 +340,7 @@ } else if (e.equals("Info")) { - + new ProjectInfoDialog(m_MainFrame, true, project); } } Added: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/InformationTab.java 2008-08-28 12:59:05 UTC (rev 205) @@ -0,0 +1,225 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.project; + +import org.opencdspowered.opencds.ui.main.MainFrame; +import org.opencdspowered.opencds.ui.util.Util; +import org.opencdspowered.opencds.core.logging.Logger; +import org.opencdspowered.opencds.core.project.*; +import org.opencdspowered.opencds.core.lang.*; +import org.opencdspowered.opencds.core.download.*; +import javax.swing.*; +import javax.swing.table.*; +import javax.swing.event.*; +import java.awt.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; + +/** + * The information tab shows the basic information about a project. + * + * @author Lars 'Levia' Wesselius +*/ +public class InformationTab extends JPanel implements DownloadProgressListener +{ + private MainFrame m_MainFrame; + private Project m_Project; + private JTabbedPane m_Tabs; + private JTable m_TitleTable; + + /** + * The information tabs constructor. + */ + public InformationTab(Project project, MainFrame mainFrame) + { + m_Project = project; + m_MainFrame = mainFrame; + initialize(); + } + + /** + * Initializes the dialog. + */ + public void initialize() + { + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); + + + String label = "<html>"; + label += loc.getMessage("ProjectInfo.Project") + ": " + m_Project.getName() + "<br>"; + label += loc.getMessage("ProjectInfo.URL") + ": <u>" + m_Project.getUrl() + "</u><br>"; + label += loc.getMessage("ProjectInfo.Developer") + ": " + m_Project.getDeveloper() + "<br>"; + label += loc.getMessage("ProjectInfo.Genre") + ": " + m_Project.getGenre() + "<br>"; + label += loc.getMessage("ProjectInfo.Description") + ": " + m_Project.getDescription() + "<br></html>"; + + + JLabel infoLabel = new JLabel(label); + Util.linkify(infoLabel, false, false, m_Project.getUrl()); + String iconUrl = m_Project.getIcon(); + if (!iconUrl.equals("")) + { + try + { + Image icon = Toolkit.getDefaultToolkit().createImage(new URL(iconUrl)); + icon = icon.getScaledInstance(200, 200, Image.SCALE_SMOOTH); + infoLabel.setIcon(new ImageIcon(icon)); + } + catch (MalformedURLException ex) + { + Logger.getInstance().logException(ex, false); + } + catch (Exception e) + { + Logger.getInstance().logException(e, true); + } + } + + DefaultTableModel model = new DefaultTableModel(); + model.addColumn(loc.getMessage("ProjectInfo.Title")); + model.addColumn(loc.getMessage("ProjectInfo.Type")); + model.addColumn(loc.getMessage("ProjectInfo.Target")); + model.addColumn(loc.getMessage("ProjectInfo.Status")); + + + + DownloadManager dlManager = m_MainFrame.getDownloadManager(); + + for (Enumeration<Executable> elem = m_Project.getAllExecutables(); elem.hasMoreElements();) + { + Executable exe = elem.nextElement(); + + Download dl = dlManager.getDownload(exe.getFileUrl()); + dl.addProgressListener(this); + + Object[] data = { + exe, + loc.getMessage("ProjectInfo.Type.Executable"), + exe.getTarget(), + new JProgressBar(0, 100) + }; + + model.addRow(data); + } + + for (Enumeration<Library> elem = m_Project.getAllLibraries(); elem.hasMoreElements();) + { + Library lib = elem.nextElement(); + Object[] data = { + lib, + loc.getMessage("ProjectInfo.Type.Library"), + lib.getTarget(), + new JProgressBar() + }; + + model.addRow(data); + } + + for (Enumeration<Source> elem = m_Project.getAllSources(); elem.hasMoreElements();) + { + Source src = elem.nextElement(); + Object[] data = { + src, + loc.getMessage("ProjectInfo.Type.Sources"), + src.getTarget(), + new JProgressBar() + }; + + model.addRow(data); + } + + m_TitleTable = new JTable(model) + { + public boolean isCellEditable(int rowIndex, int vColIndex) + { + return false; + } + }; + + + m_TitleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + TableColumn col = m_TitleTable.getColumnModel().getColumn(model.getColumnCount() - 1); + + col.setCellRenderer(new ProgressBarCellRenderer()); + + JScrollPane tablePane = new JScrollPane(m_TitleTable); + add(infoLabel); + add(Box.createRigidArea(new Dimension(0, 10))); + add(tablePane); + + + } + + public void progress(Download dl, double totalFileSize, double currentFileSize, double percentage, double kbsec) + { + System.out.println(1); + DefaultTableModel model = (DefaultTableModel)m_TitleTable.getModel(); + + int rowCount = model.getRowCount(); + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + System.out.println(2); + + JProgressBar bar = null; + for (int i = 0; i != rowCount; ++i) + { + String type = (String)model.getValueAt(i, 1); + System.out.println(type); + if (loc.getMessage("ProjectInfo.Type.Executable").equals(type)) + { + System.out.println("exe"); + Executable exe = (Executable)model.getValueAt(i, 0); + if (exe.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + else if (loc.getMessage("ProjectInfo.Type.Library").equals(type)) + { + System.out.println("lib"); + Library lib = (Library)model.getValueAt(i, 0); + if (lib.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + else if (loc.getMessage("ProjectInfo.Type.Source").equals(type)) + { + System.out.println("src"); + Source src = (Source)model.getValueAt(i, 0); + if (src.getFileUrl().equals(dl.getAddress())) + { + bar = (JProgressBar)model.getValueAt(i, 3); + } + } + + } + //bar = (JProgressBar)model.getValueAt(0, 3); + + bar.setValue((int)percentage); + m_TitleTable.repaint(); + } +} + + Added: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProgressBarCellRenderer.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProgressBarCellRenderer.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProgressBarCellRenderer.java 2008-08-28 12:59:05 UTC (rev 205) @@ -0,0 +1,43 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.project; + +import java.awt.Color; +import javax.swing.table.TableCellRenderer; +import javax.swing.*; +import java.awt.Component; + +/** + * Renders a progress bar in a table cell. + * + * @author Lars 'Levia' Wesselius +*/ +public class ProgressBarCellRenderer implements TableCellRenderer +{ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) + { + JProgressBar prog = (JProgressBar)value; + prog.setBackground(table.getBackground()); + return prog; + } +} + Added: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java (rev 0) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/project/ProjectInfoDialog.java 2008-08-28 12:59:05 UTC (rev 205) @@ -0,0 +1,102 @@ +/* + OpenCDS + Copyright (C) 2007 - 2008 The OpenCDS team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ---------------------------------------------------------------------------- + * Author: Lars 'Levia' Wesselius + ---------------------------------------------------------------------------- +*/ +package org.opencdspowered.opencds.ui.project; + +import org.opencdspowered.opencds.ui.main.MainFrame; +import org.opencdspowered.opencds.core.logging.Logger; +import org.opencdspowered.opencds.core.project.*; +import org.opencdspowered.opencds.core.lang.*; +import javax.swing.*; +import java.awt.*; +import java.net.MalformedURLException; +import java.net.URL; + +/** + * The project info dialog shows information about a project. + * + * @author Lars 'Levia' Wesselius +*/ +public class ProjectInfoDialog extends JDialog +{ + private MainFrame m_MainFrame; + private Project m_Project; + private JTabbedPane m_Tabs; + + /** + * The project info dialog constructor. + */ + public ProjectInfoDialog(MainFrame mainFrame, boolean modal, Project project) + { + super(mainFrame.getFrame(), mainFrame.getLocalisation().getMessageWithParams("ProjectInfo", ParameterList.makeParameterList("project:" + project.getName())), false); + m_MainFrame = mainFrame; + m_Project = project; + initialize(); + } + + /** + * Initializes the dialog. + */ + public void initialize() + { + DynamicLocalisation loc = m_MainFrame.getLocalisation(); + this.setSize(500, 550); + this.setLocationRelativeTo(null); + String iconUrl = m_Project.getIcon(); + Image icon = null; + if (!iconUrl.equals("")) + { + try + { + icon = Toolkit.getDefaultToolkit().createImage(new URL(iconUrl)); + icon = icon.getScaledInstance(16, 16, Image.SCALE_SMOOTH); + } + catch (MalformedURLException ex) + { + Logger.getInstance().logException(ex, false); + } + catch (Exception e) + { + Logger.getInstance().logException(e, true); + } + } + this.setIconImage(icon); + + + JPanel contentPane = new JPanel(); + contentPane.setLayout(new BorderLayout()); + contentPane.setBorder(BorderFactory.createEmptyBorder(5,5,3,5)); + this.setContentPane(contentPane); + + + m_Tabs = new JTabbedPane(); + m_Tabs.addTab(loc.getMessage("ProjectInfo.Information"), new InformationTab(m_Project, m_MainFrame)); + m_Tabs.addTab("Releases", new JPanel()); + m_Tabs.setEnabledAt(m_Tabs.getTabCount() - 1, false); + + + + contentPane.add(m_Tabs); + this.setVisible(true); + } +} + + Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java 2008-08-25 17:49:42 UTC (rev 204) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/util/Util.java 2008-08-28 12:59:05 UTC (rev 205) @@ -108,6 +108,51 @@ } /** + * Linkifies a label. This method sets the color, and changes it's cursor + * to the standard link cursor, and tries to open the link when clicked. + * + * @param label The label to linkify. + * @param underline Whether to underline the link or not. + * @param colorize Whether to colorize the link or not. + * @param link Opens this link when clicked. + */ + public static void linkify(JLabel label, boolean underline, boolean colorize, final String link) + { + label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + if (colorize) + { + label.setForeground(Color.blue); + } + if (underline) + { + label.setText("<html><u>" + label.getText() + "</u></html>"); + } + label.addMouseListener(new MouseListener() + { + public void mouseClicked(MouseEvent event) + { + DesktopIntegration.browse(java.net.URI.create(link)); + } + + public void mousePressed(MouseEvent event) + { + } + + public void mouseReleased(MouseEvent event) + { + } + + public void mouseExited(MouseEvent event) + { + } + + public void mouseEntered(MouseEvent event) + { + } + }); + } + + /** * Flashes a component in given color. The border of the component flashes * to the color given and is then set back to it's old border. It does * this 7 times, and changes it's state every 150 miliseconds. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-25 17:49:45
|
Revision: 204 http://opencds.svn.sourceforge.net/opencds/?rev=204&view=rev Author: levia Date: 2008-08-25 17:49:42 +0000 (Mon, 25 Aug 2008) Log Message: ----------- - #0000034: Add a button to check the changelog in the Help toolbar: Fixed. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java Added Paths: ----------- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/help-checkchangelog.png OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/tab-closeHover.png Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-25 15:24:05 UTC (rev 203) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-25 17:49:42 UTC (rev 204) @@ -33,6 +33,7 @@ HelpMenu = Help HelpMenu.About = About.. HelpMenu.About.Description = Show the about dialog +HelpMenu.CheckChangelog = Check changelog.. AboutDialog.Caption = About AboutDialog.Info = Information AboutDialog.Authors = Authors @@ -102,7 +103,7 @@ MyGear.Table.Genre = Genre MyGear.Table.Developer = Developer MyGear.PopupMenu.Run = Run -MyGear.PopupMenu.Properties = Properties +MyGear.PopupMenu.Info = Info MyGear.PopupMenu.Update = Update MyGear.PopupMenu.Remove = Remove MyGear.PopupMenu.RemoveData = Do you want to remove the project its data aswell? (Removes everything related to this project from your computer) Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-25 15:24:05 UTC (rev 203) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-25 17:49:42 UTC (rev 204) @@ -98,8 +98,8 @@ m_RightMouseMenu.add(item); - item = new JMenuItem(loc.getMessage("MyGear.PopupMenu.Properties")); - item.setActionCommand("Properties"); + item = new JMenuItem(loc.getMessage("MyGear.PopupMenu.Info")); + item.setActionCommand("Info"); item.addActionListener(this); m_RightMouseMenu.add(item); @@ -337,7 +337,7 @@ return; } } - else if (e.equals("Properties")) + else if (e.equals("Info")) { } Property changes on: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/help-checkchangelog.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/icons/tab-closeHover.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-08-25 15:24:05 UTC (rev 203) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-08-25 17:49:42 UTC (rev 204) @@ -25,7 +25,7 @@ import org.opencdspowered.opencds.ui.config.*; import org.opencdspowered.opencds.ui.tray.*; import org.opencdspowered.opencds.ui.error.*; -import org.opencdspowered.opencds.ui.update.UpdateWizard; +import org.opencdspowered.opencds.ui.update.*; import org.opencdspowered.opencds.core.lang.DynamicLocalisation; import org.opencdspowered.opencds.core.config.*; import javax.swing.*; @@ -108,6 +108,15 @@ menu.add(menuItem); + menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckChangelog"), KeyEvent.VK_U); + menuItem.setActionCommand("CheckChangelog"); + menuItem.addActionListener(this); + + imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkchangelog.png"); + menuItem.setIcon(new ImageIcon(imgURL)); + + menu.add(menuItem); + menu.addSeparator(); menuItem = new JMenuItem(loc.getMessage("HelpMenu.About"), KeyEvent.VK_A); @@ -269,6 +278,10 @@ m_MainFrame.getTrayManager().toTray(); m_MainFrame.getTrayManager().showMessage("Tray", "Now I am in tray, you can't control me!", Tray.INFO); } + else if (e.equals("CheckChangelog")) + { + new ChangelogDialog(m_MainFrame, true); + } } public void settingChanged(String key, String oldSetting, String newSetting) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-25 15:27:48
|
Revision: 203 http://opencds.svn.sourceforge.net/opencds/?rev=203&view=rev Author: levia Date: 2008-08-25 15:24:05 +0000 (Mon, 25 Aug 2008) Log Message: ----------- - 0.2.203 release. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java 2008-08-25 14:23:17 UTC (rev 202) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/util/Constants.java 2008-08-25 15:24:05 UTC (rev 203) @@ -33,7 +33,7 @@ public static final String AUTHORS = "Lars 'Levia' Wesselius"; public static final String THANKS_TO = "Kirill Grouchnikov (Substance),Sai_Co (OpenCDS logo),Quaim(Swedish translation)"; - public static final String OPENCDS_VERSION = "0.2.199"; + public static final String OPENCDS_VERSION = "0.2.203"; public static final String UPDATE_DIR = "http://opencdspowered.org/update/"; public static final String UPDATE_SCRIPT = "http://opencdspowered.org/update/listfiles.php"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-25 14:23:24
|
Revision: 202 http://opencds.svn.sourceforge.net/opencds/?rev=202&view=rev Author: levia Date: 2008-08-25 14:23:17 +0000 (Mon, 25 Aug 2008) Log Message: ----------- - #0000024: Changelog is shown after running the updater, even when there are no updates: Fixed. - #0000033: Change Save to Apply in the Configuration dialog: Fixed. - #0000026: Make tooltips optional (default: off): Fixed. Modified Paths: -------------- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/ConfigurationDialog.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/DownloadUpdatesPage.java Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/core/lang/messages_en_US.properties 2008-08-25 14:23:17 UTC (rev 202) @@ -53,7 +53,7 @@ ToolsMenu.Configuration = Configuration.. ToolsMenu.Configuration.Description = The configuration menu where you can adjust settings ConfigurationDialog.Caption = Configuration -ConfigurationDialog.Save = Save +ConfigurationDialog.Save = Apply ConfigurationDialog.GeneralSection = General ConfigurationDialog.GeneralSection.Language = Language ConfigurationDialog.GeneralSection.Language.DesiredLanguage = Desired language (becomes active when OpenCDS is restarted) @@ -73,6 +73,7 @@ ConfigurationDialog.GeneralSection.View.General = General ConfigurationDialog.GeneralSection.View.MinimizeToTray = Minimize to tray ConfigurationDialog.GeneralSection.View.ShowMemoryStatus = Show memory status panel +ConfigurationDialog.GeneralSection.View.EnableTooltips = Enable tooltips ConfigurationDialog.GeneralSection.Updater = Updater ConfigurationDialog.ConnectionSection = Connection ConfigurationDialog.ConnectionSection.HTTP = HTTP Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/browser/Browser.java 2008-08-25 14:23:17 UTC (rev 202) @@ -89,20 +89,6 @@ { return false; } - - public String getToolTipText(MouseEvent e) - { - java.awt.Point p = e.getPoint(); - int rowIndex = rowAtPoint(p); - int colIndex = columnAtPoint(p); - - Project project = (Project)model.getValueAt(rowIndex, 1); - if (project == null) - { - return null; - } - return project.getDescription(); - } }; m_BrowserTable.setOpaque(false); m_BrowserTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/ConfigurationDialog.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/ConfigurationDialog.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/ConfigurationDialog.java 2008-08-25 14:23:17 UTC (rev 202) @@ -23,7 +23,7 @@ import org.opencdspowered.opencds.ui.main.MainFrame; import org.opencdspowered.opencds.core.lang.DynamicLocalisation; -import org.opencdspowered.opencds.core.config.ConfigurationManager; +import org.opencdspowered.opencds.core.config.*; import org.opencdspowered.opencds.ui.config.panels.*; import javax.swing.*; import java.awt.*; Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/config/panels/ViewPanel.java 2008-08-25 14:23:17 UTC (rev 202) @@ -29,7 +29,6 @@ import org.opencdspowered.opencds.ui.tray.Tray; import javax.swing.*; import java.awt.*; -import java.awt.event.*; /** * The Updater configuration panel. @@ -44,6 +43,7 @@ private JCheckBox m_MinimizeToTray; private JCheckBox m_ShowMemoryStatus; + private JCheckBox m_EnableTooltips; /** * The panels dialog constructor. @@ -101,12 +101,17 @@ m_ShowMemoryStatus.setSelected(false); } } - m_GeneralPanel.add(m_ShowMemoryStatus); + m_EnableTooltips = new JCheckBox(loc.getMessage("ConfigurationDialog.GeneralSection.View.EnableTooltips")); + boolean enTooltips = cfgMgr.getBoolValue("Application.EnableTooltips"); + m_EnableTooltips.setSelected(enTooltips); + + m_GeneralPanel.add(m_EnableTooltips); + this.add(Util.createPanelHeader(loc.getMessage( "ConfigurationDialog.GeneralSection") + " : " + loc.getMessage("ConfigurationDialog.GeneralSection.View"))); @@ -125,6 +130,7 @@ cfgMgr.setValue("Application.MinimizeToTray", String.valueOf(m_MinimizeToTray.isSelected())); cfgMgr.setValue("Application.ShowMemoryStatus", String.valueOf(m_ShowMemoryStatus.isSelected())); + cfgMgr.setValue("Application.EnableTooltips", String.valueOf(m_EnableTooltips.isSelected())); } } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/gear/GearBrowser.java 2008-08-25 14:23:17 UTC (rev 202) @@ -118,20 +118,6 @@ { return false; } - - public String getToolTipText(MouseEvent e) - { - java.awt.Point p = e.getPoint(); - int rowIndex = rowAtPoint(p); - int colIndex = columnAtPoint(p); - - Project project = (Project)model.getValueAt(rowIndex, 1); - if (project == null) - { - return null; - } - return project.getDescription(); - } }; m_GearTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m_GearTable.setAlignmentX(JTable.LEFT_ALIGNMENT); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MainFrame.java 2008-08-25 14:23:17 UTC (rev 202) @@ -252,6 +252,8 @@ */ public int addTab(String title, ImageIcon icon, final JComponent panel, String toolTip) { + ConfigurationManager cfgMgr = ConfigurationManager.getInstance(); + boolean skipCloseButton = false; JPanel tabPanel = new JPanel(); tabPanel.setOpaque(false); @@ -323,7 +325,7 @@ int tabIndex = m_Tabs.getTabCount() - 1; - if (toolTip != null) + if (toolTip != null && cfgMgr.getBoolValue("Application.EnableTooltips")) { m_Tabs.setToolTipTextAt(tabIndex, toolTip); } Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/main/MenuBar.java 2008-08-25 14:23:17 UTC (rev 202) @@ -71,7 +71,6 @@ menu.addSeparator(); JMenuItem menuItem = new JMenuItem(loc.getMessage("FileMenu.Close"), KeyEvent.VK_Q); - menuItem.addActionListener(this); imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/file-stop.png"); @@ -83,7 +82,6 @@ menu = new JMenu(loc.getMessage("ToolsMenu")); menuItem = new JMenuItem(loc.getMessage("ToolsMenu.Configuration"), KeyEvent.VK_C); - menuItem.setToolTipText(loc.getMessage("ToolsMenu.Configuration.Description")); menuItem.addActionListener(this); imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/tools-configuration.png"); @@ -95,7 +93,6 @@ menu = new JMenu(loc.getMessage("HelpMenu")); menuItem = new JMenuItem(loc.getMessage("HelpMenu.ReportBug"), KeyEvent.VK_B); - menuItem.setToolTipText(loc.getMessage("HelpMenu.ReportBug.Description")); menuItem.addActionListener(this); imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-reportbug.png"); @@ -104,7 +101,6 @@ menu.add(menuItem); menuItem = new JMenuItem(loc.getMessage("HelpMenu.CheckForUpdates"), KeyEvent.VK_U); - menuItem.setToolTipText(loc.getMessage("HelpMenu.CheckForUpdates.Description")); menuItem.addActionListener(this); imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-checkforupdates.png"); @@ -115,7 +111,6 @@ menu.addSeparator(); menuItem = new JMenuItem(loc.getMessage("HelpMenu.About"), KeyEvent.VK_A); - menuItem.setToolTipText(loc.getMessage("HelpMenu.About.Description")); menuItem.addActionListener(this); imgURL = MenuBar.class.getResource("/org/opencdspowered/opencds/ui/icons/help-about.png"); Modified: OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/DownloadUpdatesPage.java =================================================================== --- OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/DownloadUpdatesPage.java 2008-08-25 13:56:01 UTC (rev 201) +++ OpenCDS/trunk/src/org/opencdspowered/opencds/ui/update/DownloadUpdatesPage.java 2008-08-25 14:23:17 UTC (rev 202) @@ -292,13 +292,13 @@ public void finishPressed(WizardDialog dlg) { - ConfigurationManager.getInstance().setValue("Updater.ShowChangelog", "true"); DynamicLocalisation loc = m_MainFrame.getLocalisation(); if (m_SelectUpdatesPage.getTotalSelectedUpdates() != 0) { // Why do we remove the icon again - because if for any reason, // OpenCDS fails to quit, the icon is gone :) + ConfigurationManager.getInstance().setValue("Updater.ShowChangelog", "true"); MenuBar bar = (MenuBar)m_MainFrame.getFrame().getJMenuBar(); bar.updatesInstalled(); m_MainFrame.stopOpenCDS(2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |