rvsn00p-commits Mailing List for RvSn00p
Brought to you by:
oluies
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(15) |
Nov
(6) |
Dec
(34) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(10) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(9) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ia...@us...> - 2008-08-16 15:43:22
|
Revision: 408
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=408&view=rev
Author: ianp
Date: 2008-08-16 15:43:20 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
Added log4j.properties file and rvsnoop.logDir property.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
Added Paths:
-----------
trunk/rvsn00p/src/main/log4j.properties
Added: trunk/rvsn00p/src/main/log4j.properties
===================================================================
--- trunk/rvsn00p/src/main/log4j.properties (rev 0)
+++ trunk/rvsn00p/src/main/log4j.properties 2008-08-16 15:43:20 UTC (rev 408)
@@ -0,0 +1,14 @@
+# Log4J configuration for RvSnoop @version@.
+# $Id$
+
+log4j.rootLogger=INFO, A
+
+log4j.appender.A = org.apache.log4j.RollingFileAppender
+log4j.appender.A.layout = org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern = %d{ISO8601} %-5p [%c] %m%n
+# The rvsnoop.logDir property is set to point to the correct platform
+# specific log location.
+log4j.appender.A.File = ${rvsnoop.logDir}/rvsnoop.log
+log4j.appender.A.MaxFileSize = 1MB
+log4j.appender.A.MaxBackupIndex = 9
+log4j.appender.A.Encoding = UTF-8
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-08-11 17:08:21 UTC (rev 407)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-08-16 15:43:20 UTC (rev 408)
@@ -59,6 +59,22 @@
*/
public final class RvSnoopApplication extends SingleFrameApplication {
+ static {
+ // Set up the log directory so that it may be used in log4j.properties.
+ final String home = System.getProperty("user.home");
+ final String fileSep = System.getProperty("file.separator");
+ if (SystemUtils.IS_OS_WINDOWS) {
+ System.setProperty("rvsnoop.logDir",
+ home + "/Application Data/Logs/RvSnoop".replace("/", fileSep));
+ } else if (SystemUtils.IS_OS_MAC_OSX) {
+ System.setProperty("rvsnoop.logDir",
+ home + "/Library/Logs/RvSnoop".replace("/", fileSep));
+ } else {
+ System.setProperty("rvsnoop.logDir",
+ home + "/.rvsnoop".replace("/", fileSep));
+ }
+ }
+
private static final Logger logger = new Logger();
/**
@@ -268,7 +284,9 @@
JOptionPane.QUESTION_MESSAGE,
resourceMap.getIcon("banners.exit"));
if (option == JOptionPane.YES_OPTION) {
- // FIXME: this shouldn't be necessary
+ // FIXME: this shouldn't be necessary:
+ // change this class to ExitHandler and make sure all reosurces are
+ // saved as necessary. Inject this class.
UserPreferences.getInstance().store();
return true;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-08-11 17:08:41
|
Revision: 407
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=407&view=rev
Author: ianp
Date: 2008-08-11 17:08:21 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
Use static EventBus methods instead of passing around an explicit EventService.
Added events for connections being added and removed.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/Application.java
trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/Project.java
trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java
trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java
trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -11,7 +11,7 @@
import java.io.File;
import java.io.IOException;
-import org.bushe.swing.event.EventService;
+import org.bushe.swing.event.EventBus;
import org.jdesktop.application.AbstractBean;
import org.rvsnoop.actions.RvSnoopAction;
import org.rvsnoop.ui.MainFrame;
@@ -176,8 +176,6 @@
private final Connections connections;
- private final EventService eventService;
-
private FilteredLedgerView filteredLedger;
/** The main application frame. */
@@ -189,9 +187,8 @@
private Project project;
@Inject
- public Impl(Connections connections, EventService eventService) {
+ public Impl(Connections connections) {
this.connections = connections;
- this.eventService = eventService;
UserPreferences.getInstance().listenToChangesFrom(this);
}
@@ -225,7 +222,7 @@
public synchronized RecordLedger getLedger() {
if (ledger == null) {
- ledger = new InMemoryLedger(eventService);
+ ledger = new InMemoryLedger();
MessageLedger.RECORD_LEDGER = ledger;
}
return ledger;
@@ -262,7 +259,7 @@
}
this.project = project;
// TODO configure the ledger from data in the project file.
- ledger = new InMemoryLedger(eventService);
+ ledger = new InMemoryLedger();
MessageLedger.RECORD_LEDGER = ledger;
filteredLedger = FilteredLedgerView.newInstance(ledger, false);
@@ -273,14 +270,14 @@
project.loadRecordTypes(getRecordTypes());
firePropertyChange(KEY_PROJECT, oldProject, project);
- eventService.publish(new Project.LoadedEvent(project));
+ EventBus.publish(project.new LoadedEvent());
}
public synchronized void setProject(File directory) throws IOException {
project = new Project(directory);
project.store(this);
firePropertyChange(KEY_PROJECT, null, project);
- eventService.publish(new Project.LoadedEvent(project));
+ EventBus.publish(project.new LoadedEvent());
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -15,18 +15,19 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.EventListener;
+import java.util.EventObject;
import java.util.Iterator;
import javax.swing.ListModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.bushe.swing.event.EventBus;
import rvsnoop.RvConnection;
import ca.odell.glazedlists.GlazedLists;
import ca.odell.glazedlists.ObservableElementList;
import ca.odell.glazedlists.SortedList;
-import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.swing.EventListModel;
import ca.odell.glazedlists.util.concurrent.Lock;
@@ -49,7 +50,7 @@
* 2007) $
* @since 1.6
*/
-public abstract class Connections {
+public final class Connections {
private static final Log log = LogFactory.getLog(Connections.class);
@@ -98,6 +99,7 @@
}
connection.setParentList(this);
list.add(connection);
+ EventBus.publish(new AddedEvent(connection));
return true;
} finally {
lock.unlock();
@@ -105,14 +107,6 @@
}
/**
- * @param listChangeListener
- * @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
- */
- public void addListEventListener(ListEventListener<RvConnection> listChangeListener) {
- list.addListEventListener(listChangeListener);
- }
-
- /**
* @see java.util.List#clear()
*/
public void clear() {
@@ -187,6 +181,7 @@
connection.stop();
connection.setParentList(null);
list.remove(connection);
+ EventBus.publish(new RemovedEvent(connection));
return true;
} finally {
lock.unlock();
@@ -194,14 +189,6 @@
}
/**
- * @param listChangeListener
- * @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
- */
- public void removeListEventListener(ListEventListener<RvConnection> listChangeListener) {
- list.removeListEventListener(listChangeListener);
- }
-
- /**
* @return The number of connections.
* @see java.util.List#size()
*/
@@ -230,6 +217,28 @@
}
}
+ public final class AddedEvent extends EventObject {
+
+ static final long serialVersionUID = -1027536693959206731L;
+
+ private final RvConnection connection;
+
+ public AddedEvent(RvConnection connection) {
+ super(Connections.this);
+ this.connection = connection;
+ }
+
+ public RvConnection getConnection() {
+ return connection;
+ }
+
+ @Override
+ public Connections getSource() {
+ return (Connections) super.getSource();
+ }
+
+ }
+
private static class DescriptionComparator implements Comparator<RvConnection> {
private final Collator collator = Collator.getInstance();
@@ -242,9 +251,6 @@
}
}
- public static final class Impl extends Connections {
- }
-
private static class Observer implements ObservableElementList.Connector<RvConnection>,
PropertyChangeListener {
private ObservableElementList<RvConnection> list;
@@ -291,4 +297,27 @@
element.removePropertyChangeListener(this);
}
}
+
+ public final class RemovedEvent extends EventObject {
+
+ private static final long serialVersionUID = -5382677785401677911L;
+
+ private final RvConnection connection;
+
+ public RemovedEvent(RvConnection connection) {
+ super(Connections.this);
+ this.connection = connection;
+ }
+
+ public RvConnection getConnection() {
+ return connection;
+ }
+
+ @Override
+ public Connections getSource() {
+ return (Connections) super.getSource();
+ }
+
+ }
+
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -7,8 +7,6 @@
*/
package org.rvsnoop;
-import org.bushe.swing.event.EventService;
-
import rvsnoop.RecordTypes;
import rvsnoop.SubjectHierarchy;
import ca.odell.glazedlists.EventList;
@@ -46,11 +44,11 @@
if (freezable) {
final FreezableList freezableList = new FreezableList(ledger.getEventList());
final FilterList filter = new FilterList(freezableList);
- final FilteredLedgerView view = new FilteredLedgerView(filter, ledger.getEventService());
+ final FilteredLedgerView view = new FilteredLedgerView(filter);
view.freezableList = freezableList;
return view;
} else {
- return new FilteredLedgerView(ledger);
+ return new FilteredLedgerView(new FilterList(ledger.getEventList()));
}
}
@@ -63,18 +61,14 @@
private MatcherEditor typeFilter;
/** Create a new <code>FilteredLedgerView</code>. */
- protected FilteredLedgerView(FilterList list, EventService eventService) {
- super(list, eventService);
+ protected FilteredLedgerView(FilterList list) {
+ super(list);
list.setMatcherEditor(filters);
filters.setMode(CompositeMatcherEditor.AND);
setFilteringOnSubject(true);
setFilteringOnType(true);
}
- protected FilteredLedgerView(RecordLedger ledger) {
- this(new FilterList(ledger.getEventList()), ledger.getEventService());
- }
-
/**
* Add an arbitrary filter to this view.
*
Modified: trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -7,8 +7,6 @@
*/
package org.rvsnoop;
-import org.bushe.swing.event.EventService;
-
import rvsnoop.Record;
import ca.odell.glazedlists.BasicEventList;
@@ -25,8 +23,8 @@
/**
* Create a new in memory ledger instance.
*/
- public InMemoryLedger(EventService eventService) {
- super(new BasicEventList<Record>(), eventService);
+ public InMemoryLedger() {
+ super(new BasicEventList<Record>());
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Project.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -235,12 +235,12 @@
}
}
- public static final class LoadedEvent extends EventObject {
+ public final class LoadedEvent extends EventObject {
static final long serialVersionUID = 5175118314515685867L;
- public LoadedEvent(Project source) {
- super(source);
+ public LoadedEvent() {
+ super(Project.this);
}
@Override
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -10,8 +10,6 @@
import java.io.IOException;
import java.util.Collection;
-import org.bushe.swing.event.EventService;
-
import rvsnoop.Record;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.event.ListEventListener;
@@ -37,8 +35,6 @@
*/
public abstract class RecordLedger {
- private final EventService eventService;
-
/**
* The underlying event list used by this ledger.
*/
@@ -49,9 +45,8 @@
*
* @param list The list to use as the record store.
*/
- protected RecordLedger(final EventList<Record> list, EventService eventService) {
+ protected RecordLedger(final EventList<Record> list) {
this.list = list;
- this.eventService = eventService;
}
/**
@@ -289,10 +284,6 @@
return list;
}
- EventService getEventService() {
- return eventService;
- }
-
/**
* Remove a single record from the ledger.
* <p>
Modified: trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -35,14 +35,12 @@
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.bushe.swing.event.EventBus;
+import org.bushe.swing.event.EventSubscriber;
import org.rvsnoop.RecordLedgerFormat.ColumnFormat;
import org.rvsnoop.ui.RecordLedgerTable;
import rvsnoop.RvConnection;
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.event.ListEvent;
-import ca.odell.glazedlists.event.ListEventListener;
-import ca.odell.glazedlists.util.concurrent.Lock;
/**
* Handles the storage and retrival of the session state.
@@ -68,12 +66,6 @@
public void columnSelectionChanged(ListSelectionEvent e) { /* NO-OP */ }
}
- private final class RecentConnectionsListener implements ListEventListener<RvConnection> {
- public void listChanged(ListEvent<RvConnection> changes) {
- updateRecentConnectionsList(changes);
- }
- }
-
private final class RecentProjectsListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent event) {
updateRecentProjectsList((Project) event.getNewValue());
@@ -99,7 +91,7 @@
return instance;
}
- private Preferences preferences =
+ private final Preferences preferences =
Preferences.userRoot().node("org").node("rvsnoop").node("sessionState");
private final LinkedList<RvConnection> recentConnections = new LinkedList<RvConnection>();
@@ -131,6 +123,12 @@
final String project = node.get(Integer.toString(i), null);
if (project != null) { recentProjects.add(new File(project)); }
}
+ EventBus.subscribe(Connections.AddedEvent.class, new EventSubscriber<Connections.AddedEvent>() {
+ public void onEvent(Connections.AddedEvent event) {
+ updateRecentConnectionsList(event.getConnection());
+ }
+ });
+
}
/**
@@ -165,7 +163,7 @@
public RvConnection getMostRecentConnection() {
try {
- return (RvConnection) recentConnections.get(0);
+ return recentConnections.get(0);
} catch (Exception e) {
return null;
}
@@ -188,7 +186,6 @@
}
public void listenToChangesFrom(Application application) {
- application.getConnections().addListEventListener(new RecentConnectionsListener());
application.addPropertyChangeListener(Application.KEY_PROJECT, new RecentProjectsListener());
}
@@ -224,25 +221,7 @@
preferences.putInt(KEY_NUM_RECENT_CONNECTIONS, number);
}
- private void updateRecentConnectionsList(ListEvent<RvConnection> changes) {
- final EventList<RvConnection> list = changes.getSourceList();
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- final int max = getNumberOfRecentConnections();
- while (changes.next()) {
- if (changes.getType() == ListEvent.INSERT) {
- final RvConnection o = list.get(changes.getIndex());
- recentConnections.remove(o);
- recentConnections.add(0, o);
- if (recentConnections.size() > max) {
- recentConnections.removeLast();
- }
- }
- }
- } finally {
- lock.unlock();
- }
+ public void store() {
if (recentConnectionsFile == null) { return; }
FileOutputStream stream = null;
try {
@@ -257,6 +236,15 @@
}
}
+ private void updateRecentConnectionsList(RvConnection connection) {
+ final int max = getNumberOfRecentConnections();
+ recentConnections.remove(connection);
+ recentConnections.add(0, connection);
+ if (recentConnections.size() > max) {
+ recentConnections.removeLast();
+ }
+ }
+
private void updateRecentProjectsList(Project newProject) {
final File path = newProject.getDirectory();
final int max = getNumberOfRecentProjects();
@@ -267,7 +255,7 @@
}
final Preferences node = preferences.node(KEY_RECENT_PROJECTS);
for (int i = 0, imax = recentProjects.size(); i < imax; ++i) {
- node.put(Integer.toString(i), ((File) recentProjects.get(i)).getPath());
+ node.put(Integer.toString(i), (recentProjects.get(i)).getPath());
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -8,6 +8,7 @@
package org.rvsnoop.ui;
+import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
@@ -27,8 +28,6 @@
import org.apache.commons.cli2.commandline.Parser;
import org.apache.commons.cli2.util.HelpFormatter;
import org.apache.commons.lang.SystemUtils;
-import org.bushe.swing.event.EventService;
-import org.bushe.swing.event.SwingEventService;
import org.jdesktop.application.Action;
import org.jdesktop.application.ApplicationActionMap;
import org.jdesktop.application.ApplicationContext;
@@ -39,11 +38,13 @@
import org.rvsnoop.Connections;
import org.rvsnoop.Logger;
import org.rvsnoop.Project;
+import org.rvsnoop.UserPreferences;
import rvsnoop.BrowserLauncher;
import rvsnoop.RvConnection;
import rvsnoop.ui.MultiLineToolTipUI;
+import com.apple.eawt.ApplicationEvent;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -57,7 +58,7 @@
* @since 1.7
*/
public final class RvSnoopApplication extends SingleFrameApplication {
-
+
private static final Logger logger = new Logger();
/**
@@ -70,7 +71,7 @@
}
private Injector injector;
-
+
@Action(block=BlockingScope.ACTION)
public CheckForUpdatesTask checkForUpdates() {
return new CheckForUpdatesTask(this);
@@ -101,7 +102,7 @@
resourceMap.getString("displayAbout.info.title"),
JOptionPane.PLAIN_MESSAGE);
}
-
+
@Action
public void displayBugsPage() {
try {
@@ -171,7 +172,7 @@
.withShortName("p").withLongName("project")
.withDescription(resourceMap.getString("CLI.projectDescription")).create();
CommandLine line = parseCommandLine(args, helpOption, projectOption);
-
+
injector = Guice.createInjector(new GuiModule());
injector.injectMembers(this);
@@ -218,7 +219,7 @@
protected void startup() {
MainFrame.INSTANCE = injector.getInstance(Application.class).getFrame();
setMainFrame(MainFrame.INSTANCE);
-
+
final JFrame frame = getMainFrame();
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new FrameClosingListener());
@@ -228,10 +229,14 @@
JMenu fileMenu = frame.getJMenuBar().getMenu(0);
fileMenu.addSeparator();
fileMenu.add(actionMap.get("quit"));
-
+
frame.getJMenuBar().add(createHelpMenu());
getContext().getResourceMap().injectComponents(frame);
+ if (SystemUtils.IS_OS_MAC_OSX) {
+ new MacHandlersInstaller().installHandlers();
+ }
+
show(frame);
}
@@ -241,17 +246,16 @@
exit(event);
}
}
-
+
private class GuiModule extends AbstractModule {
@Override
protected void configure() {
- bind(EventService.class).to(SwingEventService.class).in(Scopes.SINGLETON);
- bind(Connections.class).to(Connections.Impl.class).in(Scopes.SINGLETON);
+ bind(Connections.class).toInstance(new Connections());
bind(Application.class).to(Application.Impl.class).in(Scopes.SINGLETON);
bind(ApplicationContext.class).toInstance(getContext());
}
-
+
}
private class MaybeExit implements ExitListener {
@@ -263,7 +267,13 @@
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
resourceMap.getIcon("banners.exit"));
- return option == JOptionPane.YES_OPTION;
+ if (option == JOptionPane.YES_OPTION) {
+ // FIXME: this shouldn't be necessary
+ UserPreferences.getInstance().store();
+ return true;
+ } else {
+ return false;
+ }
}
public void willExit(EventObject event) {
@@ -281,6 +291,30 @@
}
}
+ private final class MacHandlersInstaller {
+ public void installHandlers() {
+ com.apple.eawt.Application.getApplication().addApplicationListener(new com.apple.eawt.ApplicationAdapter() {
+
+ @Override
+ public void handleAbout(ApplicationEvent event) {
+ getContext().getActionMap().get("displayAbout").actionPerformed(
+ new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "displayAbout"));
+ }
+
+ @Override
+ public void handlePreferences(ApplicationEvent event) {
+ // TODO display the preferences dialog once we have one.
+ }
+
+ @Override
+ public void handleQuit(ApplicationEvent event) {
+ event.setHandled(false);
+ exit();
+ }
+ });
+ }
+ }
+
private class ShutdownHookTask implements Runnable {
ShutdownHookTask() {
super();
Modified: trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -7,9 +7,6 @@
*/
package org.rvsnoop;
-import org.bushe.swing.event.EventBus;
-
-
/**
* Unit tests for the {@link FilteredLedgerView} class.
*
@@ -23,7 +20,7 @@
*/
@Override
protected RecordLedger createRecordLedger() {
- return FilteredLedgerView.newInstance(new InMemoryLedger(EventBus.getGlobalEventService()), false);
+ return FilteredLedgerView.newInstance(new InMemoryLedger(), false);
}
}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -7,8 +7,6 @@
*/
package org.rvsnoop;
-import org.bushe.swing.event.EventBus;
-
/**
* Unit tests for the {@link InMemoryLedger} class.
*
@@ -22,7 +20,7 @@
*/
@Override
protected RecordLedger createRecordLedger() {
- return new InMemoryLedger(EventBus.getGlobalEventService());
+ return new InMemoryLedger();
}
}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-08-11 10:52:01 UTC (rev 406)
+++ trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-08-11 17:08:21 UTC (rev 407)
@@ -70,7 +70,7 @@
// hack. Do the same for RecordStream (or refactor RecordSelection).
@Override
public void setUp() throws IOException {
- connections = new Connections.Impl();
+ connections = new Connections();
ledger = createRecordLedger();
final InputStream stream =
new BufferedInputStream(ClassLoader.getSystemResource(TEST_DATA).openStream());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-08-11 10:52:12
|
Revision: 406
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=406&view=rev
Author: ianp
Date: 2008-08-11 10:52:01 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
Added eventbus library.
Changed project loaded notifications to use eventbus.
Fixed bug in "Save As..." command.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/Application.java
trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/Project.java
trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java
trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java
trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
Added Paths:
-----------
trunk/rvsn00p/lib/eventbus-snapshot-20080802-doc.zip
trunk/rvsn00p/lib/eventbus-snapshot-20080802-src.zip
trunk/rvsn00p/lib/eventbus-snapshot-20080802.jar
Removed Paths:
-------------
trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java
Property changes on: trunk/rvsn00p/lib/eventbus-snapshot-20080802-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/eventbus-snapshot-20080802-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/eventbus-snapshot-20080802.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -11,6 +11,7 @@
import java.io.File;
import java.io.IOException;
+import org.bushe.swing.event.EventService;
import org.jdesktop.application.AbstractBean;
import org.rvsnoop.actions.RvSnoopAction;
import org.rvsnoop.ui.MainFrame;
@@ -175,6 +176,8 @@
private final Connections connections;
+ private final EventService eventService;
+
private FilteredLedgerView filteredLedger;
/** The main application frame. */
@@ -186,8 +189,9 @@
private Project project;
@Inject
- public Impl(Connections connections) {
+ public Impl(Connections connections, EventService eventService) {
this.connections = connections;
+ this.eventService = eventService;
UserPreferences.getInstance().listenToChangesFrom(this);
}
@@ -221,7 +225,7 @@
public synchronized RecordLedger getLedger() {
if (ledger == null) {
- ledger = new InMemoryLedger();
+ ledger = new InMemoryLedger(eventService);
MessageLedger.RECORD_LEDGER = ledger;
}
return ledger;
@@ -258,7 +262,7 @@
}
this.project = project;
// TODO configure the ledger from data in the project file.
- ledger = new InMemoryLedger();
+ ledger = new InMemoryLedger(eventService);
MessageLedger.RECORD_LEDGER = ledger;
filteredLedger = FilteredLedgerView.newInstance(ledger, false);
@@ -269,13 +273,14 @@
project.loadRecordTypes(getRecordTypes());
firePropertyChange(KEY_PROJECT, oldProject, project);
+ eventService.publish(new Project.LoadedEvent(project));
}
public synchronized void setProject(File directory) throws IOException {
- if (project != null) { throw new IllegalStateException(); }
project = new Project(directory);
project.store(this);
firePropertyChange(KEY_PROJECT, null, project);
+ eventService.publish(new Project.LoadedEvent(project));
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -12,8 +12,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.text.Collator;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.EventListener;
import java.util.Iterator;
@@ -50,76 +49,26 @@
* 2007) $
* @since 1.6
*/
-public final class Connections {
+public abstract class Connections {
- private static class DescriptionComparator implements Comparator<RvConnection> {
- private final Collator collator = Collator.getInstance();
+ private static final Log log = LogFactory.getLog(Connections.class);
- public DescriptionComparator() {
- super();
+ public static void toXML(RvConnection[] connections, OutputStream stream) throws IOException {
+ final XMLBuilder builder = new XMLBuilder(stream, XMLBuilder.NS_CONNECTIONS)
+ .namespace(XMLBuilder.PREFIX_RENDEZVOUS, XMLBuilder.NS_RENDEZVOUS)
+ .startTag("connections", XMLBuilder.NS_CONNECTIONS);
+ for (int i = 0, imax = connections.length; i < imax; ++i) {
+ connections[i].toXML(builder);
}
-
- public int compare(RvConnection o1, RvConnection o2) {
- return collator.compare(o1.getDescription(), o2.getDescription());
- }
+ builder.endTag().close();
}
- private static class Observer implements ObservableElementList.Connector<RvConnection>,
- PropertyChangeListener {
- private ObservableElementList<RvConnection> list;
-
- Observer() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ca.odell.glazedlists.ObservableElementList.Connector#installListener(java.lang.Object)
- */
- public EventListener installListener(RvConnection element) {
- element.addPropertyChangeListener(this);
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- list.elementChanged((RvConnection) event.getSource());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ca.odell.glazedlists.ObservableElementList.Connector#setObservableElementList(ca.odell.glazedlists.ObservableElementList)
- */
- public void setObservableElementList(ObservableElementList<RvConnection> list) {
- this.list = list;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ca.odell.glazedlists.ObservableElementList.Connector#uninstallListener(java.lang.Object,
- * java.util.EventListener)
- */
- public void uninstallListener(RvConnection element, EventListener listener) {
- element.removePropertyChangeListener(this);
- }
- }
-
- private static final Log log = LogFactory.getLog(Connections.class);
-
private final ObservableElementList<RvConnection> list;
- public Connections(Collection<RvConnection> connections) {
- if (connections == null) { connections = Collections.emptyList(); }
+ public Connections() {
this.list = new ObservableElementList<RvConnection>(
new SortedList<RvConnection>(
- GlazedLists.eventList(connections),
+ GlazedLists.eventList(new ArrayList<RvConnection>()),
new DescriptionComparator()),
new Observer());
}
@@ -281,14 +230,65 @@
}
}
- public static void toXML(RvConnection[] connections, OutputStream stream) throws IOException {
- final XMLBuilder builder = new XMLBuilder(stream, XMLBuilder.NS_CONNECTIONS)
- .namespace(XMLBuilder.PREFIX_RENDEZVOUS, XMLBuilder.NS_RENDEZVOUS)
- .startTag("connections", XMLBuilder.NS_CONNECTIONS);
- for (int i = 0, imax = connections.length; i < imax; ++i) {
- connections[i].toXML(builder);
+ private static class DescriptionComparator implements Comparator<RvConnection> {
+ private final Collator collator = Collator.getInstance();
+
+ public DescriptionComparator() {
+ super();
}
- builder.endTag().close();
+
+ public int compare(RvConnection o1, RvConnection o2) {
+ return collator.compare(o1.getDescription(), o2.getDescription());
+ }
}
+ public static final class Impl extends Connections {
+ }
+
+ private static class Observer implements ObservableElementList.Connector<RvConnection>,
+ PropertyChangeListener {
+ private ObservableElementList<RvConnection> list;
+
+ Observer() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#installListener(java.lang.Object)
+ */
+ public EventListener installListener(RvConnection element) {
+ element.addPropertyChangeListener(this);
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ list.elementChanged((RvConnection) event.getSource());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#setObservableElementList(ca.odell.glazedlists.ObservableElementList)
+ */
+ public void setObservableElementList(ObservableElementList<RvConnection> list) {
+ this.list = list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#uninstallListener(java.lang.Object,
+ * java.util.EventListener)
+ */
+ public void uninstallListener(RvConnection element, EventListener listener) {
+ element.removePropertyChangeListener(this);
+ }
+ }
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/FilteredLedgerView.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -7,6 +7,8 @@
*/
package org.rvsnoop;
+import org.bushe.swing.event.EventService;
+
import rvsnoop.RecordTypes;
import rvsnoop.SubjectHierarchy;
import ca.odell.glazedlists.EventList;
@@ -44,11 +46,11 @@
if (freezable) {
final FreezableList freezableList = new FreezableList(ledger.getEventList());
final FilterList filter = new FilterList(freezableList);
- final FilteredLedgerView view = new FilteredLedgerView(filter);
+ final FilteredLedgerView view = new FilteredLedgerView(filter, ledger.getEventService());
view.freezableList = freezableList;
return view;
} else {
- return new FilteredLedgerView(new FilterList(ledger.getEventList()));
+ return new FilteredLedgerView(ledger);
}
}
@@ -61,14 +63,18 @@
private MatcherEditor typeFilter;
/** Create a new <code>FilteredLedgerView</code>. */
- protected FilteredLedgerView(FilterList list) {
- super(list);
+ protected FilteredLedgerView(FilterList list, EventService eventService) {
+ super(list, eventService);
list.setMatcherEditor(filters);
filters.setMode(CompositeMatcherEditor.AND);
setFilteringOnSubject(true);
setFilteringOnType(true);
}
+ protected FilteredLedgerView(RecordLedger ledger) {
+ this(new FilterList(ledger.getEventList()), ledger.getEventService());
+ }
+
/**
* Add an arbitrary filter to this view.
*
Modified: trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/InMemoryLedger.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -7,6 +7,10 @@
*/
package org.rvsnoop;
+import org.bushe.swing.event.EventService;
+
+import rvsnoop.Record;
+
import ca.odell.glazedlists.BasicEventList;
/**
@@ -21,8 +25,8 @@
/**
* Create a new in memory ledger instance.
*/
- public InMemoryLedger() {
- super(new BasicEventList());
+ public InMemoryLedger(EventService eventService) {
+ super(new BasicEventList<Record>(), eventService);
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Project.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -18,6 +18,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
+import java.util.EventObject;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -234,4 +235,19 @@
}
}
+ public static final class LoadedEvent extends EventObject {
+
+ static final long serialVersionUID = 5175118314515685867L;
+
+ public LoadedEvent(Project source) {
+ super(source);
+ }
+
+ @Override
+ public Project getSource() {
+ return (Project) super.getSource();
+ }
+
+ }
+
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -10,6 +10,8 @@
import java.io.IOException;
import java.util.Collection;
+import org.bushe.swing.event.EventService;
+
import rvsnoop.Record;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.event.ListEventListener;
@@ -35,6 +37,8 @@
*/
public abstract class RecordLedger {
+ private final EventService eventService;
+
/**
* The underlying event list used by this ledger.
*/
@@ -45,8 +49,9 @@
*
* @param list The list to use as the record store.
*/
- protected RecordLedger(final EventList<Record> list) {
+ protected RecordLedger(final EventList<Record> list, EventService eventService) {
this.list = list;
+ this.eventService = eventService;
}
/**
@@ -284,6 +289,10 @@
return list;
}
+ EventService getEventService() {
+ return eventService;
+ }
+
/**
* Remove a single record from the ledger.
* <p>
Modified: trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -7,14 +7,6 @@
*/
package org.rvsnoop;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.Window;
-import java.awt.event.HierarchyBoundsListener;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
@@ -25,14 +17,12 @@
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
-import java.util.StringTokenizer;
import java.util.prefs.BackingStoreException;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
-import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
@@ -43,7 +33,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.RecordLedgerFormat.ColumnFormat;
@@ -67,24 +56,6 @@
*/
public final class UserPreferences {
- private final class DividerLocationListener implements HierarchyBoundsListener {
- public void ancestorMoved(HierarchyEvent e) {
- final Component c = e.getChanged();
- if (c instanceof JSplitPane) { setDividerLocation((JSplitPane) c); }
- }
- public void ancestorResized(HierarchyEvent e) {
- final Component c = e.getChanged();
- if (c instanceof JSplitPane) { setDividerLocation((JSplitPane) c); }
- }
- }
-
- private final class FontChangeListener implements PropertyChangeListener {
- public void propertyChange(PropertyChangeEvent event) {
- if (!"font".equals(event.getPropertyName())) { return; }
- setLedgerFont((Font) event.getNewValue());
- }
- }
-
private final class LedgerColumnsListener implements TableColumnModelListener {
public void columnAdded(TableColumnModelEvent e) {
setLedgerColumns((TableColumnModel) e.getSource());
@@ -109,35 +80,17 @@
}
}
- private final class WindowBoundsListener extends WindowAdapter implements HierarchyBoundsListener {
- public void ancestorMoved(HierarchyEvent e) {
- final Component component = e.getChanged();
- if (component instanceof Window) { setWindowBounds((Window) component); }
- }
- public void ancestorResized(HierarchyEvent e) {
- final Component component = e.getChanged();
- if (component instanceof Window) { setWindowBounds((Window) component); }
- }
- @Override
- public void windowClosed(WindowEvent e) {
- setWindowBounds(e.getWindow());
- }
- }
-
private static final Log log = LogFactory.getLog(UserPreferences.class);
private static UserPreferences instance;
static String ERROR_CREATING_DIR, ERROR_STORING_CONNECTIONS;
- private static final String KEY_DIVIDER_LOCATION = "DividerLocation";
private static final String KEY_LAST_EXPORT_LOCATION = "LASTExportLocation";
private static final String KEY_LEDGER_COLUMNS = "ledgerColumns";
- public static final String KEY_LEDGER_FONT = "ledgerFont";
private static final String KEY_NUM_RECENT_CONNECTIONS = "numberOfRecentConnections";
private static final String KEY_NUM_RECENT_PROJECTS = "numberOfRecentProjects";
private static final String KEY_RECENT_PROJECTS = "recentProjects";
- private static final String KEY_WINDOW_BOUNDS = "windowBounds";
static { NLSUtils.internationalize(UserPreferences.class); }
@@ -188,16 +141,6 @@
preferences.addPreferenceChangeListener(pcl);
}
- /**
- * Return the divider location for a named {@link JSplitPane}.
- *
- * @param name The name of the split pane to get the location for.
- * @return The location, or <code>-1</code> if no location was stored.
- */
- public int getDividerLocation(String name) {
- return preferences.getInt(name + KEY_DIVIDER_LOCATION, -1);
- }
-
public String getLastExportLocation() {
return preferences.get(KEY_LAST_EXPORT_LOCATION, SystemUtils.USER_DIR);
}
@@ -220,11 +163,6 @@
return columns;
}
- public Font getLedgerFont() {
- final Font font = Font.decode(preferences.get(KEY_LEDGER_FONT, ""));
- return font != null ? font : UIManager.getFont("Table.font");
- }
-
public RvConnection getMostRecentConnection() {
try {
return (RvConnection) recentConnections.get(0);
@@ -249,35 +187,13 @@
return Collections.unmodifiableList(recentProjects);
}
- public Rectangle getWindowBounds() {
- try {
- final String bounds = preferences.get(KEY_WINDOW_BOUNDS, "100,100,800,600");
- final StringTokenizer stok = new StringTokenizer(bounds, ",");
- final int x = Integer.parseInt(stok.nextToken());
- final int y = Integer.parseInt(stok.nextToken());
- final int w = Integer.parseInt(stok.nextToken());
- final int h = Integer.parseInt(stok.nextToken());
- return new Rectangle(x, y, w, h);
- } catch (Exception e) {
- return new Rectangle(100, 100, 800, 600);
- }
- }
-
public void listenToChangesFrom(Application application) {
application.getConnections().addListEventListener(new RecentConnectionsListener());
application.addPropertyChangeListener(Application.KEY_PROJECT, new RecentProjectsListener());
}
public void listenToChangesFrom(JFrame frame, RecordLedgerTable table, JSplitPane[] splits) {
- frame.addPropertyChangeListener("font", new FontChangeListener());
- final WindowBoundsListener wbl = new WindowBoundsListener();
- frame.addHierarchyBoundsListener(wbl);
- frame.addWindowListener(wbl);
table.getColumnModel().addColumnModelListener(new LedgerColumnsListener());
- final DividerLocationListener dll = new DividerLocationListener();
- for (int i = 0, imax = splits.length; i < imax; ++i) {
- splits[i].addHierarchyBoundsListener(dll);
- }
}
/**
@@ -288,12 +204,6 @@
preferences.removePreferenceChangeListener(pcl);
}
- private void setDividerLocation(final JSplitPane splitpane) {
- final String name = splitpane.getName();
- final int location = splitpane.getDividerLocation();
- preferences.putInt(name + KEY_DIVIDER_LOCATION, location);
- }
-
public void getLastExportLocation(String path) {
preferences.put(KEY_LAST_EXPORT_LOCATION, path);
}
@@ -310,33 +220,10 @@
}
}
- public void setLedgerFont(final Font font) {
- if (font == null) { return; }
- final StrBuilder builder = new StrBuilder();
- builder.append(font.getFamily()).append('-');
- if (font.isPlain()) {
- builder.append("PLAIN");
- } else {
- if (font.isBold()) { builder.append("BOLD"); }
- if (font.isItalic()) { builder.append("ITALIC"); }
- }
- builder.append('-').append(Integer.toString(font.getSize()));
- preferences.put(KEY_LEDGER_FONT, builder.toString());
- }
-
public void setNumberOfRecentConnections(int number) {
preferences.putInt(KEY_NUM_RECENT_CONNECTIONS, number);
}
- private void setWindowBounds(Window window) {
- final StrBuilder builder = new StrBuilder();
- builder.append(Integer.toString(window.getX())).append(',');
- builder.append(Integer.toString(window.getY())).append(',');
- builder.append(Integer.toString(window.getWidth())).append(',');
- builder.append(Integer.toString(window.getHeight()));
- preferences.put(KEY_LEDGER_FONT, builder.toString());
- }
-
private void updateRecentConnectionsList(ListEvent<RvConnection> changes) {
final EventList<RvConnection> list = changes.getSourceList();
final Lock lock = list.getReadWriteLock().readLock();
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -13,8 +13,6 @@
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
@@ -61,15 +59,6 @@
import org.rvsnoop.actions.SearchBySelection;
import org.rvsnoop.actions.SelectAllRecords;
import org.rvsnoop.actions.ShowAllColumns;
-import org.rvsnoop.ui.ConnectionList;
-import org.rvsnoop.ui.ImageFactory;
-import org.rvsnoop.ui.RecentConnectionsMenuManager;
-import org.rvsnoop.ui.RecentProjectsMenuManager;
-import org.rvsnoop.ui.RecordLedgerTable;
-import org.rvsnoop.ui.RecordTypesMenuManager;
-import org.rvsnoop.ui.StatusBar;
-import org.rvsnoop.ui.TrackingAdjustmentListener;
-import org.rvsnoop.ui.VisibleColumnsMenuManager;
import rvsnoop.Record;
import rvsnoop.TreeModelAdapter;
@@ -123,19 +112,6 @@
}
}
- private final class FontChangeListener implements PreferenceChangeListener {
- public void preferenceChange(PreferenceChangeEvent event) {
- if (UserPreferences.KEY_LEDGER_FONT.equals(event.getKey())) {
- final Font font = UserPreferences.getInstance().getLedgerFont();
- messageLedger.setFont(font);
- // Without this the default rowNumber height is about 1-million-billion pixels...
- final int rowHeight = messageLedger.getFontMetrics(font).getHeight() + 2;
- messageLedger.setRowHeight(rowHeight);
- }
- }
-
- }
-
private static final long serialVersionUID = 4315311340452405694L;
private static final String TOOLTIP_VISIBLE_COLUMNS = "Show or hide individual table columns";
@@ -171,7 +147,6 @@
subjectExplorer = createSubjectExplorer();
connectionList = new ConnectionList(application);
messageLedger = createMessageLedger(application.getFilteredLedger());
- messageLedger.setFont(state.getLedgerFont());
connectionListScroller = createConnectionListScroller(connectionList);
subjectExplorerScroller = createSubjectExplorerScroller(subjectExplorer);
messageLedgerScroller = createMessageLedgerScroller(messageLedger);
@@ -184,12 +159,8 @@
getContentPane().add(createToolBar(factory), BorderLayout.NORTH);
getContentPane().add(statusBar, BorderLayout.SOUTH);
pack();
- setBounds(state.getWindowBounds());
connectListeners();
- configureDividerLocation(connectionListSplitter, "connectionList", state);
- configureDividerLocation(messageLedgerSplitter, "recordLedger", state);
- configureDividerLocation(subjectExplorerSplitter, "subjectExplorer", state);
state.listenToChangesFrom(this, messageLedger, new JSplitPane[] {
connectionListSplitter, messageLedgerSplitter, subjectExplorerSplitter });
}
@@ -198,12 +169,6 @@
detailsPanel.setMessage(null);
}
- private void configureDividerLocation(JSplitPane pane, String name, UserPreferences state) {
- pane.setName(name);
- final int location = state.getDividerLocation(name);
- if (location > 0) { pane.setDividerLocation(location); }
- }
-
private void connectListeners() {
final ListSelectionModel messageLedgerSelectionModel = messageLedger.getSelectionModel();
messageLedgerSelectionModel.addListSelectionListener(new MessageLedgerListener());
@@ -212,16 +177,8 @@
messageLedgerSelectionModel.addListSelectionListener((ListSelectionListener) action);
}
}
- UserPreferences.getInstance().addPreferenceChangeListener(new FontChangeListener());
}
- private JMenu createConfigureMenu() {
- final JMenu configure = new JMenu("Configure");
- configure.setMnemonic('c');
- configure.add(Actions.CHANGE_TABLE_FONT);
- return configure;
- }
-
private JScrollPane createConnectionListScroller(JList listenerList) {
final JScrollPane scrollPane = new JScrollPane(listenerList);
scrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.GRAY));
@@ -293,7 +250,6 @@
bar.add(createFileMenu(factory));
bar.add(createEditMenu(factory));
bar.add(createViewMenu(factory, table));
- bar.add(createConfigureMenu());
return bar;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -27,6 +27,8 @@
import org.apache.commons.cli2.commandline.Parser;
import org.apache.commons.cli2.util.HelpFormatter;
import org.apache.commons.lang.SystemUtils;
+import org.bushe.swing.event.EventService;
+import org.bushe.swing.event.SwingEventService;
import org.jdesktop.application.Action;
import org.jdesktop.application.ApplicationActionMap;
import org.jdesktop.application.ApplicationContext;
@@ -40,7 +42,6 @@
import rvsnoop.BrowserLauncher;
import rvsnoop.RvConnection;
-import rvsnoop.Version;
import rvsnoop.ui.MultiLineToolTipUI;
import com.google.inject.AbstractModule;
@@ -144,11 +145,13 @@
private void ensureJavaVersionIsValid() {
if (!SystemUtils.isJavaVersionAtLeast(150)) {
+ ResourceMap resourceMap = getContext().getResourceMap();
Object message = new String[] {
- "Java 1.5 or later is required to run " + Version.getAsStringWithName(),
- "Please rerun using a supported Java version."
+ resourceMap.getString("CLI.error.javaVersion[0]"),
+ resourceMap.getString("CLI.error.javaVersion[1]")
};
- JOptionPane.showMessageDialog(null, message, "Error!", JOptionPane.ERROR_MESSAGE);
+ String title = resourceMap.getString("CLI.error.javaVersion.title");
+ JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
System.exit(-1);
}
}
@@ -243,7 +246,8 @@
@Override
protected void configure() {
- bind(Connections.class).toInstance(new Connections(null));
+ bind(EventService.class).to(SwingEventService.class).in(Scopes.SINGLETON);
+ bind(Connections.class).to(Connections.Impl.class).in(Scopes.SINGLETON);
bind(Application.class).to(Application.Impl.class).in(Scopes.SINGLETON);
bind(ApplicationContext.class).toInstance(getContext());
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties 2008-08-11 10:52:01 UTC (rev 406)
@@ -15,6 +15,10 @@
CLI.error.unreadableProject = The project '%s' could not be read, check the file permissions.
CLI.warn.noProject = No filename was specified with the project option.
+CLI.error.javaVersion.title = Wrong Java Version
+CLI.error.javaVersion[0] = Java 1.5 or later is required to run ${Application.title} ${Application.version}.
+CLI.error.javaVersion[1] = Please rerun using a supported Java version.
+
# Non-action GUI Localization
mainFrame.title = ${Application.title} ${Application.version}
mainFrame.iconImage = mainFrameIcon.png
Modified: trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -84,8 +84,6 @@
private static final Log log = LogFactory.getLog(Actions.class);
- public static final Action CHANGE_TABLE_FONT = add(new ChangeTableFont());
-
public static final Action DISPLAY_HOME_PAGE = add(new DisplayHomePage());
public static final Action IMPORT_FROM_RECORD_BUNDLE = add(new ImportFromRecordBundle());
Deleted: trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -1,58 +0,0 @@
-/*
- * Class: ChangeTableFont
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop.actions;
-
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-
-import org.rvsnoop.UserPreferences;
-import org.rvsnoop.ui.MainFrame;
-
-import rvsnoop.ui.FontChooser;
-import rvsnoop.ui.Icons;
-
-/**
- * Change the font used to display text in the message ledger.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.4
- */
-final class ChangeTableFont extends AbstractAction {
-
- private static final String ID = "changeTableFont";
-
- private static String NAME = "Change Font";
-
- private static final long serialVersionUID = 7334880831350593586L;
-
- private static String TOOLTIP = "Change the font used to display text in the message ledger";
-
- public ChangeTableFont() {
- super(NAME);
- putValue(Action.ACTION_COMMAND_KEY, ID);
- putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putValue(Action.SMALL_ICON, Icons.FONT);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- public void actionPerformed(ActionEvent event) {
- final FontChooser chooser = new FontChooser();
- chooser.setSelectedFont(UserPreferences.getInstance().getLedgerFont());
- if (chooser.showDialog(MainFrame.INSTANCE) == FontChooser.OK_OPTION) {
- final Font font = chooser.getSelectedFont();
- UserPreferences.getInstance().setLedgerFont(font);
- }
- }
-
-}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -7,7 +7,9 @@
*/
package org.rvsnoop;
+import org.bushe.swing.event.EventBus;
+
/**
* Unit tests for the {@link FilteredLedgerView} class.
*
@@ -21,7 +23,7 @@
*/
@Override
protected RecordLedger createRecordLedger() {
- return FilteredLedgerView.newInstance(new InMemoryLedger(), false);
+ return FilteredLedgerView.newInstance(new InMemoryLedger(EventBus.getGlobalEventService()), false);
}
}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -7,6 +7,8 @@
*/
package org.rvsnoop;
+import org.bushe.swing.event.EventBus;
+
/**
* Unit tests for the {@link InMemoryLedger} class.
*
@@ -20,7 +22,7 @@
*/
@Override
protected RecordLedger createRecordLedger() {
- return new InMemoryLedger();
+ return new InMemoryLedger(EventBus.getGlobalEventService());
}
}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-07-25 22:19:37 UTC (rev 405)
+++ trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-08-11 10:52:01 UTC (rev 406)
@@ -70,7 +70,7 @@
// hack. Do the same for RecordStream (or refactor RecordSelection).
@Override
public void setUp() throws IOException {
- connections = new Connections(null);
+ connections = new Connections.Impl();
ledger = createRecordLedger();
final InputStream stream =
new BufferedInputStream(ClassLoader.getSystemResource(TEST_DATA).openStream());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-25 22:19:42
|
Revision: 405
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=405&view=rev
Author: ianp
Date: 2008-07-25 22:19:37 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Upgraded Commons CLI to 2.0 development version.
Moved startup code into new application class and deleted old launcher.
Started to refactor code to use Guice to resolve dependencies instead
of using the service locator pattern everywhere.
Modified Paths:
--------------
trunk/rvsn00p/bin/rvsnoop.cmd
trunk/rvsn00p/bin/rvsnoop.sh
trunk/rvsn00p/src/main/org/rvsnoop/Application.java
trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
Added Paths:
-----------
trunk/rvsn00p/lib/commons-cli-snapshot-679881-doc.zip
trunk/rvsn00p/lib/commons-cli-snapshot-679881-src.zip
trunk/rvsn00p/lib/commons-cli-snapshot-679881.jar
trunk/rvsn00p/src/main/org/rvsnoop/Logger.java
Removed Paths:
-------------
trunk/rvsn00p/lib/commons-cli-1.0-doc.zip
trunk/rvsn00p/lib/commons-cli-1.0-src.zip
trunk/rvsn00p/lib/commons-cli-1.0.jar
trunk/rvsn00p/src/main/org/rvsnoop/Application.properties
trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java
Modified: trunk/rvsn00p/bin/rvsnoop.cmd
===================================================================
--- trunk/rvsn00p/bin/rvsnoop.cmd 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/bin/rvsnoop.cmd 2008-07-25 22:19:37 UTC (rev 405)
@@ -39,6 +39,6 @@
if "no%CLASSPATH%" neq "no" set CP=%CP%;%CLASSPATH%
rem Change the "start javaw" on the next line to "java" to see a console log of any errors.
-start javaw -Xmx128m -Drvsnoop.home=%RVSNOOP_HOME% -Dfile.encoding=UTF-8 -Djava.util.logging.config.file=%RVSNOOP_HOME%\lib\commons-logging.properties -classpath "%CP%" rvsnoop.StartRvSnooper %*
+start javaw -Xmx128m -Drvsnoop.home=%RVSNOOP_HOME% -Dfile.encoding=UTF-8 -Djava.util.logging.config.file=%RVSNOOP_HOME%\lib\commons-logging.properties -classpath "%CP%" org.rvsnoop.ui.RvSnoopApplication %*
endlocal
\ No newline at end of file
Modified: trunk/rvsn00p/bin/rvsnoop.sh
===================================================================
--- trunk/rvsn00p/bin/rvsnoop.sh 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/bin/rvsnoop.sh 2008-07-25 22:19:37 UTC (rev 405)
@@ -55,4 +55,4 @@
-Dapple.laf.useScreenMenuBar=true \
-Dcom.apple.mrj.application.apple.menu.about.name="RvSnoop" \
-Djava.util.logging.config.file="${RVSNOOP_HOME}/lib/commons-logging.properties" \
- -classpath "$CP" rvsnoop.StartRvSnooper $* &
+ -classpath "$CP" org.rvsnoop.ui.RvSnoopApplication $* &
Property changes on: trunk/rvsn00p/lib/commons-cli-snapshot-679881-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/commons-cli-snapshot-679881-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/commons-cli-snapshot-679881.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -8,22 +8,21 @@
package org.rvsnoop;
import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
import java.io.File;
import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.jdesktop.application.AbstractBean;
import org.rvsnoop.actions.RvSnoopAction;
import org.rvsnoop.ui.MainFrame;
import org.rvsnoop.ui.RecordLedgerTable;
import rvsnoop.MessageLedger;
import rvsnoop.RecordTypes;
-import rvsnoop.RvConnection;
import rvsnoop.SubjectHierarchy;
import rvsnoop.actions.Actions;
+import com.google.inject.Inject;
+
/**
* The main application class.
* <p>
@@ -34,54 +33,23 @@
* @version $Revision$, $Date$
* @since 1.7
*/
-public final class Application {
+public interface Application {
/** Key for the 'project' JavaBean property. */
public static final String KEY_PROJECT = "project";
-
- private static final Log log = LogFactory.getLog(Application.class);
- static { NLSUtils.internationalize(Application.class); }
-
- static String ERROR_SHUTDOWN;
-
- private Actions actionFactory;
-
- private Connections connections;
-
- private FilteredLedgerView filteredLedger;
-
- /** The main application frame. */
- private MainFrame frame;
-
- private RecordLedger ledger;
-
- /** The current project. */
- private Project project;
-
- private final PropertyChangeSupport propertyChangeSupport =
- new PropertyChangeSupport(this);
-
- public Application() {
- UserPreferences.getInstance().listenToChangesFrom(this);
- }
-
/**
* @param listener
* @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
*/
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
+ public void addPropertyChangeListener(PropertyChangeListener listener);
/**
* @param propertyName
* @param listener
* @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
*/
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
/**
* Get an action from the applications action factory.
@@ -91,9 +59,7 @@
* <code>null</code> if no action exists for the command.
* @see Actions#getAction(String)
*/
- public RvSnoopAction getAction(String command) {
- return getActionFactory().getAction(command);
- }
+ public RvSnoopAction getAction(String command);
/**
* Get the action factory for this application.
@@ -101,20 +67,14 @@
* Note that there is also a convenience method to get individual actions.
*
*/
- public synchronized Actions getActionFactory() {
- if (actionFactory == null) { actionFactory = new Actions(this); }
- return actionFactory;
- }
+ public Actions getActionFactory();
/**
* Get the connections list for the current project.
*
* @return The connections list.
*/
- public synchronized Connections getConnections() {
- if (connections == null) { connections = new Connections(null, true); }
- return connections;
- }
+ public Connections getConnections();
/**
* Get the main filtered ledger view.
@@ -127,23 +87,12 @@
*
* @return The shared <code>FilteredLedgerView</code>.
*/
- public synchronized FilteredLedgerView getFilteredLedger() {
- if (filteredLedger == null) {
- filteredLedger = FilteredLedgerView.newInstance(getLedger(), false);
- }
- return filteredLedger;
- }
+ public FilteredLedgerView getFilteredLedger();
/**
* @return the frame
*/
- public synchronized MainFrame getFrame() {
- if (frame == null) {
- frame = new MainFrame(this);
- getActionFactory().configureListeners();
- }
- return frame;
- }
+ public MainFrame getFrame();
/**
* Get the record ledger.
@@ -153,22 +102,14 @@
*
* @return The ledger.
*/
- public synchronized RecordLedger getLedger() {
- if (ledger == null) {
- ledger = new InMemoryLedger();
- MessageLedger.RECORD_LEDGER = ledger;
- }
- return ledger;
- }
+ public RecordLedger getLedger();
/**
* Get the record ledger table.
*
* @return The ledger table.
*/
- public RecordLedgerTable getLedgerTable() {
- return getFrame().getRecordLedger();
- }
+ public RecordLedgerTable getLedgerTable();
/**
* Get the current project.
@@ -176,46 +117,34 @@
* @return The project, or <code>null</code> if the project has not been
* saved yet.
*/
- public synchronized Project getProject() {
- return project;
- }
+ public Project getProject();
/**
* Get all of the known record types.
*
* @return The record types.
*/
- public synchronized RecordTypes getRecordTypes() {
- // FIXME this should not use a static instance, they should be loaded from the project.
- return RecordTypes.getInstance();
- }
+ public RecordTypes getRecordTypes();
/**
* Get the shared subject hierarchy.
*
* @return The subject hierarchy.
*/
- public synchronized SubjectHierarchy getSubjectHierarchy() {
- // FIXME this should not use a static instance, they should be loaded from the project.
- return SubjectHierarchy.INSTANCE;
- }
+ public SubjectHierarchy getSubjectHierarchy();
/**
* @param listener
* @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
*/
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
+ public void removePropertyChangeListener(PropertyChangeListener listener);
/**
* @param propertyName
* @param listener
* @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
*/
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
- }
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
/**
* Set a new current project.
@@ -226,32 +155,8 @@
* @throws IOException If there is a current ledger and it could not be
* synchronized (applies to persistent ledgers only).
*/
- public synchronized void setProject(Project project) throws IOException {
- final Project oldProject = this.project;
- if (project.equals(oldProject)) { return; }
- // XXX when changing the ledger be sure to copy any listeners across
- // to the new ledger instance.
- if (this.project != null) {
- ledger.syncronize();
- ledger = null;
- MessageLedger.RECORD_LEDGER = null;
- filteredLedger = null;
- }
- this.project = project;
- // TODO configure the ledger from data in the project file.
- ledger = new InMemoryLedger();
- MessageLedger.RECORD_LEDGER = ledger;
- filteredLedger = FilteredLedgerView.newInstance(ledger, false);
+ public void setProject(Project project) throws IOException;
- getConnections().clear();
- project.loadConnections(getConnections());
-
- getRecordTypes().clear();
- project.loadRecordTypes(getRecordTypes());
-
- propertyChangeSupport.firePropertyChange(KEY_PROJECT, oldProject, project);
- }
-
/**
* Set a project for the application.
* <p>
@@ -261,27 +166,117 @@
* @param directory The directory to store the project in.
* @throws IOException If there is a problem storing the project.
*/
- public synchronized void setProject(File directory) throws IOException {
- if (project != null) { throw new IllegalStateException(); }
- project = new Project(directory);
- project.store(this);
- propertyChangeSupport.firePropertyChange(KEY_PROJECT, null, project);
- }
+ public void setProject(File directory) throws IOException;
+
+
+ public static final class Impl extends AbstractBean implements Application {
- /**
- * Shut down the applicatiopn and stop the VM.
- */
- public void shutdown() {
- try {
- final RvConnection[] conns = connections.toArray();
- for (int i = 0, imax = conns.length; i < imax; ++i) {
- conns[i].stop();
+ private Actions actionFactory;
+
+ private final Connections connections;
+
+ private FilteredLedgerView filteredLedger;
+
+ /** The main application frame. */
+ private MainFrame frame;
+
+ private RecordLedger ledger;
+
+ /** The current project. */
+ private Project project;
+
+ @Inject
+ public Impl(Connections connections) {
+ this.connections = connections;
+ UserPreferences.getInstance().listenToChangesFrom(this);
+ }
+
+ public RvSnoopAction getAction(String command) {
+ return getActionFactory().getAction(command);
+ }
+
+ public synchronized Actions getActionFactory() {
+ if (actionFactory == null) { actionFactory = new Actions(this); }
+ return actionFactory;
+ }
+
+ public synchronized Connections getConnections() {
+ return connections;
+ }
+
+ public synchronized FilteredLedgerView getFilteredLedger() {
+ if (filteredLedger == null) {
+ filteredLedger = FilteredLedgerView.newInstance(getLedger(), false);
}
- RvConnection.shutdown();
- System.exit(0);
- } catch (Exception e) {
- if (log.isErrorEnabled()) { log.error(ERROR_SHUTDOWN, e); }
- System.exit(1);
+ return filteredLedger;
}
+
+ public synchronized MainFrame getFrame() {
+ if (frame == null) {
+ frame = new MainFrame(this);
+ getActionFactory().configureListeners();
+ }
+ return frame;
+ }
+
+ public synchronized RecordLedger getLedger() {
+ if (ledger == null) {
+ ledger = new InMemoryLedger();
+ MessageLedger.RECORD_LEDGER = ledger;
+ }
+ return ledger;
+ }
+
+ public RecordLedgerTable getLedgerTable() {
+ return getFrame().getRecordLedger();
+ }
+
+ public synchronized Project getProject() {
+ return project;
+ }
+
+ public synchronized RecordTypes getRecordTypes() {
+ // FIXME this should not use a static instance, they should be loaded from the project.
+ return RecordTypes.getInstance();
+ }
+
+ public synchronized SubjectHierarchy getSubjectHierarchy() {
+ // FIXME this should not use a static instance, they should be loaded from the project.
+ return SubjectHierarchy.INSTANCE;
+ }
+
+ public synchronized void setProject(Project project) throws IOException {
+ final Project oldProject = this.project;
+ if (project.equals(oldProject)) { return; }
+ // XXX when changing the ledger be sure to copy any listeners across
+ // to the new ledger instance.
+ if (this.project != null) {
+ ledger.syncronize();
+ ledger = null;
+ MessageLedger.RECORD_LEDGER = null;
+ filteredLedger = null;
+ }
+ this.project = project;
+ // TODO configure the ledger from data in the project file.
+ ledger = new InMemoryLedger();
+ MessageLedger.RECORD_LEDGER = ledger;
+ filteredLedger = FilteredLedgerView.newInstance(ledger, false);
+
+ getConnections().clear();
+ project.loadConnections(getConnections());
+
+ getRecordTypes().clear();
+ project.loadRecordTypes(getRecordTypes());
+
+ firePropertyChange(KEY_PROJECT, oldProject, project);
+ }
+
+ public synchronized void setProject(File directory) throws IOException {
+ if (project != null) { throw new IllegalStateException(); }
+ project = new Project(directory);
+ project.store(this);
+ firePropertyChange(KEY_PROJECT, null, project);
+ }
}
+
}
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/Application.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.properties 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.properties 2008-07-25 22:19:37 UTC (rev 405)
@@ -1 +0,0 @@
-ERROR_SHUTDOWN=Exception caught during shut down sequence.
\ No newline at end of file
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -115,16 +115,13 @@
private final ObservableElementList<RvConnection> list;
- private final boolean ownsConnections;
-
- public Connections(Collection<RvConnection> connections, boolean ownsConnections) {
+ public Connections(Collection<RvConnection> connections) {
if (connections == null) { connections = Collections.emptyList(); }
this.list = new ObservableElementList<RvConnection>(
new SortedList<RvConnection>(
GlazedLists.eventList(connections),
new DescriptionComparator()),
new Observer());
- this.ownsConnections = ownsConnections;
}
/**
@@ -150,7 +147,7 @@
if (log.isInfoEnabled()) {
log.info("Adding connection: " + connection);
}
- if (ownsConnections) { connection.setParentList(this); }
+ connection.setParentList(this);
list.add(connection);
return true;
} finally {
@@ -178,10 +175,8 @@
if (log.isInfoEnabled()) {
log.info("Removing connection: " + connection);
}
- if (ownsConnections) {
- connection.stop();
- connection.setParentList(null);
- }
+ connection.stop();
+ connection.setParentList(null);
list.remove(0);
}
} finally {
@@ -240,10 +235,8 @@
if (log.isInfoEnabled()) {
log.info("Removing connection: " + connection);
}
- if (ownsConnections) {
- connection.stop();
- connection.setParentList(null);
- }
+ connection.stop();
+ connection.setParentList(null);
list.remove(connection);
return true;
} finally {
Added: trunk/rvsn00p/src/main/org/rvsnoop/Logger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Logger.java (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Logger.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -0,0 +1,82 @@
+/*
+ * Class: Logger
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2008 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+
+package org.rvsnoop;
+
+import org.apache.log4j.Level;
+import org.jdesktop.application.ResourceMap;
+
+/**
+ * A logger that integrates JSR-296 resource maps and Log4J.
+ * <p>
+ * The opportunity has also been taken to enforce some best practices.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.7
+ */
+public class Logger {
+
+ private final org.apache.log4j.Logger delegate;
+
+ public Logger() {
+ String name = new Exception().getStackTrace()[1].getClassName();
+ delegate = org.apache.log4j.Logger.getLogger(name);
+ }
+
+ public void debug(ResourceMap resourceMap, String key, Object... args) {
+ if (!delegate.isEnabledFor(Level.DEBUG)) { return; }
+ delegate.debug(resourceMap.getString(key, args));
+ }
+
+ public void debug(ResourceMap resourceMap, String key, Throwable t, Object... args) {
+ if (!delegate.isEnabledFor(Level.DEBUG)) { return; }
+ delegate.debug(resourceMap.getString(key, args), t);
+ }
+
+ public void error(ResourceMap resourceMap, String key, Object... args) {
+ if (!delegate.isEnabledFor(Level.ERROR)) { return; }
+ delegate.error(resourceMap.getString(key, args));
+ }
+
+ public void error(ResourceMap resourceMap, String key, Throwable t, Object... args) {
+ if (!delegate.isEnabledFor(Level.ERROR)) { return; }
+ delegate.error(resourceMap.getString(key, args), t);
+ }
+
+ public void fatal(ResourceMap resourceMap, String key, Object... args) {
+ if (!delegate.isEnabledFor(Level.FATAL)) { return; }
+ delegate.fatal(resourceMap.getString(key, args));
+ }
+
+ public void fatal(ResourceMap resourceMap, String key, Throwable t, Object... args) {
+ if (!delegate.isEnabledFor(Level.FATAL)) { return; }
+ delegate.fatal(resourceMap.getString(key, args), t);
+ }
+
+ public void info(ResourceMap resourceMap, String key, Object... args) {
+ if (!delegate.isEnabledFor(Level.INFO)) { return; }
+ delegate.info(resourceMap.getString(key, args));
+ }
+
+ public void info(ResourceMap resourceMap, String key, Throwable t, Object... args) {
+ if (!delegate.isEnabledFor(Level.INFO)) { return; }
+ delegate.info(resourceMap.getString(key, args), t);
+ }
+
+ public void warn(ResourceMap resourceMap, String key, Object... args) {
+ if (!delegate.isEnabledFor(Level.WARN)) { return; }
+ delegate.warn(resourceMap.getString(key, args));
+ }
+
+ public void warn(ResourceMap resourceMap, String key, Throwable t, Object... args) {
+ if (!delegate.isEnabledFor(Level.WARN)) { return; }
+ delegate.warn(resourceMap.getString(key, args), t);
+ }
+
+}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -11,6 +11,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
+import java.io.IOException;
import java.util.EventObject;
import javax.swing.JFrame;
@@ -18,8 +19,14 @@
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Group;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.commandline.Parser;
+import org.apache.commons.cli2.util.HelpFormatter;
+import org.apache.commons.lang.SystemUtils;
import org.jdesktop.application.Action;
import org.jdesktop.application.ApplicationActionMap;
import org.jdesktop.application.ApplicationContext;
@@ -27,23 +34,40 @@
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.Task.BlockingScope;
import org.rvsnoop.Application;
+import org.rvsnoop.Connections;
+import org.rvsnoop.Logger;
+import org.rvsnoop.Project;
import rvsnoop.BrowserLauncher;
+import rvsnoop.RvConnection;
+import rvsnoop.Version;
+import rvsnoop.ui.MultiLineToolTipUI;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+import com.google.inject.Scopes;
/**
* The main UI class for RvSnoop.
*
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
+ * @since 1.7
*/
public final class RvSnoopApplication extends SingleFrameApplication {
- private static final Log logger = LogFactory.getLog(RvSnoopApplication.class);
+ private static final Logger logger = new Logger();
+ /**
+ * The application entry point.
+ *
+ * @param args The command line arguments.
+ */
+ public static void main(final String[] args) throws Exception {
+ org.jdesktop.application.Application.launch(RvSnoopApplication.class, args);
+ }
+
private Injector injector;
@Action(block=BlockingScope.ACTION)
@@ -82,9 +106,7 @@
try {
BrowserLauncher.openURL("http://sourceforge.net/tracker/?group_id=63447");
} catch (Exception e) {
- if (logger.isErrorEnabled()) {
- logger.error(getContext().getResourceMap().getString("displayBugsPage.error.browser"), e);
- }
+ logger.error(getContext().getResourceMap(), "displayBugsPage.error.browser", e);
}
}
@@ -97,9 +119,7 @@
? "" : "file://";
BrowserLauncher.openURL(prefix + help.getAbsolutePath());
} catch (Exception e) {
- if (logger.isErrorEnabled()) {
- logger.error(getContext().getResourceMap().getString("displayHelp.error.browser"), e);
- }
+ logger.error(getContext().getResourceMap(), "displayHelp.error.browser", e);
}
}
@@ -113,9 +133,7 @@
try {
BrowserLauncher.openURL("http://rvsn00p.sourceforge.net");
} catch (Exception e) {
- if (logger.isErrorEnabled()) {
- logger.error(getContext().getResourceMap().getString("displayHomePage.error.browser"), e);
- }
+ logger.error(getContext().getResourceMap(), "displayHomePage.error.browser", e);
}
}
@@ -124,17 +142,78 @@
displayDocPage("license.html");
}
+ private void ensureJavaVersionIsValid() {
+ if (!SystemUtils.isJavaVersionAtLeast(150)) {
+ Object message = new String[] {
+ "Java 1.5 or later is required to run " + Version.getAsStringWithName(),
+ "Please rerun using a supported Java version."
+ };
+ JOptionPane.showMessageDialog(null, message, "Error!", JOptionPane.ERROR_MESSAGE);
+ System.exit(-1);
+ }
+ }
+
@Override
protected void initialize(String[] args) {
+ ensureJavaVersionIsValid();
+ ResourceMap resourceMap = getContext().getResourceMap();
+ logger.info(resourceMap, "info.appStarted");
+ Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHookTask(), "shutdownHook"));
+ MultiLineToolTipUI.configure();
+
+ Option helpOption = new DefaultOptionBuilder()
+ .withShortName("h").withLongName("help")
+ .withDescription(resourceMap.getString("CLI.helpDescription")).create();
+ Option projectOption = new DefaultOptionBuilder()
+ .withShortName("p").withLongName("project")
+ .withDescription(resourceMap.getString("CLI.projectDescription")).create();
+ CommandLine line = parseCommandLine(args, helpOption, projectOption);
+
injector = Guice.createInjector(new GuiModule());
injector.injectMembers(this);
+
+ Project project = loadProjectIfValid(projectOption, line);
+ if (project != null) {
+ try {
+ injector.getInstance(Application.class).setProject(project);
+ } catch (IOException e) {
+ logger.error(getContext().getResourceMap(), "CLI.error.readingProject");
+ }
+ }
}
+ private CommandLine parseCommandLine(String[] args, Option helpOption, Option projectOption) {
+ Group group = new GroupBuilder().withOption(helpOption).withOption(projectOption).create();
+ Parser parser = new Parser();
+ parser.setGroup(group);
+ parser.setHelpOption(helpOption);
+ parser.setHelpFormatter(new HelpFormatter());
+ CommandLine line = parser.parseAndHelp(args);
+ if (line.hasOption(helpOption)) { System.exit(0); }
+ return line;
+ }
+
+ private Project loadProjectIfValid(Option project, CommandLine line) {
+ if (!line.hasOption(project)) { return null; }
+ String filename = line.getValue(project).toString();
+ if (filename == null || filename.length() == 0) {
+ logger.warn(getContext().getResourceMap(), "CLI.warn.noProject");
+ return null;
+ }
+ File file = new File(filename);
+ if (!file.canRead()) {
+ logger.error(getContext().getResourceMap(), "CLI.error.unreadableProject", filename);
+ return null;
+ }
+ return new Project(file);
+ }
+
/* (non-Javadoc)
* @see org.jdesktop.application.Application#startup()
*/
@Override
protected void startup() {
+ MainFrame.INSTANCE = injector.getInstance(Application.class).getFrame();
setMainFrame(MainFrame.INSTANCE);
final JFrame frame = getMainFrame();
@@ -164,7 +243,8 @@
@Override
protected void configure() {
- bind(Application.class).toInstance(new Application());
+ bind(Connections.class).toInstance(new Connections(null));
+ bind(Application.class).to(Application.Impl.class).in(Scopes.SINGLETON);
bind(ApplicationContext.class).toInstance(getContext());
}
@@ -183,8 +263,27 @@
}
public void willExit(EventObject event) {
- injector.getInstance(Application.class).shutdown();
+ try {
+ final RvConnection[] conns = injector.getInstance(Connections.class).toArray();
+ for (int i = 0, imax = conns.length; i < imax; ++i) {
+ conns[i].stop();
+ }
+ RvConnection.shutdown();
+ System.exit(0);
+ } catch (Exception e) {
+ logger.error(getContext().getResourceMap(), "error.shutdown", e);
+ System.exit(1);
+ }
}
}
+ private class ShutdownHookTask implements Runnable {
+ ShutdownHookTask() {
+ super();
+ }
+ public void run() {
+ logger.info(getContext().getResourceMap(), "info.appStopped");
+ }
+ }
+
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties 2008-07-25 22:19:37 UTC (rev 405)
@@ -7,17 +7,25 @@
Application.homepage = http://rvsnoop.org
Application.description = A Rendezvous message viewing utility.
-# The resources below are "injected" at startup time, just
-# before the mainFrame is packed, with:
-# appContext.getResourceMap(getClass()).injectComponents(mainFrame);
+# Command line options
+
+CLI.helpDescription = Display a short help message then exit.
+CLI.projectDescription = Load a project file on startup.
+CLI.error.readingProject = The project '%s' could not be read.
+CLI.error.unreadableProject = The project '%s' could not be read, check the file permissions.
+CLI.warn.noProject = No filename was specified with the project option.
+
+# Non-action GUI Localization
mainFrame.title = ${Application.title} ${Application.version}
-mainFrame.icon = mainFrameIcon.png
+mainFrame.iconImage = mainFrameIcon.png
helpMenu.text = &Help
banners.error = errorBanner.png
banners.exit = exitBanner.png
+# Action Localizations
+
quit.Action.smallIcon = quit.png
quit.dialog.message = Are you sure that you want to quit?
quit.dialog.title = Confirm Quit
@@ -73,3 +81,8 @@
displayLicense.Action.text = Show &License
displayLicense.Action.shortDescription = Show the license in the default browser
displayLicense.Action.smallIcon = displayLicense.png
+
+# Other Log Messages
+error.shutdown = Exception caught during shut down sequence.
+info.appStarted = ${Application.title} ${Application.version} started.
+info.appStopped = ${Application.title} ${Application.version} stopped.
Deleted: trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -1,140 +0,0 @@
-/*
- * Class: StartRvSnooper
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2002-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rvsnoop.Application;
-import org.rvsnoop.Project;
-import org.rvsnoop.ui.MainFrame;
-import org.rvsnoop.ui.RvSnoopApplication;
-
-import rvsnoop.ui.MultiLineToolTipUI;
-
-/**
- * Starts an instance of RvSnoop.
- * <p>
- * This is just a collection of bootstrap methods to ensure that the environment
- * is suitable and parse the command line arguments.
- * <p>
- * Based on <a href="http://wiki.apache.org/logging-log4j/LogFactor5">Log Factor
- * 5</a>.
- *
- * @author <a href="mailto:lun...@ho...">Örjan Lundberg</a>
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- */
-public final class StartRvSnooper {
-
- private static class CreateAndShowTask implements Runnable {
- private final Application application;
-
- public CreateAndShowTask(Application application) {
- this.application = application;
- }
-
- public void run() {
- // FIXME this is a hack, there should be no static field.
- MainFrame.INSTANCE = application.getFrame();
- }
- }
-
- private static class ShutdownHookTask implements Runnable {
- ShutdownHookTask() {
- super();
- }
- public void run() {
- if (log.isInfoEnabled()) {
- log.info(Version.getAsStringWithName() + " stopped.");
- }
- }
- }
-
- private static final Log log = LogFactory.getLog(StartRvSnooper.class);
-
- private static void handleHelpOption(final Options options) {
- new HelpFormatter().printHelp("rvsnoop", options);
- System.exit(0);
- }
-
- private static void handleProjectOption(String project, Application application) {
- final File file = new File(project);
- if (file.canRead()) {
- if (log.isInfoEnabled()) {
- log.info("Loading project from " + project);
- }
- try {
- application.setProject(new Project(file));
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Error reading project from " + project, e);
- }
- }
- } else if (log.isErrorEnabled()) {
- if (file.exists()) {
- log.error("The project could not be read from " + project);
- } else {
- log.error("No project could be found at " + project);
- }
- }
- }
-
- /**
- * The application entry point.
- *
- * @param args The command line arguments.
- */
- public static void main(final String[] args) throws Exception {
- if (log.isInfoEnabled()) {
- log.info(Version.getAsStringWithName() + " started.");
- }
- MultiLineToolTipUI.configure();
- if (!SystemUtils.isJavaVersionAtLeast(142)) {
- Object message = new String[] {
- "Java 1.4.2 or later is required to run " + Version.getAsStringWithName(),
- "Please rerun using a supported Java version."
- };
- JOptionPane.showMessageDialog(null, message, "Error!", JOptionPane.ERROR_MESSAGE);
- }
- final Application application = new Application();
- SwingUtilities.invokeAndWait(new CreateAndShowTask(application));
- final Options options = new Options();
- options.addOption("h", "help", false, "Display a short help message then exit.");
- options.addOption("p", "project", true, "Load a project file on startup.");
- try {
- final CommandLine commands = new PosixParser().parse(options, args);
- if (commands.hasOption("h")) { handleHelpOption(options); }
- if (commands.hasOption("p")) {
- handleProjectOption(commands.getOptionValue("p"), application);
- }
- } catch (ParseException e) {
- new HelpFormatter().printHelp("rvsnoop", options);
- System.exit(-1);
- }
- org.jdesktop.application.Application.launch(RvSnoopApplication.class, args);
- Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHookTask(), "shutdownHook"));
- }
-
- /** Do not instantiate. */
- private StartRvSnooper() {
- throw new UnsupportedOperationException();
- }
-
-}
Modified: trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
===================================================================
--- trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-07-25 22:11:37 UTC (rev 404)
+++ trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java 2008-07-25 22:19:37 UTC (rev 405)
@@ -70,7 +70,7 @@
// hack. Do the same for RecordStream (or refactor RecordSelection).
@Override
public void setUp() throws IOException {
- connections = new Connections(null, true);
+ connections = new Connections(null);
ledger = createRecordLedger();
final InputStream stream =
new BufferedInputStream(ClassLoader.getSystemResource(TEST_DATA).openStream());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-25 22:11:38
|
Revision: 404
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=404&view=rev
Author: ianp
Date: 2008-07-25 22:11:37 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Added dependency on Log4J.
Added Paths:
-----------
trunk/rvsn00p/lib/apache-log4j-1.2.15-doc.zip
trunk/rvsn00p/lib/apache-log4j-1.2.15-src.zip
trunk/rvsn00p/lib/apache-log4j-1.2.15.jar
Property changes on: trunk/rvsn00p/lib/apache-log4j-1.2.15-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/apache-log4j-1.2.15-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/apache-log4j-1.2.15.jar
___________________________________________________________________
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: <ia...@us...> - 2008-07-25 18:25:47
|
Revision: 403
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=403&view=rev
Author: ianp
Date: 2008-07-25 18:25:42 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Added JSR-296 application class and altered launch sequence to use it.
Fix for changed popup listener behaviour in recent Mac versions of Java.
Moved code for the help menu into the new application class and altered
it to use the JSR-296 action framework. Several discrete action classes
were rmoved as a result of this.
Modified Paths:
--------------
trunk/rvsn00p/build.xml
trunk/rvsn00p/src/main/org/rvsnoop/Application.java
trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
trunk/rvsn00p/src/main/org/rvsnoop/Project.java
trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/main/org/rvsnoop/XMLBuilder.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java
trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
Added Paths:
-----------
trunk/rvsn00p/lib/swing-worker-snapshot-20080725-doc.zip
trunk/rvsn00p/lib/swing-worker-snapshot-20080725-src.zip
trunk/rvsn00p/lib/swing-worker-snapshot-20080725.jar
trunk/rvsn00p/src/main/org/rvsnoop/ui/CheckForUpdatesTask.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/checkForUpdates.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayAbout.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayHelp.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayHomePage.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayLicense.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/errorBanner.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/exitBanner.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/mainFrameIcon.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/quit.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/updateAvailable.png
trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/updateNotAvailable.png
Removed Paths:
-------------
trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.properties
trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.properties
trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.properties
trunk/rvsn00p/src/main/rvsnoop/actions/DisplayLicense.java
trunk/rvsn00p/src/main/rvsnoop/actions/Help.java
trunk/rvsn00p/src/main/rvsnoop/actions/SubscribeToUpdates.java
trunk/rvsn00p/src/resources/banners/quit.png
trunk/rvsn00p/src/resources/banners/updateAvailable.png
trunk/rvsn00p/src/resources/banners/updateNotAvailable.png
trunk/rvsn00p/src/resources/icons/checkForUpdates.png
trunk/rvsn00p/src/resources/icons/displayAbout.png
trunk/rvsn00p/src/resources/icons/license.png
trunk/rvsn00p/src/resources/icons/quit.png
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/build.xml 2008-07-25 18:25:42 UTC (rev 403)
@@ -33,8 +33,8 @@
<property name="lib.tibsdk" value="/opt/tibco/tra/5.5/lib/TIBCOrt.jar"/>
<!-- These are only used to run the analytics target. -->
- <property name="lib.findbugs" value="${user.home}/Library/Java/findbugs-1.3.0"/>
- <property name="lib.pmd" value="${user.home}/Library/Java/pmd-4.1rc1"/>
+ <property name="lib.findbugs" value="${user.home}/Library/Java/findbugs-1.3.4"/>
+ <property name="lib.pmd" value="${user.home}/Library/Java/pmd-4.2.2"/>
<fileset id="include.classpath" dir="lib">
<include name="*.jar"/>
Property changes on: trunk/rvsn00p/lib/swing-worker-snapshot-20080725-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/swing-worker-snapshot-20080725-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/swing-worker-snapshot-20080725.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -18,6 +18,7 @@
import org.rvsnoop.ui.MainFrame;
import org.rvsnoop.ui.RecordLedgerTable;
+import rvsnoop.MessageLedger;
import rvsnoop.RecordTypes;
import rvsnoop.RvConnection;
import rvsnoop.SubjectHierarchy;
@@ -155,6 +156,7 @@
public synchronized RecordLedger getLedger() {
if (ledger == null) {
ledger = new InMemoryLedger();
+ MessageLedger.RECORD_LEDGER = ledger;
}
return ledger;
}
@@ -232,11 +234,13 @@
if (this.project != null) {
ledger.syncronize();
ledger = null;
+ MessageLedger.RECORD_LEDGER = null;
filteredLedger = null;
}
this.project = project;
// TODO configure the ledger from data in the project file.
ledger = new InMemoryLedger();
+ MessageLedger.RECORD_LEDGER = ledger;
filteredLedger = FilteredLedgerView.newInstance(ledger, false);
getConnections().clear();
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -288,11 +288,10 @@
}
}
- public void toXML(OutputStream stream) throws IOException {
+ public static void toXML(RvConnection[] connections, OutputStream stream) throws IOException {
final XMLBuilder builder = new XMLBuilder(stream, XMLBuilder.NS_CONNECTIONS)
.namespace(XMLBuilder.PREFIX_RENDEZVOUS, XMLBuilder.NS_RENDEZVOUS)
.startTag("connections", XMLBuilder.NS_CONNECTIONS);
- final RvConnection[] connections = toArray();
for (int i = 0, imax = connections.length; i < imax; ++i) {
connections[i].toXML(builder);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Project.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -156,7 +156,7 @@
final File file = new File(projectDirectory, "Connections.xml");
final OutputStream stream = new FileOutputStream(file);
try {
- connections.toXML(stream);
+ Connections.toXML(connections.toArray(), stream);
} finally {
IOUtils.closeQuietly(stream);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -360,7 +360,7 @@
FileOutputStream stream = null;
try {
stream = new FileOutputStream(recentConnectionsFile);
- new Connections(recentConnections, false).toXML(stream);
+ Connections.toXML(recentConnections.toArray(new RvConnection[0]), stream);
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error(ERROR_STORING_CONNECTIONS, e);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/XMLBuilder.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/XMLBuilder.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/XMLBuilder.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -40,6 +40,7 @@
private final String namespace;
+ // URIs -> prefixes
private final Map namespaces = new LinkedHashMap();
private boolean started;
@@ -127,7 +128,7 @@
public XMLBuilder namespace(String prefix, String uri) {
if (started) { throw new IllegalStateException(); }
- namespaces.put(prefix, uri);
+ namespaces.put(uri, prefix);
return this;
}
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,97 +0,0 @@
-/*
- * Class: CheckForUpdates
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package org.rvsnoop.actions;
-
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-import nu.xom.Builder;
-import nu.xom.Document;
-import nu.xom.ParsingException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rvsnoop.Application;
-import org.rvsnoop.NLSUtils;
-import org.rvsnoop.ui.ImageFactory;
-
-import rvsnoop.Version;
-
-/**
- * Check for updates.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.4
- */
-public final class CheckForUpdates extends RvSnoopAction {
-
- static { NLSUtils.internationalize(CheckForUpdates.class); }
-
- private static final long serialVersionUID = -2631302391392386708L;
-
- public static final String COMMAND = "checkForUpdates";
- static String MNEMONIC, NAME, TOOLTIP;
- static String ERROR_IO, ERROR_PARSE, MESSAGE_NEW_VERSION, MESSAGE_UP_TO_DATE;
-
- private static final String ICON_ERROR = "error";
- private static final String ICON_NEW_VERSION = "updateAvailable";
- private static final String ICON_UP_TO_DATE = "updateNotAvailable";
-
- private static final Log log = LogFactory.getLog(CheckForUpdates.class);
-
- public CheckForUpdates(Application application) {
- super(NAME, application);
- putValue(Action.ACTION_COMMAND_KEY, COMMAND);
- putSmallIconValue(COMMAND);
- putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putMnemonicValue(MNEMONIC);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- @Override
- public void actionPerformed(ActionEvent event) {
- final JFrame frame = application.getFrame();
- try {
- final Document doc = new Builder().build("http://rvsnoop.org/version.xml");
- if (!isVersionCurrent(doc)) {
- final Icon icon = new ImageIcon(ImageFactory.getInstance().getBannerImage(ICON_NEW_VERSION));
- JOptionPane.showMessageDialog(frame, MESSAGE_NEW_VERSION, NAME, JOptionPane.INFORMATION_MESSAGE, icon);
- } else {
- final Icon icon = new ImageIcon(ImageFactory.getInstance().getBannerImage(ICON_UP_TO_DATE));
- JOptionPane.showMessageDialog(frame, MESSAGE_UP_TO_DATE, NAME, JOptionPane.INFORMATION_MESSAGE, icon);
- }
- } catch (ParsingException e) {
- final Icon icon = new ImageIcon(ImageFactory.getInstance().getBannerImage(ICON_ERROR));
- JOptionPane.showMessageDialog(frame, ERROR_PARSE, NAME, JOptionPane.ERROR_MESSAGE, icon);
- if (log.isErrorEnabled()) { log.error(ERROR_PARSE, e); }
- } catch (IOException e) {
- final Icon icon = new ImageIcon(ImageFactory.getInstance().getBannerImage(ICON_ERROR));
- JOptionPane.showMessageDialog(frame, ERROR_IO, NAME, JOptionPane.ERROR_MESSAGE, icon);
- if (log.isErrorEnabled()) { log.error(ERROR_IO, e); }
- }
- }
-
- private static boolean isVersionCurrent(Document doc) {
- final int major = Integer.parseInt(doc.query("//major").get(0).getValue());
- if (major > Version.getMajor()) return false;
- final int minor = Integer.parseInt(doc.query("//patch").get(0).getValue());
- if (minor > Version.getMinor()) return false;
- final int patch = Integer.parseInt(doc.query("//patch").get(0).getValue());
- return patch <= Version.getPatch();
- }
-
-}
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.properties 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.properties 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,8 +0,0 @@
-# 0x55 == KeyEvent.VK_U
-MNEMONIC=0x55
-NAME=Check For Updates
-TOOLTIP=Check for newer versions of RvSnoop (stable versions only)
-ERROR_IO=The version check could not be completed because of a problem communicating with the server.
-ERROR_PARSE=The version check could not be completed because of a bad response from the server.
-MESSAGE_NEW_VERSION=A new version is available.
-MESSAGE_UP_TO_DATE=Your version is up to date.
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,74 +0,0 @@
-/*
- * Class: DisplayAbout
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package org.rvsnoop.actions;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.Action;
-import javax.swing.JOptionPane;
-
-import org.rvsnoop.Application;
-import org.rvsnoop.NLSUtils;
-
-import rvsnoop.Version;
-
-/**
- * Display the about dialog.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.4
- */
-public final class DisplayAbout extends RvSnoopAction {
-
- static { NLSUtils.internationalize(DisplayAbout.class); }
-
- private static final long serialVersionUID = -7216295133474774451L;
-
- public static final String COMMAND = "displayAbout";
- static String MNEMONIC, NAME, TOOLTIP;
-
- public DisplayAbout(Application application) {
- super(NAME, application);
- putValue(Action.ACTION_COMMAND_KEY, COMMAND);
- putSmallIconValue(COMMAND);
- putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putMnemonicValue(MNEMONIC);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- @Override
- public void actionPerformed(ActionEvent event) {
- // TODO add a real about dialog
- JOptionPane.showMessageDialog(
- application.getFrame(),
- new String[] { Version.getAsStringWithName(),
- " ",
- "Constructed by Örjan Lundberg (lun...@ho...)",
- "and Ian Phillips (ia...@ia...)",
- " ",
- "This product includes software developed by",
- "The Apache Software Foundation (http://www.apache.org).",
- " ",
- "Thanks goes to (in no special order):",
- "\tEric Albert, Stefan Axelsson, Thomas Bonderud,",
- "\tStefan Farestam, Johan Hjort, Joe Jensen",
- "\tMagnus L Johansson, Anders Lindlof, Linda Lundberg",
- "\tStephanie Lundberg, Cedric Rouvrais, and Richard Valk.",
- " ",
- "Copyright © 2002-2007 Ian Phillips and Örjan Lundberg.",
- " ",
- "Licensed under the Apache Software License (Version 2.0).",
- "\tA copy of the license has been included with this",
- "\tdistribution in the file doc/license.html." },
- NAME, JOptionPane.PLAIN_MESSAGE);
- }
-
-}
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.properties 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.properties 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,4 +0,0 @@
-# 0x41 == KeyEvent.VK_A
-MNEMONIC=0x41
-NAME=About
-TOOLTIP=Show some general information about RvSnoop
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,64 +0,0 @@
-/*
- * Class: Quit
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package org.rvsnoop.actions;
-
-import java.awt.Image;
-import java.awt.event.ActionEvent;
-
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-import org.rvsnoop.Application;
-import org.rvsnoop.NLSUtils;
-import org.rvsnoop.ui.ImageFactory;
-
-/**
- * Quit the application.
- * <p>
- * Prompt the user for confirmation before quitting.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- */
-public final class Quit extends RvSnoopAction {
-
- static { NLSUtils.internationalize(Quit.class); }
-
- private static final long serialVersionUID = 4723433926433208758L;
-
- public static final String COMMAND = "quit";
- static String ACCELERATOR, CONFIRM_QUESTION, CONFIRM_TITLE, MNEMONIC, NAME,
- TOOLTIP;
-
- public Quit(Application application) {
- super(NAME, application);
- putValue(Action.ACTION_COMMAND_KEY, COMMAND);
- putSmallIconValue(COMMAND);
- putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putMnemonicValue(MNEMONIC);
- putAcceleratorValue(ACCELERATOR);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- @Override
- public void actionPerformed(ActionEvent event) {
- final JFrame frame = application.getFrame();
- final Image banner = ImageFactory.getInstance().getBannerImage(COMMAND);
- int option = JOptionPane.showConfirmDialog(frame,
- CONFIRM_QUESTION, CONFIRM_TITLE, JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE, new ImageIcon(banner));
- if (option != JOptionPane.YES_OPTION) { return; }
- frame.dispose();
- application.shutdown();
- }
-
-}
Deleted: trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.properties 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.properties 2008-07-25 18:25:42 UTC (rev 403)
@@ -1,7 +0,0 @@
-# 0x51 == KeyEvent.VK_Q
-ACCELERATOR=0x51
-CONFIRM_QUESTION=Are you sure that you want to quit?
-CONFIRM_TITLE=Confirm Quit
-MNEMONIC=0x51
-NAME=Quit
-TOOLTIP=Close all listeners and exit RvSnoop
Copied: trunk/rvsn00p/src/main/org/rvsnoop/ui/CheckForUpdatesTask.java (from rev 396, trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java)
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/CheckForUpdatesTask.java (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/CheckForUpdatesTask.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -0,0 +1,91 @@
+/*
+ * Class: CheckForUpdates
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.io.IOException;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+
+import nu.xom.Builder;
+import nu.xom.Document;
+import nu.xom.ParsingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.application.Application;
+import org.jdesktop.application.ResourceMap;
+import org.jdesktop.application.SingleFrameApplication;
+import org.jdesktop.application.Task;
+
+import rvsnoop.Version;
+
+/**
+ * Check for updates.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class CheckForUpdatesTask extends Task<Boolean, Void> {
+
+ private static final Log log = LogFactory.getLog(CheckForUpdatesTask.class);
+
+ public CheckForUpdatesTask(Application application) {
+ super(application);
+ // XOM doesn't provide us with a way to cancel this.
+ setUserCanCancel(false);
+ }
+
+ @Override
+ protected Boolean doInBackground() throws IOException, ParsingException {
+ // Return true if version is current, false if out of date.
+ final Document doc = new Builder().build("http://rvsnoop.org/version.xml");
+ final int major = Integer.parseInt(doc.query("//major").get(0).getValue());
+ if (major > Version.getMajor()) return false;
+ final int minor = Integer.parseInt(doc.query("//patch").get(0).getValue());
+ if (minor > Version.getMinor()) return false;
+ final int patch = Integer.parseInt(doc.query("//patch").get(0).getValue());
+ return patch <= Version.getPatch();
+ }
+
+ @Override
+ protected void failed(Throwable e) {
+ JFrame frame = ((SingleFrameApplication) getApplication()).getMainFrame();
+ ResourceMap resourceMap = getContext().getResourceMap();
+ String message = e instanceof ParsingException
+ ? resourceMap.getString("checkForUpdates.error.parse")
+ : resourceMap.getString("checkForUpdates.error.io");
+ JOptionPane.showMessageDialog(frame,
+ message,
+ resourceMap.getString("checkForUpdates.Action.text"),
+ JOptionPane.ERROR_MESSAGE,
+ resourceMap.getIcon("banners.error"));
+ if (log.isErrorEnabled()) { log.error(message, e); }
+ }
+
+ @Override
+ protected void succeeded(Boolean current) {
+ JFrame frame = ((SingleFrameApplication) getApplication()).getMainFrame();
+ ResourceMap resourceMap = getContext().getResourceMap();
+ if (current) {
+ JOptionPane.showMessageDialog(frame,
+ resourceMap.getString("checkForUpdates.info.upToDate"),
+ resourceMap.getString("checkForUpdates.Action.text"),
+ JOptionPane.INFORMATION_MESSAGE,
+ resourceMap.getIcon("checkForUpdates.icon.upToDate"));
+ } else {
+ JOptionPane.showMessageDialog(frame,
+ resourceMap.getString("checkForUpdates.info.outOfDate"),
+ resourceMap.getString("checkForUpdates.Action.text"),
+ JOptionPane.INFORMATION_MESSAGE,
+ resourceMap.getIcon("checkForUpdates.icon.outOfDate"));
+ }
+ }
+
+}
Property changes on: trunk/rvsn00p/src/main/org/rvsnoop/ui/CheckForUpdatesTask.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/ConnectionList.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/ConnectionList.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/ConnectionList.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -75,6 +75,7 @@
final ConnectionListCellRenderer renderer =
new ConnectionListCellRenderer(hidingDefaultValues);
final PopupListener popupListener = new PopupListener();
+ addMouseListener(popupListener);
renderer.addMouseListener(popupListener);
popupMenu.addPopupMenuListener(popupListener);
setCellRenderer(renderer);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java 2008-07-25 12:07:30 UTC (rev 402)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -13,8 +13,6 @@
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;
@@ -33,27 +31,22 @@
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.ListSelectionModel;
-import javax.swing.MenuElement;
import javax.swing.ScrollPaneConstants;
import javax.swing.ToolTipManager;
-import javax.swing.WindowConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeModelEvent;
import javax.swing.tree.TreeNode;
-import org.apache.commons.lang.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.Application;
import org.rvsnoop.RecordLedger;
import org.rvsnoop.UserPreferences;
-import org.rvsnoop.actions.CheckForUpdates;
import org.rvsnoop.actions.ClearLedger;
import org.rvsnoop.actions.Copy;
import org.rvsnoop.actions.Cut;
import org.rvsnoop.actions.Delete;
-import org.rvsnoop.actions.DisplayAbout;
import org.rvsnoop.actions.EditRecordTypes;
import org.rvsnoop.actions.Filter;
import org.rvsnoop.actions.FilterBySelection;
@@ -61,7 +54,6 @@
import org.rvsnoop.actions.OpenProject;
import org.rvsnoop.actions.Paste;
import org.rvsnoop.actions.PruneEmptySubjects;
-import org.rvsnoop.actions.Quit;
import org.rvsnoop.actions.Republish;
import org.rvsnoop.actions.SaveProject;
import org.rvsnoop.actions.SaveProjectAs;
@@ -81,7 +73,6 @@
import rvsnoop.Record;
import rvsnoop.TreeModelAdapter;
-import rvsnoop.Version;
import rvsnoop.actions.Actions;
import rvsnoop.actions.ExportToHtml;
import rvsnoop.actions.ExportToRecordBundle;
@@ -145,16 +136,6 @@
}
- private final class WindowCloseListener extends WindowAdapter {
- WindowCloseListener() {
- super();
- }
- @Override
- public void windowClosing(WindowEvent e) {
- application.shutdown();
- }
- }
-
private static final long serialVersionUID = 4315311340452405694L;
private static final String TOOLTIP_VISIBLE_COLUMNS = "Show or hide individual table columns";
@@ -183,7 +164,7 @@
private final StatusBar statusBar;
public MainFrame(final Application application) {
- super(Version.getAsStringWithName());
+ setName("mainFrame");
this.application = application;
final UserPreferences state = UserPreferences.getInstance();
statusBar = new StatusBar(application);
@@ -197,8 +178,6 @@
messageLedgerSplitter = createMessageLedgerSplitter(messageLedgerScroller, detailsPanel);
subjectExplorerSplitter = createSubjectExplorerSplitter(subjectExplorerScroller, messageLedgerSplitter);
connectionListSplitter = createConnectionListSplitter(connectionListScroller, subjectExplorerSplitter);
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- setIconImage(ImageFactory.getInstance().getIconImage("rvsnoop"));
final Actions factory = application.getActionFactory();
setJMenuBar(createMenuBar(messageLedger, factory));
getContentPane().add(connectionListSplitter, BorderLayout.CENTER);
@@ -233,7 +212,6 @@
messageLedgerSelectionModel.addListSelectionListener((ListSelectionListener) action);
}
}
- addWindowListener(new WindowCloseListener());
UserPreferences.getInstance().addPreferenceChangeListener(new FontChangeListener());
}
@@ -305,35 +283,17 @@
connRecent.setIcon(Icons.ADD_CONNECTION);
connRecent.addMenuListener(new RecentConnectionsMenuManager(application));
file.add(connRecent);
- file.addSeparator();
- file.add(factory.getAction(Quit.COMMAND));
+// file.addSeparator();
+// file.add(factory.getAction(Quit.COMMAND));
return file;
}
- private JMenu createHelpMenu(final Actions factory) {
- final JMenu help = new JMenu("Help");
- help.setMnemonic('h');
- help.add(Actions.HELP);
- help.add(Actions.DISPLAY_HOME_PAGE);
- help.add(Actions.REPORT_BUG);
- help.add(factory.getAction(CheckForUpdates.COMMAND));
- help.add(Actions.SUBSCRIBE_TO_UPDATES);
- help.addSeparator();
- help.add(Actions.DISPLAY_LICENSE);
- help.add(factory.getAction(DisplayAbout.COMMAND));
- return help;
- }
-
private JMenuBar createMenuBar(RecordLedgerTable table, Actions factory) {
final JMenuBar bar = new JMenuBar();
bar.add(createFileMenu(factory));
bar.add(createEditMenu(factory));
bar.add(createViewMenu(factory, table));
bar.add(createConfigureMenu());
- bar.add(createHelpMenu(factory));
- // Mac OS X screen menu bars do not normally show icons.
- if (SystemUtils.IS_OS_MAC_OSX)
- removeIconsFromMenuElements(bar);
return bar;
}
@@ -466,13 +426,4 @@
return subjectExplorer;
}
- private void removeIconsFromMenuElements(MenuElement elt) {
- if (elt instanceof AbstractButton)
- ((AbstractButton) elt).setIcon(null);
- final MenuElement[] elts = elt.getSubElements();
- for (int i = 0, imax = elts.length; i < imax; ++i) {
- removeIconsFromMenuElements(elts[i]);
- }
- }
-
}
Added: trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RvSnoopApplication.java 2008-07-25 18:25:42 UTC (rev 403)
@@ -0,0 +1,190 @@
+/*
+ * Class: RvSnoopApplication
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2008 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+
+package org.rvsnoop.ui;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.util.EventObject;
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JOptionPane;
+import javax.swing.WindowConstants;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.application.Action;
+import org.jdesktop.application.ApplicationActionMap;
+import org.jdesktop.application.ApplicationContext;
+import org.jdesktop.application.ResourceMap;
+import org.jdesktop.application.SingleFrameApplication;
+import org.jdesktop.application.Task.BlockingScope;
+import org.rvsnoop.Application;
+
+import rvsnoop.BrowserLauncher;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * The main UI class for RvSnoop.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class RvSnoopApplication extends SingleFrameApplication {
+
+ private static final Log logger = LogFactory.getLog(RvSnoopApplication.class);
+
+ private Injector injector;
+
+ @Action(block=BlockingScope.ACTION)
+ public CheckForUpdatesTask checkForUpdates() {
+ return new CheckForUpdatesTask(this);
+ }
+
+ private JMenu createHelpMenu() {
+ JMenu helpMenu = new JMenu();
+ helpMenu.setName("helpMenu");
+ getContext().getResourceMap().injectComponent(helpMenu);
+ ApplicationActionMap actionMap = getContext().getActionMap();
+ helpMenu.add(actionMap.get("displayHelp"));
+ helpMenu.add(actionMap.get("displayHomePage"));
+ helpMenu.add(actionMap.get("displayBugsPage"));
+ helpMenu.addSeparator();
+ helpMenu.add(actionMap.get("checkForUpdates"));
+ helpMenu.addSeparator();
+ helpMenu.add(actionMap.get("displayLicense"));
+ helpMenu.add(actionMap.get("displayAbout"));
+ return helpMenu;
+ }
+
+ @Action
+ public void displayAbout() {
+ ResourceMap resourceMap = getContext().getResourceMap();
+ JOptionPane.showMessageDialog(
+ getMainFrame(),
+ resourceMap.getString("displayAbout.info.message"),
+ resourceMap.getString("displayAbout.info.title"),
+ JOptionPane.PLAIN_MESSAGE);
+ }
+
+ @Action
+ public void displayBugsPage() {
+ try {
+ BrowserLauncher.openURL("http://sourceforge.net/tracker/?group_id=63447");
+ } catch (Exception e) {
+ if (logger.isErrorEnabled()) {
+ logger.error(getContext().getResourceMap().getString("displayBugsPage.error.browser"), e);
+ }
+ }
+ }
+
+ private void displayDocPage(String filename) {
+ try {
+ final File home = new File(System.getProperty("rvsnoop.home"));
+ final File docs = new File(home, "doc");
+ final File help = new File(docs, filename);
+ final String prefix = System.getProperty("os.name").startsWith("Win")
+ ? "" : "file://";
+ BrowserLauncher.openURL(prefix + help.getAbsolutePath());
+ } catch (Exception e) {
+ if (logger.isErrorEnabled()) {
+ logger.error(getContext().getResourceMap().getString("displayHelp.error.browser"), e);
+ }
+ }
+ }
+
+ @Action
+ public void displayHelp() {
+ displayDocPage("index.html");
+ }
+
+ @Action
+ public void displayHomePage() {
+ try {
+ BrowserLauncher.openURL("http://rvsn00p.sourceforge.net");
+ } catch (Exception e) {
+ if (logger.isErrorEnabled()) {
+ logger.error(getContext().getResourceMap().getString("displayHomePage.error.browser"), e);
+ }
+ }
+ }
+
+ @Action
+ public void displayLicense() {
+ displayDocPage("license.html");
+ }
+
+ @Override
+ protected void initialize(String[] args) {
+ injector = Guice.createInjector(new GuiModule());
+ injector.injectMembers(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jdesktop.application.Application#startup()
+ */
+ @Override
+ protected void startup() {
+ setMainFrame(MainFrame.INSTANCE);
+
+ final JFrame frame = getMainFrame();
+ frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ frame.addWindowListener(new FrameClosingListener());
+ addExitListener(new MaybeExit());
+
+ ApplicationActionMap actionMap = getContext().getActionMap();
+ JMenu fileMenu = frame.getJMenuBar().getMenu(0);
+ fileMenu.addSeparator();
+ fileMenu.add(actionMap.get("quit"));
+
+ frame.getJMenuBar().add(createHelpMenu());
+ getContext().getResourceMap().injectComponents(frame);
+
+ show(frame);
+ }
+
+ private class FrameClosingListener extends WindowAdapter {
+ @Override
+ public void windowClosing(WindowEvent event) {
+ exit(event);
+ }
+ }
+
+ private class GuiModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(Application.class).toInstance(new Application());
+ bind(ApplicationContext.class).toInstance(getContext());
+ }
+
+ }
+
+ private class MaybeExit implements ExitListener {
+ public boolean canExit(EventObject event) {
+ ResourceMap resourceMap = getContext().getResourceMap();
+ int option = JOptionPane.showConfirmDialog(getMainFrame(),
+ resourceMap.getString("quit.dialog.message"),
+ resourceMap.getString("quit.dialog.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ resourceMap.getIcon("banners.exit"));
+ return option == JOptionPane.YES_OPTION;
+ }
+
+ public void willExit(EventObject event) {
+ injector.getInstance(Application.class).shutdown();
+ }
+ }
+
+}
Property changes on: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/RvSnoopApplication.properties 2008-07-25 18:25:42 UTC (rev 403)
@@ -0,0 +1,75 @@
+# "Standard" application resources
+Application.id = org.rvsnoop
+Application.title = RvSnoop
+Application.version = 1.6.2
+Application.vendor = Ian Phillips
+Application.vendorId = org.rvsnoop
+Application.homepage = http://rvsnoop.org
+Application.description = A Rendezvous message viewing utility.
+
+# The resources below are "injected" at startup time, just
+# before the mainFrame is packed, with:
+# appContext.getResourceMap(getClass()).injectComponents(mainFrame);
+mainFrame.title = ${Application.title} ${Application.version}
+mainFrame.icon = mainFrameIcon.png
+
+helpMenu.text = &Help
+
+banners.error = errorBanner.png
+banners.exit = exitBanner.png
+
+quit.Action.smallIcon = quit.png
+quit.dialog.message = Are you sure that you want to quit?
+quit.dialog.title = Confirm Quit
+
+checkForUpdates.Action.text = Check for Updates
+checkForUpdates.Action.shortDescription = Check for newer versions of RvSnoop (stable versions only)
+checkForUpdates.Action.smallIcon = checkForUpdates.png
+checkForUpdates.error.io = The version check could not be completed because of a problem communicating with the server.
+checkForUpdates.error.parse = The version check could not be completed because of a bad response from the server.
+checkForUpdates.info.upToDate = Your version is up to date.
+checkForUpdates.info.outOfDate = A new version is available.
+checkForUpdates.icon.upToDate = updateNotAvailable.png
+checkForUpdates.icon.outOfDate = updateAvailable.png
+
+displayAbout.Action.text = &About
+displayAbout.Action.shortDescription = Show some general information about RvSnoop
+displayAbout.Action.smallIcon = displayAbout.png
+displayAbout.info.title = About RvSnoop
+displayAbout.info.message = <HTML>\
+<H3>${Application.title} ${Application.version}</H3>\
+Constructed by \xD6rjan Lundberg (lun...@ho...)<BR>\
+and Ian Phillips (ia...@ia...).\
+<BR><BR>\
+This product includes software developed by the<BR>\
+Apache Software Foundation (http://www.apache.org).\
+<BR><BR>\
+Thanks goes to:<BR>\
+ Eric Albert, Stefan Axelsson, Thomas Bonderud, Stefan Farestam,<BR>\
+ Johan Hjort, Joe Jensen, Magnus L Johansson, Anders Lindlof,<BR>\
+ Linda Lundberg, Stephanie Lundberg, Cedric Rouvrais, and Richard Valk.\
+<BR><BR>\
+Copyright \xA9 2002-2008 Ian Phillips and \xD6rjan Lundberg.\
+<BR><BR>\
+Licensed under the Apache Software License (Version 2.0).<BR>\
+A copy of the license has been included<BR>\
+with this distribution in the file doc/license.html.
+
+displayBugsPage.Action.text = Report &Bug
+displayBugsPage.Action.shortDescription = Report a bug or request a new feature
+displayBugsPage.Action.smallIcon = displayHomePage.png
+displayBugsPage.error.browser = The default browser could not be opened.
+
+displayHelp.Action.text = Help &Contents
+displayHelp.Action.shortDescription = Show the help files in the default browser
+displayHelp.Action.smallIcon = displayHelp.png
+displayHelp.error.browser = The default browser could not be opened.
+
+displayHomePage.Action.text = Show &Web Site
+displayHomePage.Action.shortDescription = Show the RvSnoop web site in the default browser
+displayHomePage.Action.smallIcon = displayHomePage.png
+displayHomePage.error.browser = The default browser could not be opened.
+
+displayLicense.Action.text = Show &License
+displayLicense.Action.shortDescription = Show the license in the default browser
+displayLicense.Action.smallIcon = displayLicense.png
Property changes on: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/checkForUpdates.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Property changes on: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayAbout.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Added: trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayHelp.png
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayHelp.png (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/resources/displayHelp.png 2008-07-25 18:25:42 UTC (rev 403)
@@ -0,0 +1,9 @@
+\x89PNG
+
+ |
|
From: <ia...@us...> - 2008-07-25 12:07:32
|
Revision: 402
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=402&view=rev
Author: ianp
Date: 2008-07-25 12:07:30 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Added Guice and Swing Application Framework (JSR-296) libraries.
Added Paths:
-----------
trunk/rvsn00p/lib/app-framework-snapshot-r126-doc.zip
trunk/rvsn00p/lib/app-framework-snapshot-r126-src.zip
trunk/rvsn00p/lib/app-framework-snapshot-r126.jar
trunk/rvsn00p/lib/google-guice-snapshot-r564-doc.zip
trunk/rvsn00p/lib/google-guice-snapshot-r564-src.zip
trunk/rvsn00p/lib/google-guice-snapshot-r564.jar
Property changes on: trunk/rvsn00p/lib/app-framework-snapshot-r126-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/app-framework-snapshot-r126-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/app-framework-snapshot-r126.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/google-guice-snapshot-r564-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/google-guice-snapshot-r564-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/google-guice-snapshot-r564.jar
___________________________________________________________________
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: <ia...@us...> - 2008-07-25 11:55:17
|
Revision: 401
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=401&view=rev
Author: ianp
Date: 2008-07-25 11:55:13 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Renamed UIManager to MainFrame to prevent name conflict with Swing's UIManager class.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/Application.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/SelectAllRecords.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/ShowAllColumns.java
trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java
trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java
trunk/rvsn00p/src/main/rvsnoop/actions/ImportFromFile.java
trunk/rvsn00p/src/main/rvsnoop/ui/RvConnectionDialog.java
trunk/rvsn00p/src/main/rvsnoop/ui/UIUtils.java
Added Paths:
-----------
trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
Removed Paths:
-------------
trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Application.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -15,13 +15,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.actions.RvSnoopAction;
+import org.rvsnoop.ui.MainFrame;
import org.rvsnoop.ui.RecordLedgerTable;
import rvsnoop.RecordTypes;
import rvsnoop.RvConnection;
import rvsnoop.SubjectHierarchy;
import rvsnoop.actions.Actions;
-import rvsnoop.ui.UIManager;
/**
* The main application class.
@@ -51,7 +51,7 @@
private FilteredLedgerView filteredLedger;
/** The main application frame. */
- private UIManager frame;
+ private MainFrame frame;
private RecordLedger ledger;
@@ -136,9 +136,9 @@
/**
* @return the frame
*/
- public synchronized UIManager getFrame() {
+ public synchronized MainFrame getFrame() {
if (frame == null) {
- frame = new UIManager(this);
+ frame = new MainFrame(this);
getActionFactory().configureListeners();
}
return frame;
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -13,9 +13,9 @@
import org.rvsnoop.Application;
import org.rvsnoop.NLSUtils;
+import org.rvsnoop.ui.MainFrame;
import rvsnoop.Record;
-import rvsnoop.ui.UIManager;
/**
* Clear the contents of the record ledger.
@@ -50,7 +50,7 @@
application.getSubjectHierarchy().reset();
Record.resetSequence();
// FIXME this should be replaced with a listener on the ledger.
- UIManager.INSTANCE.clearDetails();
+ MainFrame.INSTANCE.clearDetails();
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/Republish.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/Republish.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/Republish.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -20,11 +20,11 @@
import org.rvsnoop.NLSUtils;
import org.rvsnoop.event.RecordLedgerSelectionEvent;
import org.rvsnoop.event.RecordLedgerSelectionListener;
+import org.rvsnoop.ui.MainFrame;
import rvsnoop.Record;
import rvsnoop.RvConnection;
import rvsnoop.State;
-import rvsnoop.ui.UIManager;
import rvsnoop.ui.UIUtils;
/**
@@ -70,7 +70,7 @@
connectionNames[i] = connections[i].getDescription();
}
final String name = (String) JOptionPane.showInputDialog(
- UIManager.INSTANCE, question, NAME, JOptionPane.QUESTION_MESSAGE,
+ MainFrame.INSTANCE, question, NAME, JOptionPane.QUESTION_MESSAGE,
null, connectionNames, connectionNames[0]);
if (name == null) { return; } // User cancelled republishing.
final RvConnection connection = connections[ArrayUtils.indexOf(connectionNames, name)];
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/SelectAllRecords.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/SelectAllRecords.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/SelectAllRecords.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -15,9 +15,8 @@
import org.rvsnoop.Application;
import org.rvsnoop.NLSUtils;
+import org.rvsnoop.ui.MainFrame;
-import rvsnoop.ui.UIManager;
-
/**
* Select all records in the visible ledger.
*
@@ -48,7 +47,7 @@
*/
@Override
public void actionPerformed(ActionEvent event) {
- final JTable ledger = UIManager.INSTANCE.getRecordLedger();
+ final JTable ledger = MainFrame.INSTANCE.getRecordLedger();
final ListSelectionModel selectionModel = ledger.getSelectionModel();
selectionModel.setSelectionInterval(0, ledger.getRowCount() - 1);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/ShowAllColumns.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/actions/ShowAllColumns.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/ShowAllColumns.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -14,9 +14,8 @@
import org.rvsnoop.Application;
import org.rvsnoop.NLSUtils;
import org.rvsnoop.RecordLedgerFormat;
+import org.rvsnoop.ui.MainFrame;
-import rvsnoop.ui.UIManager;
-
/**
* Show all columns in the message ledger.
*
@@ -47,7 +46,7 @@
*/
@Override
public void actionPerformed(ActionEvent event) {
- UIManager.INSTANCE.getRecordLedger().getTableFormat().setColumns(RecordLedgerFormat.ALL_COLUMNS);
+ MainFrame.INSTANCE.getRecordLedger().getTableFormat().setColumns(RecordLedgerFormat.ALL_COLUMNS);
}
}
Copied: trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java (from rev 396, trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java)
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java (rev 0)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -0,0 +1,478 @@
+/*
+ * Class: UIManager
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2002-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.prefs.PreferenceChangeEvent;
+import java.util.prefs.PreferenceChangeListener;
+
+import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
+import javax.swing.JToolBar;
+import javax.swing.JTree;
+import javax.swing.ListSelectionModel;
+import javax.swing.MenuElement;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.ToolTipManager;
+import javax.swing.WindowConstants;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.tree.TreeNode;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.Application;
+import org.rvsnoop.RecordLedger;
+import org.rvsnoop.UserPreferences;
+import org.rvsnoop.actions.CheckForUpdates;
+import org.rvsnoop.actions.ClearLedger;
+import org.rvsnoop.actions.Copy;
+import org.rvsnoop.actions.Cut;
+import org.rvsnoop.actions.Delete;
+import org.rvsnoop.actions.DisplayAbout;
+import org.rvsnoop.actions.EditRecordTypes;
+import org.rvsnoop.actions.Filter;
+import org.rvsnoop.actions.FilterBySelection;
+import org.rvsnoop.actions.NewRvConnection;
+import org.rvsnoop.actions.OpenProject;
+import org.rvsnoop.actions.Paste;
+import org.rvsnoop.actions.PruneEmptySubjects;
+import org.rvsnoop.actions.Quit;
+import org.rvsnoop.actions.Republish;
+import org.rvsnoop.actions.SaveProject;
+import org.rvsnoop.actions.SaveProjectAs;
+import org.rvsnoop.actions.Search;
+import org.rvsnoop.actions.SearchBySelection;
+import org.rvsnoop.actions.SelectAllRecords;
+import org.rvsnoop.actions.ShowAllColumns;
+import org.rvsnoop.ui.ConnectionList;
+import org.rvsnoop.ui.ImageFactory;
+import org.rvsnoop.ui.RecentConnectionsMenuManager;
+import org.rvsnoop.ui.RecentProjectsMenuManager;
+import org.rvsnoop.ui.RecordLedgerTable;
+import org.rvsnoop.ui.RecordTypesMenuManager;
+import org.rvsnoop.ui.StatusBar;
+import org.rvsnoop.ui.TrackingAdjustmentListener;
+import org.rvsnoop.ui.VisibleColumnsMenuManager;
+
+import rvsnoop.Record;
+import rvsnoop.TreeModelAdapter;
+import rvsnoop.Version;
+import rvsnoop.actions.Actions;
+import rvsnoop.actions.ExportToHtml;
+import rvsnoop.actions.ExportToRecordBundle;
+import rvsnoop.actions.ExportToRvScript;
+import rvsnoop.actions.ExportToRvTest;
+import rvsnoop.ui.Icons;
+import rvsnoop.ui.RvDetailsPanel;
+import rvsnoop.ui.SubjectExplorerEditor;
+import rvsnoop.ui.SubjectExplorerRenderer;
+import rvsnoop.ui.UIUtils;
+
+/**
+ * The single user interface class for the application.
+ *
+ * @author <a href="mailto:lun...@ho...">Örjan Lundberg</a>
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+// Class provides a static instance instead of a factory method.
+// @PMD:REVIEWED:MissingStaticMethodInNonInstantiatableClass: by ianp on 1/17/06 7:58 PM
+public final class MainFrame extends JFrame {
+
+ private final class MessageLedgerListener implements ListSelectionListener {
+ MessageLedgerListener() {
+ super();
+ }
+ public void valueChanged(ListSelectionEvent e) {
+ final Record record = getSelectedRecord();
+ if (record != null) { detailsPanel.setMessage(record); }
+ }
+ }
+
+ private final class TreeExpander extends TreeModelAdapter {
+ private boolean isExpanded;
+ private TreeExpander() {
+ super();
+ }
+ @Override
+ public void treeNodesInserted(TreeModelEvent e) {
+ if (isExpanded) { return; }
+ isExpanded = true;
+ subjectExplorer.expandPath(e.getTreePath());
+ }
+ @Override
+ public void treeNodesRemoved(TreeModelEvent e) {
+ final TreeNode root = (TreeNode) application.getSubjectHierarchy().getRoot();
+ if (root.getChildCount() == 0) { isExpanded = false; }
+ }
+ }
+
+ private final class FontChangeListener implements PreferenceChangeListener {
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (UserPreferences.KEY_LEDGER_FONT.equals(event.getKey())) {
+ final Font font = UserPreferences.getInstance().getLedgerFont();
+ messageLedger.setFont(font);
+ // Without this the default rowNumber height is about 1-million-billion pixels...
+ final int rowHeight = messageLedger.getFontMetrics(font).getHeight() + 2;
+ messageLedger.setRowHeight(rowHeight);
+ }
+ }
+
+ }
+
+ private final class WindowCloseListener extends WindowAdapter {
+ WindowCloseListener() {
+ super();
+ }
+ @Override
+ public void windowClosing(WindowEvent e) {
+ application.shutdown();
+ }
+ }
+
+ private static final long serialVersionUID = 4315311340452405694L;
+
+ private static final String TOOLTIP_VISIBLE_COLUMNS = "Show or hide individual table columns";
+
+ private static final Log log = LogFactory.getLog(MainFrame.class);
+
+ // FIXME: Remove this field.
+ public static MainFrame INSTANCE;
+
+ private final Application application;
+
+ private final JPopupMenu columnsPopup = new JPopupMenu();
+
+ private final ConnectionList connectionList;
+ private final JTree subjectExplorer;
+ private final RvDetailsPanel detailsPanel = new RvDetailsPanel();
+ private final RecordLedgerTable messageLedger;
+ private final JScrollPane connectionListScroller;
+ private final JScrollPane subjectExplorerScroller;
+ private final JScrollPane messageLedgerScroller;
+
+ private final JSplitPane messageLedgerSplitter;
+ private final JSplitPane subjectExplorerSplitter;
+ private final JSplitPane connectionListSplitter;
+
+ private final StatusBar statusBar;
+
+ public MainFrame(final Application application) {
+ super(Version.getAsStringWithName());
+ this.application = application;
+ final UserPreferences state = UserPreferences.getInstance();
+ statusBar = new StatusBar(application);
+ subjectExplorer = createSubjectExplorer();
+ connectionList = new ConnectionList(application);
+ messageLedger = createMessageLedger(application.getFilteredLedger());
+ messageLedger.setFont(state.getLedgerFont());
+ connectionListScroller = createConnectionListScroller(connectionList);
+ subjectExplorerScroller = createSubjectExplorerScroller(subjectExplorer);
+ messageLedgerScroller = createMessageLedgerScroller(messageLedger);
+ messageLedgerSplitter = createMessageLedgerSplitter(messageLedgerScroller, detailsPanel);
+ subjectExplorerSplitter = createSubjectExplorerSplitter(subjectExplorerScroller, messageLedgerSplitter);
+ connectionListSplitter = createConnectionListSplitter(connectionListScroller, subjectExplorerSplitter);
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ setIconImage(ImageFactory.getInstance().getIconImage("rvsnoop"));
+ final Actions factory = application.getActionFactory();
+ setJMenuBar(createMenuBar(messageLedger, factory));
+ getContentPane().add(connectionListSplitter, BorderLayout.CENTER);
+ getContentPane().add(createToolBar(factory), BorderLayout.NORTH);
+ getContentPane().add(statusBar, BorderLayout.SOUTH);
+ pack();
+ setBounds(state.getWindowBounds());
+
+ connectListeners();
+ configureDividerLocation(connectionListSplitter, "connectionList", state);
+ configureDividerLocation(messageLedgerSplitter, "recordLedger", state);
+ configureDividerLocation(subjectExplorerSplitter, "subjectExplorer", state);
+ state.listenToChangesFrom(this, messageLedger, new JSplitPane[] {
+ connectionListSplitter, messageLedgerSplitter, subjectExplorerSplitter });
+ }
+
+ public void clearDetails() {
+ detailsPanel.setMessage(null);
+ }
+
+ private void configureDividerLocation(JSplitPane pane, String name, UserPreferences state) {
+ pane.setName(name);
+ final int location = state.getDividerLocation(name);
+ if (location > 0) { pane.setDividerLocation(location); }
+ }
+
+ private void connectListeners() {
+ final ListSelectionModel messageLedgerSelectionModel = messageLedger.getSelectionModel();
+ messageLedgerSelectionModel.addListSelectionListener(new MessageLedgerListener());
+ for (Object action : Actions.getActions()) {
+ if (action instanceof ListSelectionListener) {
+ messageLedgerSelectionModel.addListSelectionListener((ListSelectionListener) action);
+ }
+ }
+ addWindowListener(new WindowCloseListener());
+ UserPreferences.getInstance().addPreferenceChangeListener(new FontChangeListener());
+ }
+
+ private JMenu createConfigureMenu() {
+ final JMenu configure = new JMenu("Configure");
+ configure.setMnemonic('c');
+ configure.add(Actions.CHANGE_TABLE_FONT);
+ return configure;
+ }
+
+ private JScrollPane createConnectionListScroller(JList listenerList) {
+ final JScrollPane scrollPane = new JScrollPane(listenerList);
+ scrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.GRAY));
+ return scrollPane;
+ }
+
+ private JSplitPane createConnectionListSplitter(JScrollPane connectionList, JSplitPane subjectExplorerSplitter) {
+ final JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, connectionList, subjectExplorerSplitter);
+ splitter.setOneTouchExpandable(false);
+ splitter.setDividerLocation(0.20);
+ splitter.setBorder(BorderFactory.createEmptyBorder());
+ return splitter;
+ }
+
+ private JMenu createEditMenu(final Actions factory) {
+ final JMenu edit = new JMenu("Edit");
+ edit.setMnemonic('e');
+ edit.add(factory.getAction(Cut.COMMAND));
+ edit.add(factory.getAction(Copy.COMMAND));
+ edit.add(factory.getAction(Paste.COMMAND));
+ edit.addSeparator();
+ edit.add(factory.getAction(Search.COMMAND));
+ edit.add(factory.getAction(SearchBySelection.COMMAND));
+ edit.addSeparator();
+ edit.add(factory.getAction(Republish.COMMAND));
+ edit.addSeparator();
+ edit.add(factory.getAction(PruneEmptySubjects.COMMAND));
+ edit.addSeparator();
+ edit.add(factory.getAction(Delete.COMMAND));
+ return edit;
+ }
+
+ private JMenu createFileMenu(final Actions factory) {
+ final ImageFactory images = ImageFactory.getInstance();
+ final JMenu file = new JMenu("File");
+ file.setMnemonic('f');
+ file.add(factory.getAction(OpenProject.COMMAND));
+ final JMenu fileRecent = new JMenu("Recent Projects");
+ fileRecent.setIcon(new ImageIcon(images.getIconImage(OpenProject.COMMAND)));
+ fileRecent.addMenuListener(new RecentProjectsMenuManager(application));
+ file.add(fileRecent);
+ file.addSeparator();
+ file.add(factory.getAction(SaveProject.COMMAND));
+ file.add(factory.getAction(SaveProjectAs.COMMAND));
+ final JMenu fileExport = new JMenu("Export To");
+ fileExport.setIcon(Icons.EXPORT);
+ fileExport.add(factory.getAction(ExportToHtml.COMMAND));
+ fileExport.add(factory.getAction(ExportToRecordBundle.COMMAND));
+ fileExport.add(factory.getAction(ExportToRvScript.COMMAND));
+ fileExport.add(factory.getAction(ExportToRvTest.COMMAND));
+ file.add(fileExport);
+ final JMenu fileImport = new JMenu("Import From");
+ fileExport.setIcon(Icons.IMPORT);
+ fileImport.add(Actions.IMPORT_FROM_RECORD_BUNDLE);
+ file.add(fileImport);
+ file.addSeparator();
+ file.add(factory.getAction(NewRvConnection.COMMAND));
+ final JMenu connRecent = new JMenu("Recent Connections");
+ connRecent.setIcon(Icons.ADD_CONNECTION);
+ connRecent.addMenuListener(new RecentConnectionsMenuManager(application));
+ file.add(connRecent);
+ file.addSeparator();
+ file.add(factory.getAction(Quit.COMMAND));
+ return file;
+ }
+
+ private JMenu createHelpMenu(final Actions factory) {
+ final JMenu help = new JMenu("Help");
+ help.setMnemonic('h');
+ help.add(Actions.HELP);
+ help.add(Actions.DISPLAY_HOME_PAGE);
+ help.add(Actions.REPORT_BUG);
+ help.add(factory.getAction(CheckForUpdates.COMMAND));
+ help.add(Actions.SUBSCRIBE_TO_UPDATES);
+ help.addSeparator();
+ help.add(Actions.DISPLAY_LICENSE);
+ help.add(factory.getAction(DisplayAbout.COMMAND));
+ return help;
+ }
+
+ private JMenuBar createMenuBar(RecordLedgerTable table, Actions factory) {
+ final JMenuBar bar = new JMenuBar();
+ bar.add(createFileMenu(factory));
+ bar.add(createEditMenu(factory));
+ bar.add(createViewMenu(factory, table));
+ bar.add(createConfigureMenu());
+ bar.add(createHelpMenu(factory));
+ // Mac OS X screen menu bars do not normally show icons.
+ if (SystemUtils.IS_OS_MAC_OSX)
+ removeIconsFromMenuElements(bar);
+ return bar;
+ }
+
+ private RecordLedgerTable createMessageLedger(RecordLedger ledger) {
+ final RecordLedgerTable table = new RecordLedgerTable(ledger, application.getConnections());
+ table.getTableFormat().setColumns(UserPreferences.getInstance().getLedgerColumns());
+ columnsPopup.addPopupMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
+ return table;
+ }
+
+ private JScrollPane createMessageLedgerScroller(JTable ledger) {
+ final JScrollPane scrollPane = new JScrollPane(ledger);
+ scrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, Color.GRAY));
+ scrollPane.getVerticalScrollBar().addAdjustmentListener(new TrackingAdjustmentListener());
+ scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ final JButton colsButton = UIUtils.createSmallButton(Icons.COLUMNS_CORNER, TOOLTIP_VISIBLE_COLUMNS, null);
+ colsButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ columnsPopup.show(colsButton, e.getX(), e.getY());
+ }
+ });
+ colsButton.setBorderPainted(false);
+ scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, colsButton);
+ return scrollPane;
+ }
+
+ private JSplitPane createMessageLedgerSplitter(JScrollPane ledger, RvDetailsPanel details) {
+ final JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ledger, details);
+ splitter.setOneTouchExpandable(true);
+ splitter.setDividerLocation(0.5);
+ splitter.setBorder(BorderFactory.createEmptyBorder());
+ return splitter;
+ }
+
+ private JTree createSubjectExplorer() {
+ final JTree tree = new JTree(application.getSubjectHierarchy());
+ tree.setBorder(BorderFactory.createEmptyBorder());
+ tree.setRootVisible(false);
+ tree.setShowsRootHandles(true);
+ tree.setEditable(true);
+ tree.setCellRenderer(new SubjectExplorerRenderer());
+ tree.setCellEditor(new SubjectExplorerEditor(application, tree));
+ application.getSubjectHierarchy().addTreeModelListener(new TreeExpander());
+ // This line allows the cell renderer to provide a custom tooltip for each node.
+ ToolTipManager.sharedInstance().registerComponent(tree);
+ return tree;
+ }
+
+ private JScrollPane createSubjectExplorerScroller(JTree subjectExplorer) {
+ final JScrollPane scroller = new JScrollPane(subjectExplorer);
+ scroller.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 1, Color.GRAY));
+ return scroller;
+ }
+
+ private JSplitPane createSubjectExplorerSplitter(JScrollPane subjectExplorer, JSplitPane messageLedger) {
+ final JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, subjectExplorer, messageLedger);
+ splitter.setOneTouchExpandable(false);
+ splitter.setDividerLocation(0.25);
+ splitter.setBorder(BorderFactory.createEmptyBorder());
+ return splitter;
+ }
+
+ private JToolBar createToolBar(final Actions factory) {
+ final JToolBar toolbar = new JToolBar();
+ toolbar.setFloatable(false);
+ toolbar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));
+ toolbar.setRollover(true);
+ toolbar.add(factory.getAction(OpenProject.COMMAND));
+ toolbar.add(factory.getAction(SaveProject.COMMAND));
+ toolbar.addSeparator();
+ toolbar.add(factory.getAction(NewRvConnection.COMMAND));
+ toolbar.addSeparator();
+ toolbar.add(factory.getAction(ClearLedger.COMMAND));
+ toolbar.addSeparator();
+ toolbar.add(Actions.PAUSE_ALL);
+ final Component[] components = toolbar.getComponents();
+ for (int i = 0, imax = components.length; i < imax; ++i) {
+ Component component = components[i];
+ if (component instanceof AbstractButton) {
+ ((AbstractButton) component).setBorderPainted(false);
+ ((AbstractButton) component).setOpaque(false);
+ }
+ }
+ return toolbar;
+ }
+
+ private JMenu createViewMenu(final Actions factory, final RecordLedgerTable table) {
+ final ImageFactory images = ImageFactory.getInstance();
+ final JMenu view = new JMenu("View");
+ view.setMnemonic('v');
+ view.add(factory.getAction(SelectAllRecords.COMMAND));
+ view.add(factory.getAction(ShowAllColumns.COMMAND));
+ view.addSeparator();
+ view.add(factory.getAction(Filter.COMMAND));
+ view.add(factory.getAction(FilterBySelection.COMMAND));
+ view.addSeparator();
+ final JMenu viewColumns = new JMenu("Columns");
+ viewColumns.setIcon(Icons.FILTER_COLUMNS);
+ viewColumns.addMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
+ view.add(viewColumns);
+ final JMenu viewTypes = new JMenu("Types");
+ viewTypes.setIcon(new ImageIcon(images.getIconImage(EditRecordTypes.COMMAND)));
+ viewTypes.addMenuListener(new RecordTypesMenuManager(application));
+ view.add(viewTypes);
+ return view;
+ }
+
+ public RecordLedgerTable getRecordLedger() {
+ return messageLedger;
+ }
+
+ public Font getMessageLedgerFont() {
+ return messageLedger.getFont();
+ }
+
+ public Record getSelectedRecord() {
+ try {
+ final int index = messageLedger.getSelectedRow();
+ return index >= 0 ? application.getFilteredLedger().get(index) : null;
+ } catch (IndexOutOfBoundsException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Failed to get selected record from ledger.", e);
+ }
+ return null;
+ }
+ }
+
+ public JTree getSubjectExplorer() {
+ return subjectExplorer;
+ }
+
+ private void removeIconsFromMenuElements(MenuElement elt) {
+ if (elt instanceof AbstractButton)
+ ((AbstractButton) elt).setIcon(null);
+ final MenuElement[] elts = elt.getSubElements();
+ for (int i = 0, imax = elts.length; i < imax; ++i) {
+ removeIconsFromMenuElements(elts[i]);
+ }
+ }
+
+}
Property changes on: trunk/rvsn00p/src/main/org/rvsnoop/ui/MainFrame.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/StartRvSnooper.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -23,9 +23,9 @@
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.Application;
import org.rvsnoop.Project;
+import org.rvsnoop.ui.MainFrame;
import rvsnoop.ui.MultiLineToolTipUI;
-import rvsnoop.ui.UIManager;
/**
* Starts an instance of RvSnoop.
@@ -51,8 +51,8 @@
public void run() {
// FIXME this is a hack, there should be no static field.
- UIManager.INSTANCE = application.getFrame();
- UIManager.INSTANCE.setVisible(true);
+ MainFrame.INSTANCE = application.getFrame();
+ MainFrame.INSTANCE.setVisible(true);
}
}
Modified: trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/actions/ChangeTableFont.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -14,10 +14,10 @@
import javax.swing.Action;
import org.rvsnoop.UserPreferences;
+import org.rvsnoop.ui.MainFrame;
import rvsnoop.ui.FontChooser;
import rvsnoop.ui.Icons;
-import rvsnoop.ui.UIManager;
/**
* Change the font used to display text in the message ledger.
@@ -49,7 +49,7 @@
public void actionPerformed(ActionEvent event) {
final FontChooser chooser = new FontChooser();
chooser.setSelectedFont(UserPreferences.getInstance().getLedgerFont());
- if (chooser.showDialog(UIManager.INSTANCE) == FontChooser.OK_OPTION) {
+ if (chooser.showDialog(MainFrame.INSTANCE) == FontChooser.OK_OPTION) {
final Font font = chooser.getSelectedFont();
UserPreferences.getInstance().setLedgerFont(font);
}
Modified: trunk/rvsn00p/src/main/rvsnoop/actions/ImportFromFile.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/actions/ImportFromFile.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/actions/ImportFromFile.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -23,9 +23,8 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.ui.MainFrame;
-import rvsnoop.ui.UIManager;
-
/**
* An abstract class that handles the basics of importing messages to the ledger.
*
@@ -53,7 +52,7 @@
public void actionPerformed(ActionEvent event) {
final JFileChooser chooser = new JFileChooser();
if (filter != null) chooser.setFileFilter(filter);
- if (JFileChooser.APPROVE_OPTION != chooser.showOpenDialog(UIManager.INSTANCE))
+ if (JFileChooser.APPROVE_OPTION != chooser.showOpenDialog(MainFrame.INSTANCE))
return;
final File file = chooser.getSelectedFile();
importRecords(file);
Modified: trunk/rvsn00p/src/main/rvsnoop/ui/RvConnectionDialog.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/ui/RvConnectionDialog.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/ui/RvConnectionDialog.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -20,6 +20,8 @@
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import org.rvsnoop.ui.MainFrame;
+
import rvsnoop.RvConnection;
import rvsnoop.StringUtils;
@@ -93,7 +95,7 @@
* @param initial The initial parameter values to display, may be <code>null</code>.
*/
public RvConnectionDialog(RvConnection initial) {
- super(UIManager.INSTANCE, "Add Connection", true);
+ super(MainFrame.INSTANCE, "Add Connection", true);
buildContentArea(initial != null ? initial : new RvConnection());
buildButtonArea();
pack();
@@ -101,7 +103,7 @@
size.width = Math.max(size.width, MAX_WIDTH);
size.height = Math.max(size.height, MAX_HEIGHT);
setSize(size);
- setLocationRelativeTo(UIManager.INSTANCE);
+ setLocationRelativeTo(MainFrame.INSTANCE);
}
private void buildButtonArea() {
Deleted: trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -1,474 +0,0 @@
-/*
- * Class: UIManager
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2002-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop.ui;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.Iterator;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-
-import javax.swing.AbstractButton;
-import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTable;
-import javax.swing.JToolBar;
-import javax.swing.JTree;
-import javax.swing.ListSelectionModel;
-import javax.swing.MenuElement;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.ToolTipManager;
-import javax.swing.WindowConstants;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.tree.TreeNode;
-
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rvsnoop.Application;
-import org.rvsnoop.RecordLedger;
-import org.rvsnoop.UserPreferences;
-import org.rvsnoop.actions.CheckForUpdates;
-import org.rvsnoop.actions.ClearLedger;
-import org.rvsnoop.actions.Copy;
-import org.rvsnoop.actions.Cut;
-import org.rvsnoop.actions.Delete;
-import org.rvsnoop.actions.DisplayAbout;
-import org.rvsnoop.actions.EditRecordTypes;
-import org.rvsnoop.actions.Filter;
-import org.rvsnoop.actions.FilterBySelection;
-import org.rvsnoop.actions.NewRvConnection;
-import org.rvsnoop.actions.OpenProject;
-import org.rvsnoop.actions.Paste;
-import org.rvsnoop.actions.PruneEmptySubjects;
-import org.rvsnoop.actions.Quit;
-import org.rvsnoop.actions.Republish;
-import org.rvsnoop.actions.SaveProject;
-import org.rvsnoop.actions.SaveProjectAs;
-import org.rvsnoop.actions.Search;
-import org.rvsnoop.actions.SearchBySelection;
-import org.rvsnoop.actions.SelectAllRecords;
-import org.rvsnoop.actions.ShowAllColumns;
-import org.rvsnoop.ui.ConnectionList;
-import org.rvsnoop.ui.ImageFactory;
-import org.rvsnoop.ui.RecentConnectionsMenuManager;
-import org.rvsnoop.ui.RecentProjectsMenuManager;
-import org.rvsnoop.ui.RecordLedgerTable;
-import org.rvsnoop.ui.RecordTypesMenuManager;
-import org.rvsnoop.ui.StatusBar;
-import org.rvsnoop.ui.TrackingAdjustmentListener;
-import org.rvsnoop.ui.VisibleColumnsMenuManager;
-
-import rvsnoop.Record;
-import rvsnoop.TreeModelAdapter;
-import rvsnoop.Version;
-import rvsnoop.actions.Actions;
-import rvsnoop.actions.ExportToHtml;
-import rvsnoop.actions.ExportToRecordBundle;
-import rvsnoop.actions.ExportToRvScript;
-import rvsnoop.actions.ExportToRvTest;
-
-/**
- * The single user interface class for the application.
- *
- * @author <a href="mailto:lun...@ho...">Örjan Lundberg</a>
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- */
-// Class provides a static instance instead of a factory method.
-// @PMD:REVIEWED:MissingStaticMethodInNonInstantiatableClass: by ianp on 1/17/06 7:58 PM
-public final class UIManager extends JFrame {
-
- private final class MessageLedgerListener implements ListSelectionListener {
- MessageLedgerListener() {
- super();
- }
- public void valueChanged(ListSelectionEvent e) {
- final Record record = getSelectedRecord();
- if (record != null) { detailsPanel.setMessage(record); }
- }
- }
-
- private final class TreeExpander extends TreeModelAdapter {
- private boolean isExpanded;
- private TreeExpander() {
- super();
- }
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- if (isExpanded) { return; }
- isExpanded = true;
- subjectExplorer.expandPath(e.getTreePath());
- }
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- final TreeNode root = (TreeNode) application.getSubjectHierarchy().getRoot();
- if (root.getChildCount() == 0) { isExpanded = false; }
- }
- }
-
- private final class FontChangeListener implements PreferenceChangeListener {
- public void preferenceChange(PreferenceChangeEvent event) {
- if (UserPreferences.KEY_LEDGER_FONT.equals(event.getKey())) {
- final Font font = UserPreferences.getInstance().getLedgerFont();
- messageLedger.setFont(font);
- // Without this the default rowNumber height is about 1-million-billion pixels...
- final int rowHeight = messageLedger.getFontMetrics(font).getHeight() + 2;
- messageLedger.setRowHeight(rowHeight);
- }
- }
-
- }
-
- private final class WindowCloseListener extends WindowAdapter {
- WindowCloseListener() {
- super();
- }
- @Override
- public void windowClosing(WindowEvent e) {
- application.shutdown();
- }
- }
-
- private static final long serialVersionUID = 4315311340452405694L;
-
- private static final String TOOLTIP_VISIBLE_COLUMNS = "Show or hide individual table columns";
-
- private static final Log log = LogFactory.getLog(UIManager.class);
-
- // FIXME: Remove this field.
- public static UIManager INSTANCE;
-
- private final Application application;
-
- private final JPopupMenu columnsPopup = new JPopupMenu();
-
- private final ConnectionList connectionList;
- private final JTree subjectExplorer;
- private final RvDetailsPanel detailsPanel = new RvDetailsPanel();
- private final RecordLedgerTable messageLedger;
- private final JScrollPane connectionListScroller;
- private final JScrollPane subjectExplorerScroller;
- private final JScrollPane messageLedgerScroller;
-
- private final JSplitPane messageLedgerSplitter;
- private final JSplitPane subjectExplorerSplitter;
- private final JSplitPane connectionListSplitter;
-
- private final StatusBar statusBar;
-
- public UIManager(final Application application) {
- super(Version.getAsStringWithName());
- this.application = application;
- final UserPreferences state = UserPreferences.getInstance();
- statusBar = new StatusBar(application);
- subjectExplorer = createSubjectExplorer();
- connectionList = new ConnectionList(application);
- messageLedger = createMessageLedger(application.getFilteredLedger());
- messageLedger.setFont(state.getLedgerFont());
- connectionListScroller = createConnectionListScroller(connectionList);
- subjectExplorerScroller = createSubjectExplorerScroller(subjectExplorer);
- messageLedgerScroller = createMessageLedgerScroller(messageLedger);
- messageLedgerSplitter = createMessageLedgerSplitter(messageLedgerScroller, detailsPanel);
- subjectExplorerSplitter = createSubjectExplorerSplitter(subjectExplorerScroller, messageLedgerSplitter);
- connectionListSplitter = createConnectionListSplitter(connectionListScroller, subjectExplorerSplitter);
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- setIconImage(ImageFactory.getInstance().getIconImage("rvsnoop"));
- final Actions factory = application.getActionFactory();
- setJMenuBar(createMenuBar(messageLedger, factory));
- getContentPane().add(connectionListSplitter, BorderLayout.CENTER);
- getContentPane().add(createToolBar(factory), BorderLayout.NORTH);
- getContentPane().add(statusBar, BorderLayout.SOUTH);
- pack();
- setBounds(state.getWindowBounds());
-
- connectListeners();
- configureDividerLocation(connectionListSplitter, "connectionList", state);
- configureDividerLocation(messageLedgerSplitter, "recordLedger", state);
- configureDividerLocation(subjectExplorerSplitter, "subjectExplorer", state);
- state.listenToChangesFrom(this, messageLedger, new JSplitPane[] {
- connectionListSplitter, messageLedgerSplitter, subjectExplorerSplitter });
- }
-
- public void clearDetails() {
- detailsPanel.setMessage(null);
- }
-
- private void configureDividerLocation(JSplitPane pane, String name, UserPreferences state) {
- pane.setName(name);
- final int location = state.getDividerLocation(name);
- if (location > 0) { pane.setDividerLocation(location); }
- }
-
- private void connectListeners() {
- final ListSelectionModel messageLedgerSelectionModel = messageLedger.getSelectionModel();
- messageLedgerSelectionModel.addListSelectionListener(new MessageLedgerListener());
- for (final Iterator i = Actions.getActions().iterator(); i.hasNext(); ) {
- final Object action = i.next();
- if (action instanceof ListSelectionListener)
- messageLedgerSelectionModel.addListSelectionListener((ListSelectionListener) action);
- }
- addWindowListener(new WindowCloseListener());
- UserPreferences.getInstance().addPreferenceChangeListener(new FontChangeListener());
- }
-
- private JMenu createConfigureMenu() {
- final JMenu configure = new JMenu("Configure");
- configure.setMnemonic('c');
- configure.add(Actions.CHANGE_TABLE_FONT);
- return configure;
- }
-
- private JScrollPane createConnectionListScroller(JList listenerList) {
- final JScrollPane scrollPane = new JScrollPane(listenerList);
- scrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.GRAY));
- return scrollPane;
- }
-
- private JSplitPane createConnectionListSplitter(JScrollPane connectionList, JSplitPane subjectExplorerSplitter) {
- final JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, connectionList, subjectExplorerSplitter);
- splitter.setOneTouchExpandable(false);
- splitter.setDividerLocation(0.20);
- splitter.setBorder(BorderFactory.createEmptyBorder());
- return splitter;
- }
-
- private JMenu createEditMenu(final Actions factory) {
- final JMenu edit = new JMenu("Edit");
- edit.setMnemonic('e');
- edit.add(factory.getAction(Cut.COMMAND));
- edit.add(factory.getAction(Copy.COMMAND));
- edit.add(factory.getAction(Paste.COMMAND));
- edit.addSeparator();
- edit.add(factory.getAction(Search.COMMAND));
- edit.add(factory.getAction(SearchBySelection.COMMAND));
- edit.addSeparator();
- edit.add(factory.getAction(Republish.COMMAND));
- edit.addSeparator();
- edit.add(factory.getAction(PruneEmptySubjects.COMMAND));
- edit.addSeparator();
- edit.add(factory.getAction(Delete.COMMAND));
- return edit;
- }
-
- private JMenu createFileMenu(final Actions factory) {
- final ImageFactory images = ImageFactory.getInstance();
- final JMenu file = new JMenu("File");
- file.setMnemonic('f');
- file.add(factory.getAction(OpenProject.COMMAND));
- final JMenu fileRecent = new JMenu("Recent Projects");
- fileRecent.setIcon(new ImageIcon(images.getIconImage(OpenProject.COMMAND)));
- fileRecent.addMenuListener(new RecentProjectsMenuManager(application));
- file.add(fileRecent);
- file.addSeparator();
- file.add(factory.getAction(SaveProject.COMMAND));
- file.add(factory.getAction(SaveProjectAs.COMMAND));
- final JMenu fileExport = new JMenu("Export To");
- fileExport.setIcon(Icons.EXPORT);
- fileExport.add(factory.getAction(ExportToHtml.COMMAND));
- fileExport.add(factory.getAction(ExportToRecordBundle.COMMAND));
- fileExport.add(factory.getAction(ExportToRvScript.COMMAND));
- fileExport.add(factory.getAction(ExportToRvTest.COMMAND));
- file.add(fileExport);
- final JMenu fileImport = new JMenu("Import From");
- fileExport.setIcon(Icons.IMPORT);
- fileImport.add(Actions.IMPORT_FROM_RECORD_BUNDLE);
- file.add(fileImport);
- file.addSeparator();
- file.add(factory.getAction(NewRvConnection.COMMAND));
- final JMenu connRecent = new JMenu("Recent Connections");
- connRecent.setIcon(Icons.ADD_CONNECTION);
- connRecent.addMenuListener(new RecentConnectionsMenuManager(application));
- file.add(connRecent);
- file.addSeparator();
- file.add(factory.getAction(Quit.COMMAND));
- return file;
- }
-
- private JMenu createHelpMenu(final Actions factory) {
- final JMenu help = new JMenu("Help");
- help.setMnemonic('h');
- help.add(Actions.HELP);
- help.add(Actions.DISPLAY_HOME_PAGE);
- help.add(Actions.REPORT_BUG);
- help.add(factory.getAction(CheckForUpdates.COMMAND));
- help.add(Actions.SUBSCRIBE_TO_UPDATES);
- help.addSeparator();
- help.add(Actions.DISPLAY_LICENSE);
- help.add(factory.getAction(DisplayAbout.COMMAND));
- return help;
- }
-
- private JMenuBar createMenuBar(RecordLedgerTable table, Actions factory) {
- final JMenuBar bar = new JMenuBar();
- bar.add(createFileMenu(factory));
- bar.add(createEditMenu(factory));
- bar.add(createViewMenu(factory, table));
- bar.add(createConfigureMenu());
- bar.add(createHelpMenu(factory));
- // Mac OS X screen menu bars do not normally show icons.
- if (SystemUtils.IS_OS_MAC_OSX)
- removeIconsFromMenuElements(bar);
- return bar;
- }
-
- private RecordLedgerTable createMessageLedger(RecordLedger ledger) {
- final RecordLedgerTable table = new RecordLedgerTable(ledger, application.getConnections());
- table.getTableFormat().setColumns(UserPreferences.getInstance().getLedgerColumns());
- columnsPopup.addPopupMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
- return table;
- }
-
- private JScrollPane createMessageLedgerScroller(JTable ledger) {
- final JScrollPane scrollPane = new JScrollPane(ledger);
- scrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, Color.GRAY));
- scrollPane.getVerticalScrollBar().addAdjustmentListener(new TrackingAdjustmentListener());
- scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- final JButton colsButton = UIUtils.createSmallButton(Icons.COLUMNS_CORNER, TOOLTIP_VISIBLE_COLUMNS, null);
- colsButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- columnsPopup.show(colsButton, e.getX(), e.getY());
- }
- });
- colsButton.setBorderPainted(false);
- scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, colsButton);
- return scrollPane;
- }
-
- private JSplitPane createMessageLedgerSplitter(JScrollPane ledger, RvDetailsPanel details) {
- final JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ledger, details);
- splitter.setOneTouchExpandable(true);
- splitter.setDividerLocation(0.5);
- splitter.setBorder(BorderFactory.createEmptyBorder());
- return splitter;
- }
-
- private JTree createSubjectExplorer() {
- final JTree tree = new JTree(application.getSubjectHierarchy());
- tree.setBorder(BorderFactory.createEmptyBorder());
- tree.setRootVisible(false);
- tree.setShowsRootHandles(true);
- tree.setEditable(true);
- tree.setCellRenderer(new SubjectExplorerRenderer());
- tree.setCellEditor(new SubjectExplorerEditor(application, tree));
- application.getSubjectHierarchy().addTreeModelListener(new TreeExpander());
- // This line allows the cell renderer to provide a custom tooltip for each node.
- ToolTipManager.sharedInstance().registerComponent(tree);
- return tree;
- }
-
- private JScrollPane createSubjectExplorerScroller(JTree subjectExplorer) {
- final JScrollPane scroller = new JScrollPane(subjectExplorer);
- scroller.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 1, Color.GRAY));
- return scroller;
- }
-
- private JSplitPane createSubjectExplorerSplitter(JScrollPane subjectExplorer, JSplitPane messageLedger) {
- final JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, subjectExplorer, messageLedger);
- splitter.setOneTouchExpandable(false);
- splitter.setDividerLocation(0.25);
- splitter.setBorder(BorderFactory.createEmptyBorder());
- return splitter;
- }
-
- private JToolBar createToolBar(final Actions factory) {
- final JToolBar toolbar = new JToolBar();
- toolbar.setFloatable(false);
- toolbar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));
- toolbar.setRollover(true);
- toolbar.add(factory.getAction(OpenProject.COMMAND));
- toolbar.add(factory.getAction(SaveProject.COMMAND));
- toolbar.addSeparator();
- toolbar.add(factory.getAction(NewRvConnection.COMMAND));
- toolbar.addSeparator();
- toolbar.add(factory.getAction(ClearLedger.COMMAND));
- toolbar.addSeparator();
- toolbar.add(Actions.PAUSE_ALL);
- final Component[] components = toolbar.getComponents();
- for (int i = 0, imax = components.length; i < imax; ++i) {
- Component component = components[i];
- if (component instanceof AbstractButton) {
- ((AbstractButton) component).setBorderPainted(false);
- ((AbstractButton) component).setOpaque(false);
- }
- }
- return toolbar;
- }
-
- private JMenu createViewMenu(final Actions factory, final RecordLedgerTable table) {
- final ImageFactory images = ImageFactory.getInstance();
- final JMenu view = new JMenu("View");
- view.setMnemonic('v');
- view.add(factory.getAction(SelectAllRecords.COMMAND));
- view.add(factory.getAction(ShowAllColumns.COMMAND));
- view.addSeparator();
- view.add(factory.getAction(Filter.COMMAND));
- view.add(factory.getAction(FilterBySelection.COMMAND));
- view.addSeparator();
- final JMenu viewColumns = new JMenu("Columns");
- viewColumns.setIcon(Icons.FILTER_COLUMNS);
- viewColumns.addMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
- view.add(viewColumns);
- final JMenu viewTypes = new JMenu("Types");
- viewTypes.setIcon(new ImageIcon(images.getIconImage(EditRecordTypes.COMMAND)));
- viewTypes.addMenuListener(new RecordTypesMenuManager(application));
- view.add(viewTypes);
- return view;
- }
-
- public RecordLedgerTable getRecordLedger() {
- return messageLedger;
- }
-
- public Font getMessageLedgerFont() {
- return messageLedger.getFont();
- }
-
- public Record getSelectedRecord() {
- try {
- final int index = messageLedger.getSelectedRow();
- return index >= 0 ? application.getFilteredLedger().get(index) : null;
- } catch (IndexOutOfBoundsException e) {
- if (log.isErrorEnabled()) {
- log.error("Failed to get selected record from ledger.", e);
- }
- return null;
- }
- }
-
- public JTree getSubjectExplorer() {
- return subjectExplorer;
- }
-
- private void removeIconsFromMenuElements(MenuElement elt) {
- if (elt instanceof AbstractButton)
- ((AbstractButton) elt).setIcon(null);
- final MenuElement[] elts = elt.getSubElements();
- for (int i = 0, imax = elts.length; i < imax; ++i) {
- removeIconsFromMenuElements(elts[i]);
- }
- }
-
-}
Modified: trunk/rvsn00p/src/main/rvsnoop/ui/UIUtils.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/ui/UIUtils.java 2008-07-25 11:41:20 UTC (rev 400)
+++ trunk/rvsn00p/src/main/rvsnoop/ui/UIUtils.java 2008-07-25 11:55:13 UTC (rev 401)
@@ -24,6 +24,8 @@
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
+import org.rvsnoop.ui.MainFrame;
+
import com.tibco.tibrv.TibrvException;
/**
@@ -74,11 +76,11 @@
m[0] = message;
m[1] = s != null ? s : "";
m[2] = exception instanceof TibrvException ? "Rendezvous Error Code: " + ((TibrvException) exception).error : "";
- JOptionPane.showMessageDialog(UIManager.INSTANCE, m, title, JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(MainFrame.INSTANCE, m, title, JOptionPane.ERROR_MESSAGE);
}
public static void showInformation(Object message) {
- JOptionPane.showMessageDialog(UIManager.INSTANCE, message, INFORMATION_TITLE, JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(MainFrame.INSTANCE, message, INFORMATION_TITLE, JOptionPane.INFORMATION_MESSAGE);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-25 11:41:23
|
Revision: 400
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=400&view=rev
Author: ianp
Date: 2008-07-25 11:41:20 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Added dependency on Google collections library.
Added generic type information to tree nodes.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java
Added Paths:
-----------
trunk/rvsn00p/lib/google-collect-snapshot-r53-doc.zip
trunk/rvsn00p/lib/google-collect-snapshot-r53-src.zip
trunk/rvsn00p/lib/google-collect-snapshot-r53.jar
Property changes on: trunk/rvsn00p/lib/google-collect-snapshot-r53-doc.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/google-collect-snapshot-r53-src.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/rvsn00p/lib/google-collect-snapshot-r53.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java 2008-07-13 22:44:37 UTC (rev 399)
+++ trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java 2008-07-25 11:41:20 UTC (rev 400)
@@ -13,6 +13,7 @@
import javax.swing.Icon;
import javax.swing.ImageIcon;
+import javax.swing.tree.TreeNode;
import org.rvsnoop.ui.ImageFactory;
@@ -43,7 +44,7 @@
static String AERV, RV, XMLJMS, XMLRV, UNKNOWN, TRACKING, DATA;
- private final List children = new ArrayList(2);
+ private final List<TreeNode> children = new ArrayList<TreeNode>(2);
private final String text;
@@ -72,7 +73,7 @@
* @see rvsnoop.LazyTreeNode#createChildren()
*/
@Override
- protected List createChildren() {
+ protected List<TreeNode> createChildren() {
return children;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java 2008-07-13 22:44:37 UTC (rev 399)
+++ trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java 2008-07-25 11:41:20 UTC (rev 400)
@@ -50,7 +50,7 @@
}
- private List children;
+ private List<TreeNode> children;
private final TreeNode parent;
@@ -65,9 +65,8 @@
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#children()
*/
- public final Enumeration children() {
- if (children == null)
- children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ public final Enumeration<TreeNode> children() {
+ ensureChildrenCreated();
return Collections.enumeration(children);
}
@@ -76,8 +75,18 @@
*
* @return A list of tree nodes.
*/
- protected abstract List createChildren();
+ protected abstract List<TreeNode> createChildren();
+ private void ensureChildrenCreated() {
+ if (children == null) {
+ if (getAllowsChildren()) {
+ children = createChildren();
+ } else {
+ children = Collections.emptyList();
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#getAllowsChildren()
*/
@@ -87,8 +96,7 @@
* @see javax.swing.tree.TreeNode#getChildAt(int)
*/
public final TreeNode getChildAt(int childIndex) {
- if (children == null)
- children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ ensureChildrenCreated();
return (TreeNode) children.get(childIndex);
}
@@ -96,8 +104,7 @@
* @see javax.swing.tree.TreeNode#getChildCount()
*/
public final int getChildCount() {
- if (children == null)
- children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ ensureChildrenCreated();
return children.size();
}
@@ -114,8 +121,7 @@
* @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
*/
public final int getIndex(TreeNode node) {
- if (children == null)
- children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ ensureChildrenCreated();
return children.indexOf(node);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java 2008-07-13 22:44:37 UTC (rev 399)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java 2008-07-25 11:41:20 UTC (rev 400)
@@ -7,6 +7,8 @@
*/
package org.rvsnoop;
+import static com.google.common.collect.Lists.newArrayList;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -174,45 +176,44 @@
}
@Override
- protected List createChildren() {
- List children = null;
+ protected List<TreeNode> createChildren() {
if (field.type == TibrvMsg.XML) {
final InputStream stream = new ByteArrayInputStream(((TibrvXml) field.data).getBytes());
- children = createChildrenFromXML(new InputStreamReader(stream));
+ return createChildrenFromXML(new InputStreamReader(stream));
} else if (field.type == TibrvMsg.STRING && ((String) field.data).startsWith("<?xml ")) {
- children = createChildrenFromXML(new StringReader((String) field.data));
+ return createChildrenFromXML(new StringReader((String) field.data));
} else if (field.type == TibrvMsg.MSG) {
final TibrvMsg msg = (TibrvMsg) field.data;
final int numChildren = msg.getNumFields();
- children = new ArrayList(numChildren);
+ ArrayList<TreeNode> children = newArrayList();
try {
- for (int i = 0; i < numChildren; ++i)
+ for (int i = 0; i < numChildren; ++i) {
children.add(new RvFieldTreeNode(this, msg.getFieldByIndex(i)));
+ }
} catch (TibrvException e) {
if (log.isErrorEnabled()) {
- log.error(MessageFormat.format(ERROR_FIELD, new Object[] {
- new Integer(e.error)
- }), e);
+ log.error(MessageFormat.format(ERROR_FIELD, e.error), e);
}
}
+ children.trimToSize();
+ return children;
}
- return children != null ? children : Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- private List createChildrenFromXML(final Reader reader) {
- List children = null;
+ private List<TreeNode> createChildrenFromXML(final Reader reader) {
+ final ArrayList<TreeNode> children = newArrayList();
final Builder builder = new Builder(false, new InterningTrimmingNodeFactory());
try {
final Document doc = builder.build(reader).getDocument();
final int numChildren = doc.getChildCount();
- children = new ArrayList(numChildren);
- for (int i = 0; i < numChildren; ++i)
+ for (int i = 0; i < numChildren; ++i) {
children.add(new XMLTreeNode(this, doc.getChild(i)));
+ }
} catch (ParsingException e) {
if (log.isErrorEnabled()) {
- log.error(MessageFormat.format(ERROR_XML_PARSE, new Object[] {
- new Integer(e.getLineNumber()), new Integer(e.getColumnNumber())
- }), e);
+ log.error(MessageFormat.format(ERROR_XML_PARSE,
+ e.getLineNumber(), e.getColumnNumber()), e);
}
} catch (IOException e) {
if (log.isErrorEnabled()) {
@@ -221,6 +222,7 @@
} finally {
IOUtils.closeQuietly(reader);
}
+ children.trimToSize();
return children;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java 2008-07-13 22:44:37 UTC (rev 399)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java 2008-07-25 11:41:20 UTC (rev 400)
@@ -7,12 +7,16 @@
*/
package org.rvsnoop;
+import static com.google.common.collect.Lists.newArrayList;
+
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.Icon;
import javax.swing.ImageIcon;
+import javax.swing.tree.TreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,21 +55,21 @@
}
@Override
- protected List createChildren() {
+ protected List<TreeNode> createChildren() {
final int numFields = message.getNumFields();
- final List children = new ArrayList(numFields);
+ if (numFields == 0) { return Collections.emptyList(); }
+ final ArrayList<TreeNode> children = newArrayList();
for (int i = 0; i < numFields; ++i) {
try {
children.add(new RvFieldTreeNode(this, message.getFieldByIndex(i)));
} catch (TibrvException e) {
if (log.isErrorEnabled()) {
- log.error(MessageFormat.format(ERROR_FIELD, new Object[] {
- new Integer(e.error)
- }), e);
+ log.error(MessageFormat.format(ERROR_FIELD, e.error), e);
}
break;
}
}
+ children.trimToSize();
return children;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java 2008-07-13 22:44:37 UTC (rev 399)
+++ trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java 2008-07-25 11:41:20 UTC (rev 400)
@@ -7,6 +7,8 @@
*/
package org.rvsnoop;
+import static com.google.common.collect.Lists.newArrayList;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -14,7 +16,6 @@
import javax.swing.Icon;
import javax.swing.tree.TreeNode;
-
import nu.xom.Attribute;
import nu.xom.Comment;
import nu.xom.DocType;
@@ -43,13 +44,15 @@
}
@Override
- protected List createChildren() {
+ protected List<TreeNode> createChildren() {
final ParentNode pn = (ParentNode) node;
final int numChildren = pn.getChildCount();
- if (numChildren == 0) return Collections.EMPTY_LIST;
- final List children = new ArrayList(numChildren);
- for (int i = 0; i < numChildren; ++i)
+ if (numChildren == 0) { return Collections.emptyList(); }
+ final ArrayList<TreeNode> children = newArrayList();
+ for (int i = 0; i < numChildren; ++i) {
children.add(new XMLTreeNode(this, pn.getChild(i)));
+ }
+ children.trimToSize();
return children;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-13 22:44:39
|
Revision: 399
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=399&view=rev
Author: ianp
Date: 2008-07-13 15:44:37 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
Added generic type parameters.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java
trunk/rvsn00p/src/main/org/rvsnoop/TibrvUtils.java
trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessor.java
trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessorFactory.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RecentProjectsMenuManager.java
Modified: trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -33,9 +33,10 @@
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
*/
+@SuppressWarnings("unchecked")
public final class NLSUtils {
- private static final class PriviledgedFieldSetter implements PrivilegedAction {
+ private static final class PriviledgedFieldSetter implements PrivilegedAction {
private final Field field;
private final Object value;
private PriviledgedFieldSetter(Field field, Object value) {
Modified: trunk/rvsn00p/src/main/org/rvsnoop/TibrvUtils.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/TibrvUtils.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/TibrvUtils.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -32,7 +32,7 @@
* @param message The message to traverse.
* @return The iterator.
*/
- public static Iterator depthFirstFieldIterator(TibrvMsg message) {
+ public static Iterator<TibrvMsgField> depthFirstFieldIterator(TibrvMsg message) {
return new DepthFirstFieldIterator(message);
}
@@ -51,8 +51,8 @@
}
/** Traverse the fields in a message in depth first order. */
-final class DepthFirstFieldIterator implements Iterator {
- private final List stack = new ArrayList(1);
+final class DepthFirstFieldIterator implements Iterator<TibrvMsgField> {
+ private final List<StackElement> stack = new ArrayList<StackElement>(1);
private boolean hasNext;
private TibrvMsg message;
private int numFields;
@@ -65,7 +65,7 @@
public boolean hasNext() {
return hasNext;
}
- public Object next() {
+ public TibrvMsgField next() {
if (!hasNext) { throw new NoSuchElementException(); }
try {
final TibrvMsgField next = message.getField(position++);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
@@ -98,8 +97,8 @@
public void columnSelectionChanged(ListSelectionEvent e) { /* NO-OP */ }
}
- private final class RecentConnectionsListener implements ListEventListener {
- public void listChanged(ListEvent changes) {
+ private final class RecentConnectionsListener implements ListEventListener<RvConnection> {
+ public void listChanged(ListEvent<RvConnection> changes) {
updateRecentConnectionsList(changes);
}
}
@@ -150,11 +149,11 @@
private Preferences preferences =
Preferences.userRoot().node("org").node("rvsnoop").node("sessionState");
- private final LinkedList recentConnections = new LinkedList();
+ private final LinkedList<RvConnection> recentConnections = new LinkedList<RvConnection>();
private final File recentConnectionsFile;
- private final LinkedList recentProjects = new LinkedList();
+ private final LinkedList<File> recentProjects = new LinkedList<File>();
private UserPreferences() {
String path = null;
@@ -203,8 +202,8 @@
return preferences.get(KEY_LAST_EXPORT_LOCATION, SystemUtils.USER_DIR);
}
- public List getLedgerColumns() {
- final List columns = new ArrayList(RecordLedgerFormat.ALL_COLUMNS.size());
+ public List<ColumnFormat> getLedgerColumns() {
+ final List<ColumnFormat> columns = new ArrayList<ColumnFormat>(RecordLedgerFormat.ALL_COLUMNS.size());
final Preferences node = preferences.node(KEY_LEDGER_COLUMNS);
try {
final String[] keys = node.keys();
@@ -242,13 +241,11 @@
return preferences.getInt(KEY_NUM_RECENT_PROJECTS, 10);
}
- // List<RvConnection>
- public List getRecentConnections() {
+ public List<RvConnection> getRecentConnections() {
return Collections.unmodifiableList(recentConnections);
}
- // List<File>
- public List getRecentProjects() {
+ public List<File> getRecentProjects() {
return Collections.unmodifiableList(recentProjects);
}
@@ -301,14 +298,14 @@
preferences.put(KEY_LAST_EXPORT_LOCATION, path);
}
- private void setLedgerColumns(final TableColumnModel model) {
+ @SuppressWarnings("unchecked")
+ private void setLedgerColumns(final TableColumnModel model) {
final List columns = new ArrayList(model.getColumnCount());
for (Enumeration e = model.getColumns(); e.hasMoreElements(); ) {
columns.add(((TableColumn) e.nextElement()).getHeaderValue());
}
final Preferences node = preferences.node(KEY_LEDGER_COLUMNS);
- for (Iterator i = RecordLedgerFormat.ALL_COLUMNS.iterator(); i.hasNext(); ) {
- final ColumnFormat column = (ColumnFormat) i.next();
+ for (ColumnFormat column : RecordLedgerFormat.ALL_COLUMNS) {
node.putBoolean(column.getIdentifier(), columns.contains(column.getName()));
}
}
@@ -340,15 +337,15 @@
preferences.put(KEY_LEDGER_FONT, builder.toString());
}
- private void updateRecentConnectionsList(ListEvent changes) {
- final EventList list = changes.getSourceList();
+ private void updateRecentConnectionsList(ListEvent<RvConnection> changes) {
+ final EventList<RvConnection> list = changes.getSourceList();
final Lock lock = list.getReadWriteLock().readLock();
lock.lock();
try {
final int max = getNumberOfRecentConnections();
while (changes.next()) {
if (changes.getType() == ListEvent.INSERT) {
- final Object o = list.get(changes.getIndex());
+ final RvConnection o = list.get(changes.getIndex());
recentConnections.remove(o);
recentConnections.add(0, o);
if (recentConnections.size() > max) {
@@ -374,7 +371,7 @@
}
private void updateRecentProjectsList(Project newProject) {
- final String path = newProject.getDirectory().getPath();
+ final File path = newProject.getDirectory();
final int max = getNumberOfRecentProjects();
recentProjects.remove(path);
recentProjects.add(0, path);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessor.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessor.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessor.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -31,36 +31,36 @@
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
*/
-public abstract class DataAccessor {
+public abstract class DataAccessor<T> {
- static final class FieldContents extends DataAccessor {
+ static final class FieldContents extends DataAccessor<String> {
public static final String IDENTIFIER = "fieldContents";
public FieldContents() {
super(FIELD_CONTENTS, IDENTIFIER);
}
@Override
- public Iterator getDataElement(Record record) {
+ public Iterator<String> getDataElement(Record record) {
return new FieldContentsIterator(TibrvUtils.depthFirstFieldIterator(record.getMessage()));
}
}
- private static final class FieldContentsIterator implements Iterator {
- private final Iterator iterator;
- FieldContentsIterator(Iterator iterator) {
+ private static final class FieldContentsIterator implements Iterator<String> {
+ private final Iterator<TibrvMsgField> iterator;
+ FieldContentsIterator(Iterator<TibrvMsgField> iterator) {
this.iterator = iterator;
}
public boolean hasNext() {
return iterator.hasNext();
}
- public Object next() {
- TibrvMsgField field = (TibrvMsgField) iterator.next();
+ public String next() {
+ TibrvMsgField field = iterator.next();
if (field.type == TibrvMsg.STRING) {
- return field.data;
+ return (String) field.data;
} else if (field.type == TibrvMsg.XML) {
try {
return new String(((TibrvXml) field.data).getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
- // Never happens, UTF-8 is always supported in a Java VM.
+ throw new Error("The VM doesn't support UTF-8!");
}
}
return "";
@@ -70,67 +70,67 @@
}
}
- static final class FieldNames extends DataAccessor {
+ static final class FieldNames extends DataAccessor<String> {
public static final String IDENTIFIER = "fieldNames";
public FieldNames() {
super(FIELD_NAMES, IDENTIFIER);
}
@Override
- public Iterator getDataElement(Record record) {
+ public Iterator<String> getDataElement(Record record) {
return new FieldNamesIterator(TibrvUtils.depthFirstFieldIterator(record.getMessage()));
}
}
- private static final class FieldNamesIterator implements Iterator {
- private final Iterator iterator;
- FieldNamesIterator(Iterator iterator) {
+ private static final class FieldNamesIterator implements Iterator<String> {
+ private final Iterator<TibrvMsgField> iterator;
+ FieldNamesIterator(Iterator<TibrvMsgField> iterator) {
this.iterator = iterator;
}
public boolean hasNext() {
return iterator.hasNext();
}
- public Object next() {
- return ((TibrvMsgField) iterator.next()).name;
+ public String next() {
+ return iterator.next().name;
}
public void remove() {
iterator.remove();
}
}
- static final class ReplySubject extends DataAccessor {
+ static final class ReplySubject extends DataAccessor<String> {
public static final String IDENTIFIER = "replySubject";
- private final SingleElementIterator iterator = new SingleElementIterator();
+ private final SingleElementIterator<String> iterator = new SingleElementIterator<String>();
public ReplySubject() {
super(REPLY_SUBJECT, IDENTIFIER);
}
@Override
- public Iterator getDataElement(Record record) {
+ public Iterator<String> getDataElement(Record record) {
iterator.element = record.getReplySubject();
return iterator;
}
}
- static final class SendSubject extends DataAccessor {
+ static final class SendSubject extends DataAccessor<String> {
public static final String IDENTIFIER = "sendSubject";
- private final SingleElementIterator iterator = new SingleElementIterator();
+ private final SingleElementIterator<String> iterator = new SingleElementIterator<String>();
public SendSubject() {
super(SEND_SUBJECT, IDENTIFIER);
}
@Override
- public Iterator getDataElement(Record record) {
+ public Iterator<String> getDataElement(Record record) {
iterator.element = record.getSendSubject();
return iterator;
}
}
- private static final class SingleElementIterator implements Iterator {
- Object element;
+ private static final class SingleElementIterator<T> implements Iterator<T> {
+ T element;
public boolean hasNext() {
return element != null;
}
- public Object next() {
- if (element == null) throw new NoSuchElementException();
- Object next = element;
+ public T next() {
+ if (element == null) { throw new NoSuchElementException(); }
+ T next = element;
element = null;
return next;
}
@@ -139,14 +139,14 @@
}
}
- static final class TrackingId extends DataAccessor {
+ static final class TrackingId extends DataAccessor<String> {
public static final String IDENTIFIER = "trackingId";
- private final SingleElementIterator iterator = new SingleElementIterator();
+ private final SingleElementIterator<String> iterator = new SingleElementIterator<String>();
public TrackingId() {
super(TRACKING_ID, IDENTIFIER);
}
@Override
- public Iterator getDataElement(Record record) {
+ public Iterator<String> getDataElement(Record record) {
iterator.element = record.getTrackingId();
return iterator;
}
@@ -169,7 +169,8 @@
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
- @Override
+ @SuppressWarnings("unchecked")
+ @Override
public boolean equals(Object obj) {
if (this == obj) { return true; }
if (obj == null) { return false; }
@@ -185,7 +186,7 @@
* @param record The record to extract data from.
* @return The data elements.
*/
- public abstract Iterator getDataElement(Record record);
+ public abstract Iterator<T> getDataElement(Record record);
/**
* Get a string describing the data this class accesses which is suitable
Modified: trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessorFactory.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessorFactory.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessorFactory.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -34,9 +34,9 @@
return instance;
}
- private final Map identifiersToAccessorsMap = new LinkedHashMap();
+ private final Map<String, Class<? extends DataAccessor<?>>> identifiersToAccessorsMap = new LinkedHashMap<String, Class<? extends DataAccessor<?>>>();
- private final Map namesToAccessorsMap = new LinkedHashMap();
+ private final Map<String, Class<? extends DataAccessor<?>>> namesToAccessorsMap = new LinkedHashMap<String, Class<? extends DataAccessor<?>>>();
private DataAccessorFactory() {
identifiersToAccessorsMap.put(DataAccessor.FieldContents.IDENTIFIER, DataAccessor.FieldContents.class);
@@ -51,43 +51,43 @@
namesToAccessorsMap.put(DataAccessor.TRACKING_ID, DataAccessor.TrackingId.class);
}
- public DataAccessor createFieldContentsAccessor() {
+ public DataAccessor<String> createFieldContentsAccessor() {
return new DataAccessor.FieldContents();
}
- public DataAccessor createFieldNamesAccessor() {
+ public DataAccessor<String> createFieldNamesAccessor() {
return new DataAccessor.FieldNames();
}
- public DataAccessor createReplySubjectAccessor() {
+ public DataAccessor<String> createReplySubjectAccessor() {
return new DataAccessor.ReplySubject();
}
- public DataAccessor createSendSubjectAccessor() {
+ public DataAccessor<String> createSendSubjectAccessor() {
return new DataAccessor.SendSubject();
}
- public DataAccessor createTrackingIdAccessor() {
+ public DataAccessor<String> createTrackingIdAccessor() {
return new DataAccessor.TrackingId();
}
- public DataAccessor createFromDisplayName(String name) {
+ public DataAccessor<?> createFromDisplayName(String name) {
return createFromString(namesToAccessorsMap, name, ERROR_BAD_NAME);
}
- public DataAccessor createFromIdentifier(String identifier) {
+ public DataAccessor<?> createFromIdentifier(String identifier) {
return createFromString(identifiersToAccessorsMap, identifier, ERROR_BAD_IDENTIFIER);
}
- private DataAccessor createFromString(Map map, String string, String errorMessage) {
+ private DataAccessor<?> createFromString(Map<String, Class<? extends DataAccessor<?>>> map, String string, String errorMessage) {
Validate.notNull(string);
- Class clazz = (Class) map.get(string);
+ Class<? extends DataAccessor<?>> clazz = map.get(string);
if (clazz == null) {
throw new IllegalArgumentException(
MessageFormat.format(errorMessage, new Object[] { string }));
}
try {
- return (DataAccessor) clazz.newInstance();
+ return clazz.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
@@ -96,8 +96,8 @@
}
public String[] getDisplayNames() {
- final Set names = namesToAccessorsMap.keySet();
- return (String[]) names.toArray(new String[names.size()]);
+ final Set<String> names = namesToAccessorsMap.keySet();
+ return names.toArray(new String[names.size()]);
}
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ui/RecentProjectsMenuManager.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/ui/RecentProjectsMenuManager.java 2008-07-13 21:53:32 UTC (rev 398)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ui/RecentProjectsMenuManager.java 2008-07-13 22:44:37 UTC (rev 399)
@@ -88,10 +88,10 @@
public void menuSelected(MenuEvent e) {
final JMenu menu = (JMenu) e.getSource();
menu.removeAll();
- final Iterator i = UserPreferences.getInstance().getRecentProjects().iterator();
+ final Iterator<File> i = UserPreferences.getInstance().getRecentProjects().iterator();
int count = 0;
while (i.hasNext()) {
- menu.add(new MenuItem((File) i.next(), ++count));
+ menu.add(new MenuItem(i.next(), ++count));
}
if (count == 0) {
menu.add(new JMenuItem(EMPTY_MENU_TEXT));
@@ -118,10 +118,10 @@
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
final JPopupMenu menu = (JPopupMenu) e.getSource();
menu.removeAll();
- final Iterator i = UserPreferences.getInstance().getRecentProjects().iterator();
+ final Iterator<File> i = UserPreferences.getInstance().getRecentProjects().iterator();
int count = 0;
while (i.hasNext()) {
- menu.add(new MenuItem((File) i.next(), ++count));
+ menu.add(new MenuItem(i.next(), ++count));
}
if (count == 0) {
menu.add(new JMenuItem(EMPTY_MENU_TEXT));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-13 21:53:34
|
Revision: 398
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=398&view=rev
Author: ianp
Date: 2008-07-13 14:53:32 -0700 (Sun, 13 Jul 2008)
Log Message:
-----------
Added generic type parameters.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java
trunk/rvsn00p/src/main/rvsnoop/RecordMatcher.java
trunk/rvsn00p/src/main/rvsnoop/RecordType.java
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-07-09 23:39:31 UTC (rev 397)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RecordLedger.java 2008-07-13 21:53:32 UTC (rev 398)
@@ -38,14 +38,14 @@
/**
* The underlying event list used by this ledger.
*/
- private final EventList list;
+ private final EventList<Record> list;
/**
* Create a new record ledger.
*
* @param list The list to use as the record store.
*/
- protected RecordLedger(final EventList list) {
+ protected RecordLedger(final EventList<Record> list) {
this.list = list;
}
@@ -77,7 +77,7 @@
* @param records The records to add.
* @see java.util.Collection#addAll(Collection)
*/
- public final void addAll(Collection records) {
+ public final void addAll(Collection<Record> records) {
final Lock lock = list.getReadWriteLock().writeLock();
lock.lock();
try {
@@ -91,7 +91,7 @@
* @param listChangeListener
* @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
*/
- public void addListEventListener(ListEventListener listChangeListener) {
+ public void addListEventListener(ListEventListener<Record> listChangeListener) {
list.addListEventListener(listChangeListener);
}
@@ -142,9 +142,9 @@
*
* @return A new table model.
*/
- public final EventTableModel createTableModel() {
+ public final EventTableModel<Record> createTableModel() {
final RecordLedgerFormat format = new RecordLedgerFormat();
- final EventTableModel model = new EventTableModel(list, format);
+ final EventTableModel<Record> model = new EventTableModel<Record>(list, format);
format.setModel(model);
return model;
}
@@ -159,7 +159,7 @@
* @return The found record, or <code>null</code> if none meet the selection
* criterion.
*/
- public final Record find(Matcher criteria, int startIndex) {
+ public final Record find(Matcher<Record> criteria, int startIndex) {
final Lock lock = list.getReadWriteLock().readLock();
lock.lock();
try {
@@ -185,7 +185,7 @@
* @param criteria How to match records.
* @return The indices of the matching records.
*/
- public final int[] findAllIndices(Matcher criteria) {
+ public final int[] findAllIndices(Matcher<Record> criteria) {
final Lock lock = list.getReadWriteLock().readLock();
lock.lock();
final int[] temp = new int[list.size()];
@@ -213,7 +213,7 @@
* @return The index of the found record, or -1 if none meet the selection
* criterion.
*/
- public final int findIndex(Matcher criteria, int startIndex) {
+ public final int findIndex(Matcher<Record> criteria, int startIndex) {
final Lock lock = list.getReadWriteLock().readLock();
lock.lock();
try {
@@ -280,7 +280,7 @@
*
* @return The wrapped list.
*/
- EventList getEventList() {
+ EventList<Record> getEventList() {
return list;
}
@@ -312,7 +312,7 @@
* @param records The records to remove.
* @see java.util.Collection#removeAll(Collection)
*/
- public final void removeAll(Collection records) {
+ public final void removeAll(Collection<Record> records) {
final Lock lock = list.getReadWriteLock().writeLock();
lock.lock();
try {
@@ -326,7 +326,7 @@
* @param listChangeListener
* @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
*/
- public void removeListEventListener(ListEventListener listChangeListener) {
+ public void removeListEventListener(ListEventListener<Record> listChangeListener) {
list.removeListEventListener(listChangeListener);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java 2008-07-09 23:39:31 UTC (rev 397)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java 2008-07-13 21:53:32 UTC (rev 398)
@@ -28,14 +28,15 @@
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
*/
-public final class RecordLedgerFormat implements AdvancedTableFormat {
+public final class RecordLedgerFormat implements AdvancedTableFormat<Record> {
- private static final class ComparableComparator implements Comparator {
+ @SuppressWarnings("unchecked")
+ private static final class ComparableComparator implements Comparator<Comparable> {
ComparableComparator() {
super();
}
- public int compare(Object o1, Object o2) {
- return ((Comparable) o1).compareTo(o2);
+ public int compare(Comparable o1, Comparable o2) {
+ return o1.compareTo(o2);
}
}
@@ -46,23 +47,23 @@
* @version $Revision$, $Date$
*/
public abstract static class ColumnFormat {
- private final Class clazz;
- private final Comparator comparator;
+ private final Class<?> clazz;
+ private final Comparator<?> comparator;
private final String identifier;
private final String name;
- ColumnFormat(String id, String name, Class clazz) {
+ ColumnFormat(String id, String name, Class<?> clazz) {
this(id, name, clazz, Collator.getInstance());
}
- ColumnFormat(String id, String name, Class clazz, Comparator comparator) {
+ ColumnFormat(String id, String name, Class<?> clazz, Comparator<?> comparator) {
this.clazz = clazz;
this.comparator = comparator;
this.identifier = id;
this.name = name;
}
- public Class getClazz() {
+ public Class<?> getClazz() {
return clazz;
}
- public Comparator getComparator() {
+ public Comparator<?> getComparator() {
return comparator;
}
public final String getIdentifier() {
@@ -146,7 +147,7 @@
}
};
- public static final List ALL_COLUMNS = Collections.unmodifiableList(
+ public static final List<ColumnFormat> ALL_COLUMNS = Collections.unmodifiableList(
Arrays.asList(new ColumnFormat[] {
CONNECTION, TIMESTAMP, SEQUENCE_NO, TYPE,
SUBJECT, SIZE_IN_BYTES, TRACKING_ID, MESSAGE
@@ -176,9 +177,9 @@
return null;
}
- private final List columns = new ArrayList(ALL_COLUMNS);
+ private final List<ColumnFormat> columns = new ArrayList<ColumnFormat>(ALL_COLUMNS);
- private EventTableModel model;
+ private EventTableModel<Record> model;
/**
* Create a new <code>RecordLedgerFormat</code>.
@@ -214,14 +215,14 @@
/* (non-Javadoc)
* @see ca.odell.glazedlists.gui.AdvancedTableFormat#getColumnClass(int)
*/
- public Class getColumnClass(int column) {
+ public Class<?> getColumnClass(int column) {
return ((ColumnFormat) columns.get(column)).getClazz();
}
/* (non-Javadoc)
* @see ca.odell.glazedlists.gui.AdvancedTableFormat#getColumnComparator(int)
*/
- public Comparator getColumnComparator(int column) {
+ public Comparator<?> getColumnComparator(int column) {
return ((ColumnFormat) columns.get(column)).getComparator();
}
@@ -244,15 +245,15 @@
*
* @return A <em>read-only</em> list containing the columns.
*/
- public List getColumns() {
+ public List<ColumnFormat> getColumns() {
return Collections.unmodifiableList(columns);
}
/* (non-Javadoc)
* @see ca.odell.glazedlists.gui.TableFormat#getColumnValue(java.lang.Object, int)
*/
- public Object getColumnValue(Object record, int index) {
- return ((ColumnFormat) columns.get(index)).getValue((Record) record);
+ public Object getColumnValue(Record record, int index) {
+ return ((ColumnFormat) columns.get(index)).getValue(record);
}
/**
@@ -270,7 +271,7 @@
*
* @param columns The columns to set.
*/
- public void setColumns(List columns) {
+ public void setColumns(List<ColumnFormat> columns) {
columns.clear();
columns.addAll(columns);
if (model != null) { model.setTableFormat(this); }
@@ -284,7 +285,7 @@
*
* @param model
*/
- void setModel(EventTableModel model) {
+ void setModel(EventTableModel<Record> model) {
this.model = model;
}
Modified: trunk/rvsn00p/src/main/rvsnoop/RecordMatcher.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/RecordMatcher.java 2008-07-09 23:39:31 UTC (rev 397)
+++ trunk/rvsn00p/src/main/rvsnoop/RecordMatcher.java 2008-07-13 21:53:32 UTC (rev 398)
@@ -31,10 +31,10 @@
* @version $Revision$, $Date$
* @since 1.5
*/
-public abstract class RecordMatcher implements Matcher {
+public abstract class RecordMatcher implements Matcher<Record> {
- private static final Map matchersById = new HashMap();
- private static final Map matchersByName = new HashMap();
+ private static final Map<String, Class<RecordMatcher>> matchersById = new HashMap<String, Class<RecordMatcher>>();
+ private static final Map<String, Class<RecordMatcher>> matchersByName = new HashMap<String, Class<RecordMatcher>>();
public static final class EverythingMatcher extends RecordMatcher {
public static final String ID = "Everything";
@@ -42,7 +42,7 @@
public EverythingMatcher() {
super(ID, NAME, "");
}
- public boolean matches(Object item) {
+ public boolean matches(Record item) {
return true;
}
}
@@ -53,8 +53,8 @@
public SendSubjectContains(String value) {
super(ID, NAME, value);
}
- public boolean matches(Object item) {
- return ((Record) item).getSendSubject().indexOf(getValue()) >= 0;
+ public boolean matches(Record item) {
+ return item.getSendSubject().indexOf(getValue()) >= 0;
}
}
@@ -64,8 +64,8 @@
public SendSubjectStartsWith(String value) {
super(ID, NAME, value);
}
- public boolean matches(Object item) {
- return ((Record) item).getSendSubject().startsWith(getValue());
+ public boolean matches(Record item) {
+ return item.getSendSubject().startsWith(getValue());
}
}
@@ -104,11 +104,11 @@
* @return The new matcher instance.
*/
public static RecordMatcher createMatcher(String typeOrName, String value) {
- Class clazz = (Class) matchersById.get(typeOrName);
- if (clazz == null) clazz = (Class) matchersByName.get(typeOrName);
+ Class<RecordMatcher> clazz = matchersById.get(typeOrName);
+ if (clazz == null) clazz = matchersByName.get(typeOrName);
if (clazz == null) throw new IllegalArgumentException("No matcher named " + typeOrName + '.');
try {
- final Constructor ctor = clazz.getConstructor(new Class[] { String.class });
+ final Constructor<RecordMatcher> ctor = clazz.getConstructor(new Class[] { String.class });
return (RecordMatcher) ctor.newInstance(new Object[] { value });
} catch (Exception e) {
if (log.isErrorEnabled())
@@ -125,7 +125,7 @@
* @return The names of all known record matchers.
*/
public static String[] getMatcherNames() {
- final Set nameSet = matchersByName.keySet();
+ final Set<String> nameSet = matchersByName.keySet();
final String[] names = (String[]) nameSet.toArray(new String[nameSet.size()]);
Arrays.sort(names, Collator.getInstance());
return names;
@@ -144,8 +144,8 @@
this.type = type;
this.name = name;
this.value = value;
- matchersById.put(type, getClass());
- matchersByName.put(name, getClass());
+ matchersById.put(type, RecordMatcher.class);
+ matchersByName.put(name, RecordMatcher.class);
}
/**
Modified: trunk/rvsn00p/src/main/rvsnoop/RecordType.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/RecordType.java 2008-07-09 23:39:31 UTC (rev 397)
+++ trunk/rvsn00p/src/main/rvsnoop/RecordType.java 2008-07-13 21:53:32 UTC (rev 398)
@@ -24,7 +24,7 @@
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
*/
-public class RecordType implements Matcher {
+public class RecordType implements Matcher<Record> {
/** Key for colour JavaBean property. */
public static final String KEY_COLOUR = "colour";
@@ -113,7 +113,7 @@
return selected;
}
- public boolean matches(Object item) {
+ public boolean matches(Record item) {
return matcher.matches(item);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-07-09 23:39:33
|
Revision: 397
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=397&view=rev
Author: ianp
Date: 2008-07-09 16:39:31 -0700 (Wed, 09 Jul 2008)
Log Message:
-----------
Added generic type information now that we're moving to Java 1.5.
Modified Paths:
--------------
trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
trunk/rvsn00p/src/main/rvsnoop/RvConnection.java
trunk/rvsn00p/src/main/rvsnoop/SubjectHierarchy.java
Property Changed:
----------------
trunk/rvsn00p/
Property changes on: trunk/rvsn00p
___________________________________________________________________
Name: svn:ignore
-
.classpath
.project
build
local.properties
rvsnoop-*-???.tgz
dist
.pmd
.externalToolBuilders
.settings
stage
*.tgz
classes
debug-logging.properties
commons-logging.properties
+
.classpath
.project
build
build.properties
rvsnoop-*-???.tgz
dist
.pmd
.externalToolBuilders
.settings
stage
*.tgz
classes
debug-logging.properties
commons-logging.properties
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-06-03 21:52:10 UTC (rev 396)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Connections.java 2008-07-09 23:39:31 UTC (rev 397)
@@ -52,23 +52,21 @@
*/
public final class Connections {
- private static class DescriptionComparator implements Comparator {
+ private static class DescriptionComparator implements Comparator<RvConnection> {
private final Collator collator = Collator.getInstance();
public DescriptionComparator() {
super();
}
- public int compare(Object o1, Object o2) {
- final String d1 = ((RvConnection) o1).getDescription();
- final String d2 = ((RvConnection) o2).getDescription();
- return collator.compare(d1, d2);
+ public int compare(RvConnection o1, RvConnection o2) {
+ return collator.compare(o1.getDescription(), o2.getDescription());
}
}
- private static class Observer implements ObservableElementList.Connector,
+ private static class Observer implements ObservableElementList.Connector<RvConnection>,
PropertyChangeListener {
- private ObservableElementList list;
+ private ObservableElementList<RvConnection> list;
Observer() {
super();
@@ -79,8 +77,8 @@
*
* @see ca.odell.glazedlists.ObservableElementList.Connector#installListener(java.lang.Object)
*/
- public EventListener installListener(Object element) {
- ((RvConnection) element).addPropertyChangeListener(this);
+ public EventListener installListener(RvConnection element) {
+ element.addPropertyChangeListener(this);
return this;
}
@@ -89,8 +87,8 @@
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
- public void propertyChange(PropertyChangeEvent evt) {
- list.elementChanged(evt.getSource());
+ public void propertyChange(PropertyChangeEvent event) {
+ list.elementChanged((RvConnection) event.getSource());
}
/*
@@ -98,7 +96,7 @@
*
* @see ca.odell.glazedlists.ObservableElementList.Connector#setObservableElementList(ca.odell.glazedlists.ObservableElementList)
*/
- public void setObservableElementList(ObservableElementList list) {
+ public void setObservableElementList(ObservableElementList<RvConnection> list) {
this.list = list;
}
@@ -108,21 +106,21 @@
* @see ca.odell.glazedlists.ObservableElementList.Connector#uninstallListener(java.lang.Object,
* java.util.EventListener)
*/
- public void uninstallListener(Object element, EventListener listener) {
- ((RvConnection) element).removePropertyChangeListener(this);
+ public void uninstallListener(RvConnection element, EventListener listener) {
+ element.removePropertyChangeListener(this);
}
}
private static final Log log = LogFactory.getLog(Connections.class);
- private final ObservableElementList list;
+ private final ObservableElementList<RvConnection> list;
private final boolean ownsConnections;
- public Connections(Collection connections, boolean ownsConnections) {
- if (connections == null) { connections = Collections.EMPTY_LIST; }
- this.list = new ObservableElementList(
- new SortedList(
+ public Connections(Collection<RvConnection> connections, boolean ownsConnections) {
+ if (connections == null) { connections = Collections.emptyList(); }
+ this.list = new ObservableElementList<RvConnection>(
+ new SortedList<RvConnection>(
GlazedLists.eventList(connections),
new DescriptionComparator()),
new Observer());
@@ -164,7 +162,7 @@
* @param listChangeListener
* @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
*/
- public void addListEventListener(ListEventListener listChangeListener) {
+ public void addListEventListener(ListEventListener<RvConnection> listChangeListener) {
list.addListEventListener(listChangeListener);
}
@@ -192,7 +190,7 @@
}
public ListModel createListModel() {
- return new EventListModel(list);
+ return new EventListModel<RvConnection>(list);
}
/**
@@ -208,8 +206,7 @@
final Lock lock = list.getReadWriteLock().readLock();
lock.lock();
try {
- for (final Iterator i = list.iterator(); i.hasNext();) {
- final RvConnection c = (RvConnection) i.next();
+ for (RvConnection c : list) {
if (c.getService().equals(service)
&& c.getDaemon().equals(daemon)
&& c.getNetwork().equals(network))
@@ -225,7 +222,7 @@
* @return An iterator over all of the connections.
* @see java.util.List#iterator()
*/
- public Iterator iterator() {
+ public Iterator<RvConnection> iterator() {
return list.iterator();
}
@@ -258,7 +255,7 @@
* @param listChangeListener
* @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
*/
- public void removeListEventListener(ListEventListener listChangeListener) {
+ public void removeListEventListener(ListEventListener<RvConnection> listChangeListener) {
list.removeListEventListener(listChangeListener);
}
Modified: trunk/rvsn00p/src/main/rvsnoop/RvConnection.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/RvConnection.java 2008-06-03 21:52:10 UTC (rev 396)
+++ trunk/rvsn00p/src/main/rvsnoop/RvConnection.java 2008-07-09 23:39:31 UTC (rev 397)
@@ -13,7 +13,6 @@
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Collections;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -311,7 +310,7 @@
* <p>
* The map values are the RV Listeners, which may be <code>null</code>.
*/
- private final Map subjects = new TreeMap();
+ private final Map<String, TibrvListener> subjects = new TreeMap<String, TibrvListener>();
private TibrvNetTransport transport;
@@ -476,7 +475,7 @@
*
* @return A sorted (natural order) set of subjects. Elements may be cast to {@link String}.
*/
- public Set getSubjects() {
+ public Set<String> getSubjects() {
return Collections.unmodifiableSet(subjects.keySet());
}
@@ -518,12 +517,13 @@
transport.send(record.getMessage());
}
- public synchronized void removeAllSubbjects() {
- if (state != State.STOPPED)
- for (final Iterator i = subjects.values().iterator(); i.hasNext(); )
- ((TibrvEvent) i.next()).destroy();
+ public synchronized void removeAllSubjects() {
+ if (state != State.STOPPED) {
+ for (TibrvEvent event : subjects.values()) {
+ event.destroy();
+ }
+ }
subjects.clear();
- // TODO: Update this to use fireIndexedPropertyChange in SE 5.0.
changeSupport.firePropertyChange(KEY_SUBJECTS, null, null);
}
@@ -597,8 +597,7 @@
state = State.STARTED;
try {
createTransport();
- for (final Iterator i = subjects.keySet().iterator(); i.hasNext(); ) {
- final String subject = (String) i.next();
+ for (String subject : subjects.keySet()) {
subjects.put(subject, createListener(subject));
}
log.info("Started connection: " + description);
@@ -613,8 +612,9 @@
public synchronized void stop() {
if (state == State.STOPPED) return;
log.info("Stopping connection: " + description);
- for (final Iterator i = subjects.values().iterator(); i.hasNext(); )
- ((TibrvEvent) i.next()).destroy();
+ for (TibrvEvent event : subjects.values()) {
+ event.destroy();
+ }
subjects.values().clear();
transport.destroy();
transport = null;
@@ -642,8 +642,8 @@
.attribute("service", service)
.attribute("network", network)
.attribute("daemon", daemon);
- for (Iterator i = getSubjects().iterator(); i.hasNext(); ) {
- builder.startTag("subject").pcdata(i.next().toString()).endTag();
+ for (String subject : getSubjects()) {
+ builder.startTag("subject").pcdata(subject).endTag();
}
builder.endTag();
}
Modified: trunk/rvsn00p/src/main/rvsnoop/SubjectHierarchy.java
===================================================================
--- trunk/rvsn00p/src/main/rvsnoop/SubjectHierarchy.java 2008-06-03 21:52:10 UTC (rev 396)
+++ trunk/rvsn00p/src/main/rvsnoop/SubjectHierarchy.java 2008-07-09 23:39:31 UTC (rev 397)
@@ -38,27 +38,29 @@
*/
public static final String NO_SUBJECT_LABEL = "[No Subject!]";
- private static class SubjectHierarchyMatcherEditor extends AbstractMatcherEditor {
+ private static class SubjectHierarchyMatcherEditor extends AbstractMatcherEditor<Record> {
SubjectHierarchyMatcherEditor() {
super();
}
@Override
- public Matcher getMatcher() {
- return new Matcher() {
- public boolean matches(Object item) {
- SubjectElement elt = ((Record) item).getSubject();
+ public Matcher<Record> getMatcher() {
+ return new Matcher<Record>() {
+ public boolean matches(Record item) {
+ SubjectElement elt = item.getSubject();
if (!elt.isSelected()) return false;
- while ((elt = ((SubjectElement) elt.getParent())) != null)
+ while ((elt = ((SubjectElement) elt.getParent())) != null) {
if (!elt.isSelected()) return false;
+ }
return true;
}
};
}
void update(boolean selected) {
- if (selected)
+ if (selected) {
fireRelaxed(getMatcher());
- else
+ } else {
fireConstrained(getMatcher());
+ }
}
}
@@ -86,7 +88,7 @@
nodeChanged(nodes[i]);
}
- public MatcherEditor getMatcherEditor() {
+ public MatcherEditor<Record> getMatcherEditor() {
return matcherEditor;
}
@@ -174,7 +176,8 @@
/**
* Resets all counters and error flags in the hierarchy.
*/
- public void reset() {
+ @SuppressWarnings("unchecked")
+ public void reset() {
final Enumeration nodes = ((DefaultMutableTreeNode) getRoot()).depthFirstEnumeration();
while (nodes.hasMoreElements()) {
final SubjectElement current = (SubjectElement) nodes.nextElement();
@@ -189,7 +192,8 @@
* @param node The root of the subtree to set.
* @param selected The new selection value.
*/
- public void setAllSelected(SubjectElement node, boolean selected) {
+ @SuppressWarnings("unchecked")
+ public void setAllSelected(SubjectElement node, boolean selected) {
final Enumeration descendants = node.depthFirstEnumeration();
while (descendants.hasMoreElements())
updateElement((SubjectElement) descendants.nextElement(), selected);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-06-03 21:52:15
|
Revision: 396
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=396&view=rev
Author: ianp
Date: 2008-06-03 14:52:10 -0700 (Tue, 03 Jun 2008)
Log Message:
-----------
Oops! The new build file copied all of the icons into the wrong JAR
location, this resulted in slow start times and a fugly UI.
Modified Paths:
--------------
trunk/rvsn00p/build.xml
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2008-06-02 14:32:27 UTC (rev 395)
+++ trunk/rvsn00p/build.xml 2008-06-03 21:52:10 UTC (rev 396)
@@ -162,7 +162,7 @@
<attribute name="Implementation-URL" value="http://rvsnoop.org/"/>
</manifest>
<fileset dir="${dir.build}/classes/main" includes="**/*.class"/>
- <fileset dir="src/resources" includes="**/*.png"/>
+ <fileset dir="src" includes="resources/**/*.png"/>
<fileset dir="src/main" includes="**/*.properties" excludes="commons-logging.properties"/>
</jar>
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-06-02 14:32:32
|
Revision: 395
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=395&view=rev
Author: ianp
Date: 2008-06-02 07:32:27 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
Added in all redistributable libraries.
Added Paths:
-----------
trunk/rvsn00p/lib/beansbinding-1.2.1-doc.zip
trunk/rvsn00p/lib/beansbinding-1.2.1-src.zip
trunk/rvsn00p/lib/beansbinding-1.2.1.jar
trunk/rvsn00p/lib/commons-cli-1.0-doc.zip
trunk/rvsn00p/lib/commons-cli-1.0-src.zip
trunk/rvsn00p/lib/commons-cli-1.0.jar
trunk/rvsn00p/lib/commons-io-1.3.1-doc.zip
trunk/rvsn00p/lib/commons-io-1.3.1-src.zip
trunk/rvsn00p/lib/commons-io-1.3.1.jar
trunk/rvsn00p/lib/commons-lang-2.3-doc.zip
trunk/rvsn00p/lib/commons-lang-2.3-src.zip
trunk/rvsn00p/lib/commons-lang-2.3.jar
trunk/rvsn00p/lib/commons-logging-1.1-doc.zip
trunk/rvsn00p/lib/commons-logging-1.1-src.zip
trunk/rvsn00p/lib/commons-logging-1.1.jar
trunk/rvsn00p/lib/glazed-lists-1.7.0-doc.zip
trunk/rvsn00p/lib/glazed-lists-1.7.0-src.zip
trunk/rvsn00p/lib/glazed-lists-1.7.0.jar
trunk/rvsn00p/lib/jgoodies-forms-1.2.0-doc.zip
trunk/rvsn00p/lib/jgoodies-forms-1.2.0-src.zip
trunk/rvsn00p/lib/jgoodies-forms-1.2.0.jar
trunk/rvsn00p/lib/jgoodies-looks-2.1.4-doc.zip
trunk/rvsn00p/lib/jgoodies-looks-2.1.4-src.zip
trunk/rvsn00p/lib/jgoodies-looks-2.1.4.jar
trunk/rvsn00p/lib/junit-4.4-doc.zip
trunk/rvsn00p/lib/junit-4.4-src.zip
trunk/rvsn00p/lib/junit-4.4.jar
trunk/rvsn00p/lib/swing-layout-1.0.3-doc.zip
trunk/rvsn00p/lib/swing-layout-1.0.3-src.zip
trunk/rvsn00p/lib/swing-layout-1.0.3.jar
trunk/rvsn00p/lib/xmlenc-0.52-doc.zip
trunk/rvsn00p/lib/xmlenc-0.52-src.zip
trunk/rvsn00p/lib/xmlenc-0.52.jar
trunk/rvsn00p/lib/xom-1.1-doc.zip
trunk/rvsn00p/lib/xom-1.1-src.zip
trunk/rvsn00p/lib/xom-1.1.jar
Added: trunk/rvsn00p/lib/beansbinding-1.2.1-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/beansbinding-1.2.1-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/beansbinding-1.2.1-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/beansbinding-1.2.1-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/beansbinding-1.2.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/beansbinding-1.2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-cli-1.0-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-cli-1.0-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-cli-1.0-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-cli-1.0-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-cli-1.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-cli-1.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-io-1.3.1-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-io-1.3.1-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-io-1.3.1-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-io-1.3.1-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-io-1.3.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-io-1.3.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-lang-2.3-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-lang-2.3-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-lang-2.3-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-lang-2.3-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-lang-2.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-lang-2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-logging-1.1-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-logging-1.1-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-logging-1.1-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-logging-1.1-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/commons-logging-1.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/commons-logging-1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/glazed-lists-1.7.0-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/glazed-lists-1.7.0-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/glazed-lists-1.7.0-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/glazed-lists-1.7.0-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/glazed-lists-1.7.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/glazed-lists-1.7.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-forms-1.2.0-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-forms-1.2.0-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-forms-1.2.0-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-forms-1.2.0-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-forms-1.2.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-forms-1.2.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-looks-2.1.4-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-looks-2.1.4-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-looks-2.1.4-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-looks-2.1.4-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/jgoodies-looks-2.1.4.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/jgoodies-looks-2.1.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/junit-4.4-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/junit-4.4-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/junit-4.4-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/junit-4.4-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/junit-4.4.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/junit-4.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/swing-layout-1.0.3-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/swing-layout-1.0.3-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/swing-layout-1.0.3-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/swing-layout-1.0.3-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/swing-layout-1.0.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/swing-layout-1.0.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xmlenc-0.52-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xmlenc-0.52-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xmlenc-0.52-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xmlenc-0.52-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xmlenc-0.52.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xmlenc-0.52.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xom-1.1-doc.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xom-1.1-doc.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xom-1.1-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xom-1.1-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/lib/xom-1.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/lib/xom-1.1.jar
___________________________________________________________________
Name: 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: <ia...@us...> - 2008-06-02 14:24:22
|
Revision: 394
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=394&view=rev
Author: ianp
Date: 2008-06-02 07:24:20 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
Added dummy file for use with IDE based launches.
Added Paths:
-----------
trunk/rvsn00p/src/main/META-INF/build.properties
Added: trunk/rvsn00p/src/main/META-INF/build.properties
===================================================================
--- trunk/rvsn00p/src/main/META-INF/build.properties (rev 0)
+++ trunk/rvsn00p/src/main/META-INF/build.properties 2008-06-02 14:24:20 UTC (rev 394)
@@ -0,0 +1,10 @@
+#Dummy build information file for use in IDEs.
+# This prevents the version class from blowing up when launched from within
+# an IDE (i.e. when the full build has not been run).
+build.os.version=10.4.10
+build.os.name=Mac OS X
+build.date=2007-11-12 23\:29\:21
+build.java.vendor=Apple Computer, Inc.
+build.os.arch=ppc
+build.java.version=1.5.0_07
+build.version=1.6.2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2008-06-02 14:22:40
|
Revision: 393
http://rvsn00p.svn.sourceforge.net/rvsn00p/?rev=393&view=rev
Author: ianp
Date: 2008-06-02 07:22:38 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
Changes that have been sat uncommitted on my laptop for far too long!
Mainly reorganising the project structure.
Modified Paths:
--------------
trunk/rvsn00p/build.xml
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/CausedIOException.java
trunk/rvsn00p/src/main/org/rvsnoop/CausedIllegalArgumentException.java
trunk/rvsn00p/src/main/org/rvsnoop/FastFileHandler.java
trunk/rvsn00p/src/main/org/rvsnoop/FastFormatter.java
trunk/rvsn00p/src/main/org/rvsnoop/InterningTrimmingNodeFactory.java
trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java
trunk/rvsn00p/src/main/org/rvsnoop/Project.java
trunk/rvsn00p/src/main/org/rvsnoop/ProjectFileFilter.java
trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java
trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Copy.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Cut.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Delete.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/DisplayAbout.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/EditRecordTypes.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/ExportToFile.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Filter.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/FilterBySelection.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/NewRvConnection.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/OpenProject.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Paste.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/PauseConnection.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/PruneEmptySubjects.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/RvSnoopAction.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/SaveProject.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/SaveProjectAs.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/Search.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/SearchBySelection.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/SelectAllRecords.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/ShowAllColumns.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/StartConnection.java
trunk/rvsn00p/src/main/org/rvsnoop/actions/StopConnection.java
trunk/rvsn00p/src/main/org/rvsnoop/io/HTMLExportFormat.java
trunk/rvsn00p/src/main/org/rvsnoop/io/RecordBundleV1ExportFormat.java
trunk/rvsn00p/src/main/org/rvsnoop/io/RvScriptExportFormat.java
trunk/rvsn00p/src/main/org/rvsnoop/io/RvTestExportFormat.java
trunk/rvsn00p/src/main/org/rvsnoop/matchers/DataAccessor.java
trunk/rvsn00p/src/main/org/rvsnoop/matchers/Predicate.java
trunk/rvsn00p/src/main/org/rvsnoop/matchers/RvSnoopMatcherEditor.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/GhostGlassPane.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/HeaderPanel.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/ImageFactory.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RecordLedgerTable.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/RecordTypesDialog.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/ReorderableList.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/SearchResultsDialog.java
trunk/rvsn00p/src/main/org/rvsnoop/ui/StatusBar.java
trunk/rvsn00p/src/main/rvsnoop/Marshaller.java
trunk/rvsn00p/src/main/rvsnoop/MessageLedger.java
trunk/rvsn00p/src/main/rvsnoop/Record.java
trunk/rvsn00p/src/main/rvsnoop/RecordMatcher.java
trunk/rvsn00p/src/main/rvsnoop/RecordType.java
trunk/rvsn00p/src/main/rvsnoop/RecordTypes.java
trunk/rvsn00p/src/main/rvsnoop/RvConnection.java
trunk/rvsn00p/src/main/rvsnoop/State.java
trunk/rvsn00p/src/main/rvsnoop/SubjectElement.java
trunk/rvsn00p/src/main/rvsnoop/SubjectHierarchy.java
trunk/rvsn00p/src/main/rvsnoop/Version.java
trunk/rvsn00p/src/main/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/main/rvsnoop/actions/ExportToHtml.java
trunk/rvsn00p/src/main/rvsnoop/actions/ExportToRecordBundle.java
trunk/rvsn00p/src/main/rvsnoop/actions/ExportToRvScript.java
trunk/rvsn00p/src/main/rvsnoop/actions/ExportToRvTest.java
trunk/rvsn00p/src/main/rvsnoop/actions/ImportFromRecordBundle.java
trunk/rvsn00p/src/main/rvsnoop/ui/FontChooser.java
trunk/rvsn00p/src/main/rvsnoop/ui/MultiLineToolTipUI.java
trunk/rvsn00p/src/main/rvsnoop/ui/SubjectExplorerEditor.java
trunk/rvsn00p/src/main/rvsnoop/ui/SubjectExplorerRenderer.java
trunk/rvsn00p/src/main/rvsnoop/ui/UIManager.java
trunk/rvsn00p/src/test/org/rvsnoop/FilteredLedgerViewTest.java
trunk/rvsn00p/src/test/org/rvsnoop/InMemoryLedgerTest.java
trunk/rvsn00p/src/test/org/rvsnoop/RecordLedgerTest.java
Added Paths:
-----------
trunk/rvsn00p/etc/
trunk/rvsn00p/etc/rvsnoop.pmd
trunk/rvsn00p/lib/
trunk/rvsn00p/src/main/
trunk/rvsn00p/src/main/META-INF/
trunk/rvsn00p/src/main/commons-logging.properties
trunk/rvsn00p/src/main/org/
trunk/rvsn00p/src/main/rvsnoop/
trunk/rvsn00p/src/test/
trunk/rvsn00p/src/test/data/
trunk/rvsn00p/src/test/org/
Removed Paths:
-------------
trunk/rvsn00p/.lint4jprefs
trunk/rvsn00p/build.properties
trunk/rvsn00p/rvsnoop.pmd
trunk/rvsn00p/src/commons-logging.properties
trunk/rvsn00p/src/org/
trunk/rvsn00p/src/rvsnoop/
trunk/rvsn00p/tests/data/
trunk/rvsn00p/tests/org/
trunk/rvsn00p/version.xml
Deleted: trunk/rvsn00p/.lint4jprefs
===================================================================
--- trunk/rvsn00p/.lint4jprefs 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/.lint4jprefs 2008-06-02 14:22:38 UTC (rev 393)
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><Lint4j><Audits><Audit id="J2SEGroup.audit1"/><Audit id="J2SEGroup.audit2"/><Audit id="J2SEGroup.audit4"/><Audit id="J2SEGroup.audit5"/><Audit id="J2SEGroup.audit6"/><Audit id="J2SEGroup.audit7"/><Audit id="J2SEGroup.audit8"/><Audit id="J2SEGroup.audit9"/><Audit id="J2SEGroup.audit10"/><Audit id="J2SEGroup.audit11"/><Audit id="J2SEGroup.audit12"/><Audit id="J2SEGroup.audit14"/><Audit id="J2SEGroup.audit16"/><Audit id="SerializationGroup.audit1"/><Audit id="SerializationGroup.audit2"/><Audit id="SerializationGroup.audit3"/><Audit id="SerializationGroup.audit4"/><Audit id="SerializationGroup.audit5"/><Audit id="SerializationGroup.audit6"/><Audit id="SerializationGroup.audit7"/><Audit id="SerializationGroup.audit8"/><Audit id="SerializationGroup.audit9"/><Audit id="SerializationGroup.audit10"/><Audit id="SerializationGroup.audit11"/><Audit id="MaturityGroup.audit1"/><Audit id="MaturityGroup.audit2"/><Audit id="MaturityGroup.audit3"/><Audit id="MaturityGroup.audit4"/><Audit id="MaturityGroup.audit5"/><Audit id="MaturityGroup.audit6"/><Audit id="MaturityGroup.audit7"/><Audit id="MaturityGroup.audit8"/><Audit id="MaturityGroup.audit9"/><Audit id="MaturityGroup.audit11"/><Audit id="MaturityGroup.audit12"/><Audit id="MaturityGroup.audit13"/><Audit id="MaturityGroup.audit14"/><Audit id="MaturityGroup.audit15"/><Audit id="MaturityGroup.audit16"/><Audit id="MaturityGroup.audit17"/><Audit id="MaturityGroup.audit18"/><Audit id="MaturityGroup.audit19"/><Audit id="MaturityGroup.audit20"/><Audit id="MaturityGroup.audit21"/><Audit id="MaturityGroup.audit22"/><Audit id="MaturityGroup.audit23"/><Audit id="PerformanceGroup.audit1"/><Audit id="PerformanceGroup.audit2"/></Audits></Lint4j>
\ No newline at end of file
Deleted: trunk/rvsn00p/build.properties
===================================================================
--- trunk/rvsn00p/build.properties 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/build.properties 2008-06-02 14:22:38 UTC (rev 393)
@@ -1,51 +0,0 @@
-# ANT build properties for rvSnoop.
-# Set the library paths to match your system, optionally set the build options.
-# Additionally, JSCH is required to publish the web site, it should be set on
-# the system CLASSPATH.
-# $Id$
-
-# Library Paths
-# tibco, tibco.rv, and tibco.sdk should point to install folders.
-# All others should point to the JAR files directly.
-tibco=/opt/tibco/
-tibco.rv=${tibco}/tibrv
-tibco.sdk=${tibco}/tra/5.2
-tibco.rvscript=${tibco}/rvscript-1.35/rvscript.jar
-tibco.rvtest=${tibco}/rvtest-1.0b3/lib/rvtest-1.0-beta-3.jar
-lib.binding=/usr/local/share/java/binding-1.2.0/binding-1.2.0.jar
-lib.cli=/usr/local/share/java/commons-cli-1.0/commons-cli-1.0.jar
-lib.forms=/usr/local/share/java/forms-1.0.7/forms-1.0.7.jar
-lib.glazed=/usr/local/share/java/glazedlists-1.7.0/glazedlists.jar
-lib.io=/usr/local/share/java/commons-io-1.3.1/commons-io-1.3.1.jar
-lib.lang=/usr/local/share/java/commons-lang-2.3/commons-lang-2.3.jar
-lib.logging=/usr/local/share/java/commons-logging-1.1/commons-logging-1.1.jar
-lib.looks=/usr/local/share/java/looks-2.1.0/looks-2.1.0.jar
-lib.swinglayout=/usr/local/share/java/swing-layout-1.0.1/swing-layout-1.0.1.jar
-lib.wizard=/usr/local/share/java/wizard-0.1.12/wizard-0.1.12.jar
-lib.xmlenc=/usr/local/share/java/xmlenc-0.52/xmlenc.jar
-lib.xom=/usr/local/share/java/xom-1.1/xom-1.1.jar
-
-# The following libraries are used by the build process, they are not needed at runtime.
-
-# FindBugs should point to the install directory, not the JAR file.
-lib.findbugs=/usr/local/share/java/findbugs-1.1.2
-lib.junit=/usr/local/share/java/junit-3.8.1/junit.jar
-lib.lint4j=/usr/local/share/java/lint4j-0.9.1/jars/lint4j.jar
-# This should contain all of the JARs needed by PMD.
-lib.pmd=/usr/local/share/java/pmd-3.9/lib/pmd-3.9.jar:/usr/local/share/java/pmd-3.9/lib/asm-3.0.jar:/Users/ianp/Library/Java/PMD 3.9/lib/backport-util-concurrent.jar:/usr/local/share/java/pmd-3.9/lib/jaxen-1.1-beta-10.jar
-lib.saxon=/usr/local/share/java/saxon-8.8/saxon.jar
-
-# The svnversion command is needed to set the build number correctly.
-svnversion=/usr/local/bin/svnversion
-# If you are building with a non-standard JDK (e.g. GCJ) you may need to change this.
-java.lib=${java.home}/lib/rt.jar
-
-# Build Options
-#skip.setbuildversion=true
-#skip.genjavadoc=true
-#skip.analyze=true
-javac.debug=true
-javac.optimize=true
-javac.deprecation=false
-javadoc.access=public
-javadoc.offline=false
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/build.xml 2008-06-02 14:22:38 UTC (rev 393)
@@ -1,240 +1,159 @@
<?xml version='1.0' encoding='UTF-8'?>
-<!-- Build file tested with Ant version 1.6.5. -->
+<!-- Build file tested with Ant version 1.7.0. -->
<!-- $Id$ -->
-<project name="rvsnoop" default="printusage" basedir=".">
- <description>A TIBCO Rendezvous message viewing utility.</description>
+<project name="rvsnoop" default="dist" basedir=".">
+
+ <description>
+ A TIBCO Rendezvous message viewing utility.
+ </description>
+
+ <property name="version" value="1.6.2"/>
+ <tstamp/>
+ <tstamp><format property="tstamp.date" pattern="yyyy-MM-dd HH:mm:ss"/></tstamp>
- <!-- Display a short help message and exit. -->
- <target name="printusage">
- <echo>Use "ant -projecthelp" to get a list of build targets. </echo>
- <echo> </echo>
- <echo>Copy build.properties to local.properties and configure your </echo>
- <echo>build environment. This will prevent your changes from being </echo>
- <echo>overwritten when you synchronize your working folder. </echo>
- <echo> </echo>
- <echo>You will need to add the JUnit JAR to your CLASSPATH in order </echo>
- <echo>to run the unit tests (and thus to build a distribution). </echo>
- </target>
+ <target name="init">
+ <property file="build.properties"/>
- <!-- Set the timestamps and read the properties file. -->
- <target name="settimestamp">
- <tstamp/>
- <tstamp><format property="build.date" pattern="yyyy-MM-dd HH:mm:ss"/></tstamp>
- <tstamp><format property="build.year" pattern="yyyy"/></tstamp>
- <echo>Timestamp for build set to: ${build.date}</echo>
- <property file="local.properties"/>
- </target>
+ <!-- Override this to change the location of the build. -->
+ <property name="dir.build" value="build"/>
- <!-- Get the build version. -->
- <target name="setbuildversion" unless="skip.setbuildversion" depends="settimestamp">
- <exec executable="${svnversion}" spawn="false" dir="." output="build.number" failifexecutionfails="false">
- <arg line="."/>
- </exec>
- <replaceregexp file="build.number" match="([0-9]+).*" replace="build.svnversion=\1" />
- <property file="build.number" />
- <delete file="build.number" />
- </target>
+ <!-- Override these to control the build. -->
+ <property name="javac.debug" value="true"/>
+ <property name="javac.optimize" value="true"/>
+ <property name="javac.deprecation" value="false"/>
+ <property name="javadoc.offline" value="false"/>
- <!-- Configure the properties and filtersets. -->
- <target name="setproperties" depends="setbuildversion">
- <property name="version.major" value="1"/>
- <property name="version.minor" value="6"/>
- <property name="version.patch" value="1"/>
- <property name="version.alpha" value="false"/>
- <property name="version.beta" value="false"/>
- <property name="version" value="${version.major}.${version.minor}.${version.patch}"/>
- <property name="dir.stage" value="stage"/>
- <property name="dir.build" value="build"/>
- <property name="dir.dist" value="dist/rvsnoop-${version}"/>
- <!-- Import environment variables as properties, prefixed with "env". -->
- <property environment="env"/>
- <path id="path.class">
- <!-- Define our class path first. -->
- <pathelement location="${tibco.rv}/lib/tibrvj.jar"/>
- <pathelement location="${tibco.sdk}/lib/TIBCOrt.jar"/>
- <pathelement location="${tibco.rvscript}"/>
- <pathelement location="${tibco.rvtest}"/>
- <pathelement location="${lib.binding}"/>
- <pathelement location="${lib.cli}"/>
- <pathelement location="${lib.forms}"/>
- <pathelement location="${lib.glazed}"/>
- <pathelement location="${lib.io}"/>
- <pathelement location="${lib.lang}"/>
- <pathelement location="${lib.logging}"/>
- <pathelement location="${lib.looks}"/>
- <pathelement location="${lib.swinglayout}"/>
- <pathelement location="${lib.wizard}"/>
- <pathelement location="${lib.xmlenc}"/>
- <pathelement location="${lib.xom}"/>
+ <!-- If you are building with a non-Sun JDK you may need to change this. -->
+ <property name="lib.java" value="${java.home}/lib/rt.jar"/>
+
+ <!-- Override these to change the locations of the dependencies. -->
+ <property name="lib.rvscript" value="/opt/tibco/rvscript-1.35/rvscript.jar"/>
+ <property name="lib.rvtest" value="/opt/tibco/rvtest-1.0b3/lib/rvtest-1.0-beta-3.jar"/>
+ <property name="lib.tibrv" value="/opt/tibco/tibrv/lib/tibrvj.jar"/>
+ <property name="lib.tibsdk" value="/opt/tibco/tra/5.5/lib/TIBCOrt.jar"/>
+
+ <!-- These are only used to run the analytics target. -->
+ <property name="lib.findbugs" value="${user.home}/Library/Java/findbugs-1.3.0"/>
+ <property name="lib.pmd" value="${user.home}/Library/Java/pmd-4.1rc1"/>
+
+ <fileset id="include.classpath" dir="lib">
+ <include name="*.jar"/>
+ <exclude name="junit*"/>
+ </fileset>
+
+ <path id="compile.classpath">
+ <fileset refid="include.classpath"/>
+ <path location="${lib.tibrv}"/>
+ <path location="${lib.tibsdk}"/>
+ <path location="${lib.rvscript}"/>
+ <path location="${lib.rvtest}"/>
</path>
- <condition property="build.number" value="${build.svnversion}" else="0">
- <isset property="build.svnversion"/>
- </condition>
- <echo>Build number set to ${build.number}.</echo>
+
+ <path id="test.classpath">
+ <path refid="compile.classpath"/>
+ <path location="lib/junit-4.4.jar"/>
+ <path location="${dir.build}/classes/main"/>
+ <path location="${dir.build}/classes/test"/>
+ </path>
+
+ <fileset id="test.data" dir="src/test">
+ <include name="**/*.properties"/>
+ <include name="**/*.rbz"/>
+ <include name="**/*.txt"/>
+ </fileset>
+
<filterset id="filters">
- <filter token="version.major" value="${version.major}"/>
- <filter token="version.minor" value="${version.minor}"/>
- <filter token="version.patch" value="${version.patch}"/>
- <filter token="version.alpha" value="${version.alpha}"/>
- <filter token="version.beta" value="${version.beta}"/>
<filter token="version" value="${version}"/>
<filter token="java.vendor" value="${java.vendor}"/>
<filter token="java.version" value="${java.version}"/>
<filter token="os.name" value="${os.name}"/>
<filter token="os.version" value="${os.version}"/>
<filter token="os.arch" value="${os.arch}"/>
- <filter token="build.number" value="${build.number}"/>
- <filter token="build.date" value="${build.date}"/>
+ <filter token="tstamp.date" value="${build.date}"/>
<filter token="suffix" value="${file.suffix}"/>
- <filter token="year" value="${build.year}"/>
</filterset>
- </target>
- <target name="stage" depends="setproperties"
- description="Prepare the files for the build.">
- <mkdir dir="${dir.stage}/bin"/>
- <mkdir dir="${dir.stage}/doc/developer"/>
- <mkdir dir="${dir.stage}/src"/>
- <mkdir dir="${dir.stage}/tests"/>
- <mkdir dir="${dir.stage}/www"/>
- <echo>Moving all files to staging area: ${dir.stage}</echo>
- <copy todir="${dir.stage}" file="version.xml" encoding="UTF-8">
- <filterset refid="filters"/>
- </copy>
- <copy todir="${dir.stage}/bin" encoding="UTF-8">
- <filterset refid="filters"/>
- <fileset dir="bin" includes="*.cmd, *.sh"/>
- </copy>
- <copy todir="${dir.stage}/bin">
- <fileset dir="bin" includes="*.ico"/>
- </copy>
- <chmod dir="${dir.stage}/bin" includes="*.sh" perm="750"/>
- <copy todir="${dir.stage}/src" encoding="UTF-8">
- <filterset refid="filters"/>
- <fileset dir="src" includes="**/*.java, **/*.properties"/>
- </copy>
- <copy todir="${dir.stage}/src">
- <fileset dir="src" includes="**/*.png"/>
- </copy>
- <copy todir="${dir.stage}/tests" encoding="UTF-8">
- <filterset refid="filters"/>
- <fileset dir="tests" includes="**/*.java, **/*.properties, **/*.txt"/>
- </copy>
- <copy todir="${dir.stage}/tests">
- <fileset dir="tests" includes="**/*.rbz"/>
- </copy>
- <copy todir="${dir.stage}/doc" encoding="UTF-8">
- <filterset refid="filters"/>
- <fileset dir="doc" includes="**/*.html, **/*.css"/>
- </copy>
- <copy todir="${dir.stage}/doc">
- <fileset dir="doc" includes="**/*.png"/>
- </copy>
- <copy todir="${dir.stage}/www" encoding="UTF-8">
- <filterset refid="filters"/>
- <fileset dir="www" includes="*.html, *.css"/>
- </copy>
- <copy todir="${dir.stage}/www">
- <fileset dir="www" includes="**/*.png, **/*.gif"/>
- </copy>
+ <mkdir dir="${dir.build}/classes/main/META-INF"/>
+ <mkdir dir="${dir.build}/classes/test"/>
+ <mkdir dir="${dir.build}/doc/user"/>
+ <mkdir dir="${dir.build}/doc/developer/test"/>
+ <mkdir dir="${dir.build}/dist/bin"/>
+ <mkdir dir="${dir.build}/dist/doc"/>
+ <mkdir dir="${dir.build}/dist/lib"/>
+ <mkdir dir="${dir.build}/dist/src"/>
</target>
- <target name="compile" depends="stage"
- description="Compile all of the Java class files (including tests).">
- <echo>Compiling application.</echo>
- <mkdir dir="${dir.build}/classes/main"/>
- <javac srcdir="${dir.stage}/src" destdir="${dir.build}/classes/main" includes="**/*.java"
+ <target name="compile" depends="init"
+ description="Compile all of the Java class files (excluding tests).">
+ <javac srcdir="src/main" destdir="${dir.build}/classes/main" includes="**/*.java"
debug="${javac.debug}" optimize="${javac.optimize}" encoding="UTF-8"
- deprecation="${javac.deprecation}" source="1.4" target="1.4">
- <classpath refid="path.class"/>
+ deprecation="${javac.deprecation}" source="1.5" target="1.5">
+ <classpath refid="compile.classpath"/>
</javac>
- <echo>Compiling unit tests.</echo>
- <mkdir dir="${dir.build}/classes/tests"/>
- <javac srcdir="${dir.stage}/tests" destdir="${dir.build}/classes/tests" includes="**/*.java"
- debug="${javac.debug}" optimize="${javac.optimize}" encoding="UTF-8"
- deprecation="${javac.deprecation}" source="1.4" target="1.4">
- <classpath>
- <path refid="path.class"/>
- <pathelement location="${dir.build}/classes/main"/>
- <pathelement location="${lib.junit}"/>
- </classpath>
- </javac>
+ <propertyfile comment="Build Information" file="${dir.build}/classes/main/META-INF/build.properties">
+ <entry key="build.version" value="${version}"/>
+ <entry key="build.date" value="${tstamp.date}"/>
+ <entry key="build.java.vendor" value="${java.vendor}"/>
+ <entry key="build.java.version" value="${java.version}"/>
+ <entry key="build.os.name" value="${os.name}"/>
+ <entry key="build.os.arch" value="${os.arch}"/>
+ <entry key="build.os.version" value="${os.version}"/>
+ </propertyfile>
</target>
- <target name="genjavadoc" depends="stage" unless="skip.genjavadoc"
- description="Compile all of the Java API documentation.">
- <mkdir dir="${dir.build}/doc/api"/>
- <javadoc destdir="${dir.build}/doc/api" version="true" author="true"
- use="true" source="1.4" access="${javadoc.access}"
- windowtitle="RvSnoop ${version} API Documentation">
- <doctitle><![CDATA[<h1>RvSnoop ${version}</h1>]]></doctitle>
- <bottom><![CDATA[Copyright © 2002-${year} <a href="http://ianp.org/">Ian Phillips</a> and Örjan Lundberg.]]></bottom>
- <packageset dir="${dir.stage}/src" defaultexcludes="true" includes="**"/>
- <link href="http://java.sun.com/j2se/1.4.2/docs/api" offline="${javadoc.offline}"/>
- <link href="http://www.xom.nu/apidocs" offline="${javadoc.offline}"/>
- <classpath refid="path.class"/>
- </javadoc>
- </target>
-
- <target name="runtests" depends="compile"
- description="Run the unit tests.">
- <mkdir dir="${dir.build}/doc/developer/tests"/>
+ <target name="test" depends="compile"
+ description="Compile and run the unit tests.">
+ <javac srcdir="src/test" destdir="${dir.build}/classes/test" includes="**/*.java"
+ debug="true" optimize="false" encoding="UTF-8"
+ deprecation="${javac.deprecation}" source="1.5" target="1.5">
+ <classpath refid="test.classpath"/>
+ </javac>
+ <copy todir="${dir.build}/classes/test">
+ <fileset refid="test.data"/>
+ </copy>
<junit printsummary="true" haltonerror="true" fork="true" forkmode="perBatch">
- <classpath>
- <path refid="path.class"/>
- <pathelement location="${dir.build}/classes/main"/>
- <pathelement location="${dir.build}/classes/tests"/>
- <!-- This is needed to access the test data. -->
- <pathelement location="${dir.stage}/tests"/>
- </classpath>
+ <classpath refid="test.classpath"/>
<formatter type="xml"/>
- <batchtest todir="${dir.build}/doc/developer/tests">
- <fileset dir="${dir.build}/classes/tests">
+ <batchtest todir="${dir.build}/doc/developer/test">
+ <fileset dir="${dir.build}/classes/test">
<include name="**/*Test.class"/>
- <!-- The are all abstract an will cause the tests to fail if run. -->
+ <!-- Exclude all of the abstract classes. -->
<exclude name="org/rvsnoop/RecordLedgerTest.class"/>
</fileset>
</batchtest>
</junit>
- <echo>Generating report from test results.</echo>
- <junitreport todir="${dir.build}/doc/developer/tests">
- <!-- This fileset includes just the individual tests. -->
- <fileset dir="${dir.build}/doc/developer/tests">
+ <junitreport todir="${dir.build}/doc/developer/test">
+ <!-- Just the individual tests. -->
+ <fileset dir="${dir.build}/doc/developer/test">
<include name="TEST-*.xml"/>
</fileset>
- <report todir="${dir.build}/doc/developer/tests"/>
+ <report todir="${dir.build}/doc/developer/test"/>
</junitreport>
<delete>
- <!-- This fileset includes both the individual and aggregated tests. -->
- <fileset dir="${dir.build}/doc/developer/tests">
+ <!-- Both individual and aggregated tests. -->
+ <fileset dir="${dir.build}/doc/developer/test">
<include name="TEST*.xml"/>
</fileset>
</delete>
</target>
- <target name="dist" depends="runtests, analyze, genjavadoc"
- description="Package all files required for a binary distribution.">
- <echo>Preparing the distribution file layout.</echo>
- <mkdir dir="${dir.dist}/bin"/>
- <mkdir dir="${dir.dist}/doc"/>
- <mkdir dir="${dir.dist}/lib"/>
- <mkdir dir="${dir.dist}/src"/>
- <echo>Copying in the version file.</echo>
- <copy file="${dir.stage}/version.xml" todir="${dir.dist}"/>
- <echo>Copying in the launcher scripts.</echo>
- <copy todir="${dir.dist}/bin">
- <fileset dir="${dir.stage}/bin" includes="*"/>
- </copy>
- <chmod dir="${dir.dist}/bin" includes="*.sh" perm="750"/>
- <echo>Copying in the documentation.</echo>
- <copy todir="${dir.dist}/doc">
- <fileset dir="${dir.build}/doc"/>
- </copy>
- <copy todir="${dir.dist}/doc">
- <fileset dir="${dir.stage}/doc" includes="**/*"/>
- </copy>
- <echo>Copying in the runtime libraries.</echo>
- <jar jarfile="${dir.dist}/lib/rvsnoop.jar" compress="false"
+ <target name="javadoc" depends="init"
+ description="Compile all of the Java API documentation.">
+ <mkdir dir="${dir.build}/doc/api"/>
+ <javadoc destdir="${dir.build}/doc/api" version="true" author="true"
+ use="true" source="1.5" access="protected"
+ windowtitle="RvSnoop ${version} API Documentation">
+ <doctitle><![CDATA[<h1>RvSnoop ${version}</h1>]]></doctitle>
+ <bottom><![CDATA[Copyright © 2002-2007 <a href="http://ianp.org/">Ian Phillips</a> and Örjan Lundberg.]]></bottom>
+ <packageset dir="src/main" defaultexcludes="true" includes="**"/>
+ <link href="http://java.sun.com/j2se/1.4.2/docs/api" offline="${javadoc.offline}"/>
+ <link href="http://www.xom.nu/apidocs" offline="${javadoc.offline}"/>
+ <classpath refid="compile.classpath"/>
+ </javadoc>
+ </target>
+
+ <target name="jar" depends="test">
+ <jar jarfile="${dir.build}/dist/lib/rvsnoop-${version}.jar" compress="false"
manifestencoding="UTF-8" index="true">
<manifest>
<attribute name="Implementation-Title" value="RvSnoop"/>
@@ -243,105 +162,81 @@
<attribute name="Implementation-URL" value="http://rvsnoop.org/"/>
</manifest>
<fileset dir="${dir.build}/classes/main" includes="**/*.class"/>
- <fileset dir="${dir.stage}/src" includes="**/*.png"/>
- <fileset dir="${dir.stage}/src" includes="**/*.properties" excludes="commons-logging.properties"/>
+ <fileset dir="src/resources" includes="**/*.png"/>
+ <fileset dir="src/main" includes="**/*.properties" excludes="commons-logging.properties"/>
</jar>
- <copy todir="${dir.dist}/lib">
- <fileset file="${lib.binding}"/>
- <fileset file="${lib.cli}"/>
- <fileset file="${lib.forms}"/>
- <fileset file="${lib.glazed}"/>
- <fileset file="${lib.io}"/>
- <fileset file="${lib.lang}"/>
- <fileset file="${lib.logging}"/>
- <fileset file="${lib.looks}"/>
- <fileset file="${lib.swinglayout}"/>
- <fileset file="${lib.wizard}"/>
- <fileset file="${lib.xmlenc}"/>
- <fileset file="${lib.xom}"/>
- <fileset file="${dir.stage}/src/*.properties"/>
- </copy>
- <echo>Copying in the source code.</echo>
- <copy todir="${dir.dist}/src">
- <fileset dir="${dir.stage}/src" includes="**/*.java, **/*.properties"/>
- </copy>
- <echo>Packaging the distributable.</echo>
- <tar destfile="rvsnoop-${version}.tgz" compression="gzip">
- <tarfileset dir="${dir.dist}/.." mode="440" dirmode="550">
- <include name="**/*.*"/>
- <include name="rvsnoop-${version}/${file.version}"/>
- <exclude name="rvsnoop-${version}/bin/*.sh"/>
- </tarfileset>
- <tarfileset dir="${dir.dist}/.." mode="750" dirmode="550">
- <include name="rvsnoop-${version}/bin/*.sh"/>
- </tarfileset>
- </tar>
</target>
- <target name="release" depends="dist"
- description="Upload the files to SourceForge ready for releasing.">
- <input addproperty="release.email">Enter the email address to use for anonymous FTP:</input>
- <ftp server="upload.sourceforge.net" userid="anonymous" binary="true" password="${release.email}">
- <fileset file="rvsnoop-${version}.tgz"/>
- </ftp>
- <echo>Now do the SourceForge file release</echo>
- <echo>Then run "ant releasewww" to upload the new site version.</echo>
- </target>
-
- <target name="releasewww" depends="stage"
- description="Publish the files to the web server.">
- <input addproperty="ssh.user">Enter your SSH username:</input>
- <input addproperty="ssh.pass">Enter your SSH password:</input>
- <scp todir="${ssh.user}@rvsnoop.org:/users/home/iphillips/domains/rvsnoop.org/web/public"
- password="${ssh.pass}" trust="false">
- <fileset dir="${dir.stage}/www" include="**/*"/>
- <fileset dir="${dir.stage}" include="version.xml"/>
- </scp>
- </target>
-
- <target name="analyze" depends="compile" unless="skip.analyze"
+ <target name="analyze" depends="compile"
description="Analyze the code base and generate reports.">
- <taskdef name="pmd" classpath="${lib.pmd}"
- classname="net.sourceforge.pmd.ant.PMDTask"/>
- <taskdef name="lint4j" classpath="${lib.lint4j}"
- classname="com.jutils.lint4j.ant.Lint4jAntTask"/>
- <taskdef name="findbugs" classpath="${lib.findbugs}/lib/findbugs-ant.jar"
- classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
- <property name="findbugs.home" value="${lib.findbugs}"/>
- <echo>Analyzing with PMD.</echo>
+
+ <echo>Analyzing with PMD...</echo>
+ <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
+ <classpath>
+ <fileset dir="${lib.pmd}/lib" includes="*.jar"/>
+ </classpath>
+ </taskdef>
<pmd shortFilenames="true" encoding="UTF-8">
- <ruleset>rvsnoop.pmd</ruleset>
- <formatter type="html" toFile="${dir.build}/doc/developer/pmdreport.html"
- linkPrefix="file://../../src/"/>
- <fileset dir="${dir.stage}/src" includes="**/*.java"/>
+ <ruleset>etc/rvsnoop.pmd</ruleset>
+ <formatter type="html" toFile="${dir.build}/doc/developer/pmd-report.html"
+ linkPrefix="file://../../src/main/"/>
+ <fileset dir="src/main" includes="**/*.java"/>
</pmd>
- <echo>Analyzing with Lint4J.</echo>
- <lint4j sourcepath="${dir.stage}/src" level="4"
- packages="org.rvsnoop,rvsnoop,rvsnoop.actions,rvsnoop.ui">
- <classpath refid="path.class"/>
- <formatters>
- <formatter toFile="${dir.build}/doc/developer/lint4jreport.xml" type="xml"/>
- </formatters>
- </lint4j>
- <echo>Analyzing with FindBugs.</echo>
- <!-- There is a bug in the Ant task, will be resolved in FB 1.1.3 ...
- <findbugs home="${lib.findbugs}" output="html"
- outputFile="${dir.build}/doc/developer/fbreport.html">
+
+ <echo>Analyzing with FindBugs...</echo>
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
+ <classpath>
+ <fileset dir="${lib.findbugs}/lib" includes="*.jar"/>
+ </classpath>
+ </taskdef>
+ <findbugs home="${lib.findbugs}" output="html" jvmargs="-Xmx256m"
+ outputFile="${dir.build}/doc/developer/fb-report.html">
<auxClasspath>
- <path refid="path.class"/>
+ <path refid="compile.classpath"/>
</auxClasspath>
- <sourcePath path="${dir.stage}/src"/>
+ <sourcePath path="src/main"/>
<class location="${dir.build}/classes/main"/>
</findbugs>
- -->
+
</target>
- <target name="clean" depends="setproperties"
+ <target name="dist" depends="jar, analyze"
+ description="Package all files required for a distribution.">
+ <copy todir="${dir.build}/dist/bin" encoding="utf-8">
+ <fileset dir="bin" includes="*"/>
+ </copy>
+ <chmod dir="${dir.build}/dist/bin" includes="*.sh" perm="750"/>
+ <copy todir="${dir.build}/dist/doc">
+ <fileset dir="${dir.build}/doc"/>
+ <fileset dir="doc">
+ <include name="**/*.html"/>
+ <include name="**/*.css"/>
+ <include name="**/*.png"/>
+ </fileset>
+ </copy>
+ <copy todir="${dir.build}/dist/lib">
+ <fileset refid="include.classpath"/>
+ <fileset file="src/main/commons-logging.properties"/>
+ <!-- No need to copy rvsnoop.jar as it is added by the jar target. -->
+ </copy>
+ <zip destfile="${dir.build}/dist/src/rvsnoop-${version}-src.zip">
+ <zipfileset dir="src/main" includes="**/*.java, **/*.properties"/>
+ </zip>
+ <echo>Creating the tarred and gzipped distributable.</echo>
+ <tar destfile="${dir.build}/rvsnoop-${version}.tgz" compression="gzip">
+ <tarfileset dir="${dir.build}/dist" mode="750" dirmode="550" prefix="rvsnoop-${version}">
+ <include name="bin/*.sh"/>
+ </tarfileset>
+ <tarfileset dir="${dir.build}/dist" mode="440" dirmode="550" prefix="rvsnoop-${version}">
+ <include name="**/*.*"/>
+ <exclude name="bin/*.sh"/>
+ </tarfileset>
+ </tar>
+ </target>
+
+ <target name="clean" depends="init"
description="Remove all of the generated files.">
- <delete dir="${dir.build}/"/>
- <delete dir="${dir.dist}/"/>
- <delete dir="${dir.stage}/"/>
- <delete file="rvsnoop-${version}.tgz"/>
+ <delete dir="${dir.build}"/>
</target>
</project>
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Copied: trunk/rvsn00p/etc/rvsnoop.pmd (from rev 392, trunk/rvsn00p/rvsnoop.pmd)
===================================================================
(Binary files differ)
Deleted: trunk/rvsn00p/rvsnoop.pmd
===================================================================
(Binary files differ)
Deleted: trunk/rvsn00p/src/commons-logging.properties
===================================================================
--- trunk/rvsn00p/src/commons-logging.properties 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/commons-logging.properties 2008-06-02 14:22:38 UTC (rev 393)
@@ -1,21 +0,0 @@
-# Logging configuration for RvSnoop @version@.
-# This file contains both the commons-logging configuration and the properties
-# used by the java.util.logging classes.
-# $Id$
-
-# Commons Logging Configuration
-org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
-org.apache.commons.logging.Log=org.rvsnoop.FastJdk14Logger
-
-# JDK Logging Global Configuration
-handlers=org.rvsnoop.FastFileHandler
-.level=INFO
-
-# JDK Logging Handler Specific Configuration
-org.rvsnoop.FastFileHandler.maxFiles=10
-org.rvsnoop.FastFileHandler.maxFileSize=1M
-org.rvsnoop.FastFileHandler.level=INFO
-#org.rvsnoop.FastFileHandler.filter=
-org.rvsnoop.FastFileHandler.formatter=org.rvsnoop.FastFormatter
-org.rvsnoop.FastFileHandler.encoding=UTF-8
-org.rvsnoop.FastFileHandler.compressOldFiles=false
Copied: trunk/rvsn00p/src/main/commons-logging.properties (from rev 392, trunk/rvsn00p/src/commons-logging.properties)
===================================================================
--- trunk/rvsn00p/src/main/commons-logging.properties (rev 0)
+++ trunk/rvsn00p/src/main/commons-logging.properties 2008-06-02 14:22:38 UTC (rev 393)
@@ -0,0 +1,21 @@
+# Logging configuration for RvSnoop @version@.
+# This file contains both the commons-logging configuration and the properties
+# used by the java.util.logging classes.
+# $Id$
+
+# Commons Logging Configuration
+org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
+org.apache.commons.logging.Log=org.rvsnoop.FastJdk14Logger
+
+# JDK Logging Global Configuration
+handlers=org.rvsnoop.FastFileHandler
+.level=INFO
+
+# JDK Logging Handler Specific Configuration
+org.rvsnoop.FastFileHandler.maxFiles=10
+org.rvsnoop.FastFileHandler.maxFileSize=1M
+org.rvsnoop.FastFileHandler.level=INFO
+#org.rvsnoop.FastFileHandler.filter=
+org.rvsnoop.FastFileHandler.formatter=org.rvsnoop.FastFormatter
+org.rvsnoop.FastFileHandler.encoding=UTF-8
+org.rvsnoop.FastFileHandler.compressOldFiles=false
Copied: trunk/rvsn00p/src/main/org (from rev 392, trunk/rvsn00p/src/org)
Modified: trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/AeMessageTreeNode.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -38,9 +38,9 @@
private static final Icon messageIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("rvMessage"));
private static final Icon payloadIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("payload"));
private static final Icon trackingIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("tracking"));
-
+
static { NLSUtils.internationalize(AeMessageTreeNode.class); }
-
+
static String AERV, RV, XMLJMS, XMLRV, UNKNOWN, TRACKING, DATA;
private final List children = new ArrayList(2);
@@ -71,6 +71,7 @@
/* (non-Javadoc)
* @see rvsnoop.LazyTreeNode#createChildren()
*/
+ @Override
protected List createChildren() {
return children;
}
@@ -78,10 +79,12 @@
/* (non-Javadoc)
* @see rvsnoop.LazyTreeNode#getAllowsChildren()
*/
+ @Override
public boolean getAllowsChildren() {
return true;
}
+ @Override
public Icon getIcon() {
return messageIcon;
}
@@ -89,6 +92,7 @@
/* (non-Javadoc)
* @see rvsnoop.LazyTreeNode#getText()
*/
+ @Override
public String getText() {
return text;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/CausedIOException.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/CausedIOException.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -45,6 +45,7 @@
/* (non-Javadoc)
* @see java.lang.Throwable#getCause()
*/
+ @Override
public Throwable getCause() {
return cause;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/CausedIllegalArgumentException.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/CausedIllegalArgumentException.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -36,6 +36,7 @@
/* (non-Javadoc)
* @see java.lang.Throwable#getCause()
*/
+ @Override
public Throwable getCause() {
return cause;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/FastFileHandler.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FastFileHandler.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/FastFileHandler.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -121,23 +121,28 @@
CountedOutputStream(OutputStream out) {
this.stream = out;
}
+ @Override
public void close() throws IOException {
stream.close();
}
+ @Override
public void flush() throws IOException {
stream.flush();
}
int getCount() {
return count;
}
- public void write(byte buff[]) throws IOException {
+ @Override
+ public void write(byte[] buff) throws IOException {
stream.write(buff);
count += buff.length;
}
- public void write(byte buff[], int off, int len) throws IOException {
+ @Override
+ public void write(byte[] buff, int off, int len) throws IOException {
stream.write(buff, off, len);
count += len;
}
+ @Override
public void write(int b) throws IOException {
stream.write(b);
count++;
@@ -329,6 +334,7 @@
*
* @param record The record describing the logged event.
*/
+ @Override
public synchronized void publish(LogRecord record) {
if (!isLoggable(record)) { return; }
super.publish(record);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/FastFormatter.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FastFormatter.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/FastFormatter.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -32,20 +32,27 @@
this.builder = builder;
lock = builder;
}
+ @Override
public void close() throws IOException { /* NO-OP */ }
+ @Override
public void flush() throws IOException { /* NO-OP */ }
+ @Override
public void write(char[] cbuf, int off, int len) throws IOException {
builder.append(cbuf, off, len);
}
+ @Override
public void write(char[] cbuf) throws IOException {
builder.append(cbuf);
}
+ @Override
public void write(int c) throws IOException {
builder.append(c);
}
+ @Override
public void write(String str, int off, int len) throws IOException {
builder.append(str, off, len);
}
+ @Override
public void write(String str) throws IOException {
builder.append(str);
}
@@ -57,6 +64,7 @@
/* (non-Javadoc)
* @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
*/
+ @Override
public synchronized String format(LogRecord record) {
calendar.setTimeInMillis(record.getMillis());
builder.append(SystemUtils.LINE_SEPARATOR)
Modified: trunk/rvsn00p/src/main/org/rvsnoop/InterningTrimmingNodeFactory.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/InterningTrimmingNodeFactory.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -51,6 +51,7 @@
/* (non-Javadoc)
* @see nu.xom.NodeFactory#makeAttribute(java.lang.String, java.lang.String, java.lang.String, nu.xom.Attribute.Type)
*/
+ @Override
public Nodes makeAttribute(String name, String URI, String value, Type type) {
return super.makeAttribute(name.intern(), URI.intern(), value, type);
}
@@ -58,6 +59,7 @@
/* (non-Javadoc)
* @see nu.xom.NodeFactory#makeDocType(java.lang.String, java.lang.String, java.lang.String)
*/
+ @Override
public Nodes makeDocType(String rootElementName, String publicID, String systemID) {
return super.makeDocType(rootElementName.intern(), publicID.intern(), systemID.intern());
}
@@ -65,6 +67,7 @@
/* (non-Javadoc)
* @see nu.xom.NodeFactory#makeProcessingInstruction(java.lang.String, java.lang.String)
*/
+ @Override
public Nodes makeProcessingInstruction(String target, String data) {
return super.makeProcessingInstruction(target.intern(), data);
}
@@ -72,11 +75,13 @@
/* (non-Javadoc)
* @see nu.xom.NodeFactory#makeRootElement(java.lang.String, java.lang.String)
*/
+ @Override
public Element makeRootElement(String name, String namespace) {
return super.makeRootElement(name.intern(), namespace.intern());
}
// We don't need text nodes at all.
+ @Override
public Nodes makeText(String data) {
if (trim) data = data.trim();
return data.length() > 0 ? super.makeText(data) : EMPTY;
@@ -85,6 +90,7 @@
/* (non-Javadoc)
* @see nu.xom.NodeFactory#startMakingElement(java.lang.String, java.lang.String)
*/
+ @Override
public Element startMakingElement(String name, String namespace) {
return super.startMakingElement(name.intern(), namespace.intern());
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/LazyTreeNode.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -37,6 +37,7 @@
/* (non-Javadoc)
* @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
*/
+ @Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (!(value instanceof LazyTreeNode)) return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
final LazyTreeNode treeNode = (LazyTreeNode) value;
Modified: trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/NLSUtils.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -81,6 +81,7 @@
*
* @see java.util.Hashtable#put(Object,Object)
*/
+ @Override
public synchronized Object put(Object name, Object value) {
Object putObject = super.put(name, value); // value to return.
Object previousFieldValue = namesToFields.put(name, ASSIGNED);
@@ -133,7 +134,7 @@
private static String[] nlSuffixes;
- final static String SUFFIX = ".properties"; //$NON-NLS-1$
+ static final String SUFFIX = ".properties"; //$NON-NLS-1$
static {
try {
Modified: trunk/rvsn00p/src/main/org/rvsnoop/Project.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Project.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/Project.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -151,7 +151,7 @@
application.getFrame().getSubjectExplorer());
storeTypes(application.getRecordTypes());
}
-
+
public void storeConnections(Connections connections) throws IOException {
final File file = new File(projectDirectory, "Connections.xml");
final OutputStream stream = new FileOutputStream(file);
@@ -181,7 +181,7 @@
}
private void storeSubject(SubjectElement element, XMLBuilder builder, JTree tree) throws IOException {
- boolean expanded = tree != null ? tree.isExpanded(new TreePath(element.getPath())) : true;
+ boolean expanded = tree == null || tree.isExpanded(new TreePath(element.getPath()));
builder.startTag("subject", XMLBuilder.NS_CONNECTIONS)
.attribute("name", element.getElementName())
.attribute("selected", Boolean.toString(element.isSelected()))
Modified: trunk/rvsn00p/src/main/org/rvsnoop/ProjectFileFilter.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/ProjectFileFilter.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -25,11 +25,13 @@
super();
}
+ @Override
public boolean accept(File f) {
return f.isDirectory()
- || f.getName().toLowerCase(Locale.ENGLISH).equals("rvsnoop-project.xml");
+ || "rvsnoop-project.xml".equals(f.getName().toLowerCase(Locale.ENGLISH));
}
+ @Override
public String getDescription() {
return "RvSnoop Projects";
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RecordLedgerFormat.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -45,7 +45,7 @@
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
*/
- public static abstract class ColumnFormat {
+ public abstract static class ColumnFormat {
private final Class clazz;
private final Comparator comparator;
private final String identifier;
@@ -82,6 +82,7 @@
public static ColumnFormat CONNECTION = new ColumnFormat("connection", CONNECTION_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = -4938884664732119140L;
+ @Override
public Object getValue(Record record) {
final RvConnection connection = record.getConnection();
return connection != null ? connection.getDescription() : "";
@@ -90,6 +91,7 @@
public static final ColumnFormat MESSAGE = new ColumnFormat("message", MESSAGE_NAME, Object.class) {
private static final long serialVersionUID = 3526646591996520301L;
+ @Override
public Object getValue(Record record) {
return record.getMessage();
}
@@ -97,6 +99,7 @@
public static final ColumnFormat SEQUENCE_NO = new ColumnFormat("sequence", SEQUENCE_NO_NAME, Long.class, new ComparableComparator()) {
private static final long serialVersionUID = -5762735421370128862L;
+ @Override
public Object getValue(Record record) {
return Long.toString(record.getSequenceNumber());
}
@@ -104,6 +107,7 @@
public static final ColumnFormat SIZE_IN_BYTES = new ColumnFormat("size", SIZE_IN_BYTES_NAME, Integer.class, new ComparableComparator()) {
private static final long serialVersionUID = 2274660797219318776L;
+ @Override
public Object getValue(Record record) {
return new Integer(record.getSizeInBytes());
}
@@ -111,6 +115,7 @@
public static final ColumnFormat SUBJECT = new ColumnFormat("subject", SUBJECT_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = 7415054603888398693L;
+ @Override
public Object getValue(Record record) {
return record.getSendSubject();
}
@@ -118,6 +123,7 @@
public static final ColumnFormat TIMESTAMP = new ColumnFormat("timestamp", TIMESTAMP_NAME, Date.class, new ComparableComparator()) {
private static final long serialVersionUID = -3858078006527711756L;
+ @Override
public Object getValue(Record record) {
return new Date(record.getTimestamp());
}
@@ -125,6 +131,7 @@
public static final ColumnFormat TRACKING_ID = new ColumnFormat("tracking", TRACKING_ID_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = -3033175036104293820L;
+ @Override
public Object getValue(Record record) {
return record.getTrackingId();
}
@@ -133,6 +140,7 @@
public static final ColumnFormat TYPE = new ColumnFormat("type", TYPE_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = 6353909616946303068L;
final RecordTypes types = RecordTypes.getInstance();
+ @Override
public Object getValue(Record record) {
return types.getFirstMatchingType(record).getName();
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RvFieldTreeNode.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -173,6 +173,7 @@
this(parent, field, null, null);
}
+ @Override
protected List createChildren() {
List children = null;
if (field.type == TibrvMsg.XML) {
@@ -226,18 +227,22 @@
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#getAllowsChildren()
*/
+ @Override
public boolean getAllowsChildren() {
return allowsChildren;
}
+ @Override
public Icon getIcon() {
return icon;
}
+ @Override
public String getText() {
return text;
}
+ @Override
public String getTooltip() {
return TibrvMsg.getTypeName(field.type);
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RvMessageTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/RvMessageTreeNode.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -50,6 +50,7 @@
this.message = message;
}
+ @Override
protected List createChildren() {
final int numFields = message.getNumFields();
final List children = new ArrayList(numFields);
@@ -71,14 +72,17 @@
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#getAllowsChildren()
*/
+ @Override
public boolean getAllowsChildren() {
return true;
}
+ @Override
public Icon getIcon() {
return icon;
}
+ @Override
public String getText() {
return TEXT;
}
Modified: trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/UserPreferences.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/UserPreferences.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -67,7 +67,7 @@
* @version $Revision$, $Date$
*/
public final class UserPreferences {
-
+
private final class DividerLocationListener implements HierarchyBoundsListener {
public void ancestorMoved(HierarchyEvent e) {
final Component c = e.getChanged();
@@ -119,6 +119,7 @@
final Component component = e.getChanged();
if (component instanceof Window) { setWindowBounds((Window) component); }
}
+ @Override
public void windowClosed(WindowEvent e) {
setWindowBounds(e.getWindow());
}
@@ -141,7 +142,7 @@
static { NLSUtils.internationalize(UserPreferences.class); }
- public synchronized static UserPreferences getInstance() {
+ public static synchronized UserPreferences getInstance() {
if (instance == null) { instance = new UserPreferences(); }
return instance;
}
@@ -201,7 +202,7 @@
public String getLastExportLocation() {
return preferences.get(KEY_LAST_EXPORT_LOCATION, SystemUtils.USER_DIR);
}
-
+
public List getLedgerColumns() {
final List columns = new ArrayList(RecordLedgerFormat.ALL_COLUMNS.size());
final Preferences node = preferences.node(KEY_LEDGER_COLUMNS);
Modified: trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/XMLTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/XMLTreeNode.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -42,6 +42,7 @@
this.node = node;
}
+ @Override
protected List createChildren() {
final ParentNode pn = (ParentNode) node;
final int numChildren = pn.getChildCount();
@@ -55,6 +56,7 @@
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#getAllowsChildren()
*/
+ @Override
public boolean getAllowsChildren() {
return node instanceof ParentNode;
}
@@ -62,6 +64,7 @@
/* (non-Javadoc)
* @see rvsnoop.LazyTreeNode#getIcon()
*/
+ @Override
public Icon getIcon() {
if (node instanceof Attribute)
return Icons.XML_ATTRIBUTE;
@@ -74,6 +77,7 @@
/* (non-Javadoc)
* @see rvsnoop.LazyTreeNode#getText()
*/
+ @Override
public String getText() {
if (node instanceof Attribute)
return ((Attribute) node).getLocalName();
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/AbstractSearchAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/AbstractSearchAction.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -50,6 +50,7 @@
/* (non-Javadoc)
* @see org.rvsnoop.actions.RvSnoopAction#actionPerformed(java.awt.event.ActionEvent)
*/
+ @Override
public final void actionPerformed(ActionEvent e) {
final EventList oldMatchers = getMatcherEditors();
final JFrame frame = application.getFrame();
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/CheckForUpdates.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/CheckForUpdates.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -48,7 +48,7 @@
private static final String ICON_ERROR = "error";
private static final String ICON_NEW_VERSION = "updateAvailable";
private static final String ICON_UP_TO_DATE = "updateNotAvailable";
-
+
private static final Log log = LogFactory.getLog(CheckForUpdates.class);
public CheckForUpdates(Application application) {
@@ -62,6 +62,7 @@
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
+ @Override
public void actionPerformed(ActionEvent event) {
final JFrame frame = application.getFrame();
try {
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/ClearLedger.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -44,6 +44,7 @@
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
+ @Override
public final void actionPerformed(ActionEvent event) {
application.getLedger().clear();
application.getSubjectHierarchy().reset();
Modified: trunk/rvsn00p/src/main/org/rvsnoop/actions/Copy.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java 2007-05-06 14:09:58 UTC (rev 392)
+++ trunk/rvsn00p/src/main/org/rvsnoop/actions/Copy.java 2008-06-02 14:22:38 UTC (rev 393)
@@ -50,6 +50,7 @@
...
[truncated message content] |
|
From: <ia...@us...> - 2007-05-06 14:09:59
|
Revision: 392
http://svn.sourceforge.net/rvsn00p/?rev=392&view=rev
Author: ianp
Date: 2007-05-06 07:09:58 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Basically far too many changes are all going in together here.
What happened was, I was away from the internet for about a month and got a bnch of stuff done;
then, rather than sorting it out and checking stuff in straight away I left it for a while. Now I'm going
to get everything stuffed into source control.
There shouldn't be any build breakage but I'm going to have to spend some time documenting the changes.
Also there are bits of work that need finishing off.
Modified Paths:
--------------
trunk/rvsn00p/build.properties
trunk/rvsn00p/build.xml
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/org/rvsnoop/Application.java
trunk/rvsn00p/src/org/rvsnoop/Connections.java
trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
trunk/rvsn00p/src/org/rvsnoop/RecordLedger.java
trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java
trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java
trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java
trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/OpenProject.java
trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java
trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProject.java
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProjectAs.java
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProjectAs.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Search.java
trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java
trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.properties
trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordLedgerTable.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
trunk/rvsn00p/src/rvsnoop/MessageLedger.java
trunk/rvsn00p/src/rvsnoop/RecordSelection.java
trunk/rvsn00p/src/rvsnoop/RecordType.java
trunk/rvsn00p/src/rvsnoop/RecordTypes.java
trunk/rvsn00p/src/rvsnoop/RvConnection.java
trunk/rvsn00p/src/rvsnoop/StartRvSnooper.java
trunk/rvsn00p/src/rvsnoop/StringUtils.java
trunk/rvsn00p/src/rvsnoop/SubjectHierarchy.java
trunk/rvsn00p/src/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/rvsnoop/actions/ChangeTableFont.java
trunk/rvsn00p/src/rvsnoop/actions/ExportToHtml.java
trunk/rvsn00p/src/rvsnoop/actions/ExportToRecordBundle.java
trunk/rvsn00p/src/rvsnoop/actions/ExportToRvScript.java
trunk/rvsn00p/src/rvsnoop/actions/ExportToRvTest.java
trunk/rvsn00p/src/rvsnoop/actions/ImportFromFile.java
trunk/rvsn00p/src/rvsnoop/actions/ImportFromRecordBundle.java
trunk/rvsn00p/src/rvsnoop/ui/Banners.java
trunk/rvsn00p/src/rvsnoop/ui/Icons.java
trunk/rvsn00p/src/rvsnoop/ui/RvConnectionDialog.java
trunk/rvsn00p/src/rvsnoop/ui/RvDetailsPanel.java
trunk/rvsn00p/src/rvsnoop/ui/SubjectExplorerEditor.java
trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
trunk/rvsn00p/src/rvsnoop/ui/UIUtils.java
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTest.java
trunk/rvsn00p/tests/org/rvsnoop/RecordLedgerTest.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java
trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.properties
trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java
trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java
trunk/rvsn00p/src/org/rvsnoop/Project.java
trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java
trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.java
trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.properties
trunk/rvsn00p/src/org/rvsnoop/RvMessageTreeNode.java
trunk/rvsn00p/src/org/rvsnoop/RvMessageTreeNode.properties
trunk/rvsn00p/src/org/rvsnoop/UserPreferences.java
trunk/rvsn00p/src/org/rvsnoop/UserPreferences.properties
trunk/rvsn00p/src/org/rvsnoop/XMLTreeNode.java
trunk/rvsn00p/src/org/rvsnoop/actions/CheckForUpdates.java
trunk/rvsn00p/src/org/rvsnoop/actions/CheckForUpdates.properties
trunk/rvsn00p/src/org/rvsnoop/actions/ExportTo.properties
trunk/rvsn00p/src/org/rvsnoop/actions/ExportToFile.java
trunk/rvsn00p/src/org/rvsnoop/actions/PruneEmptySubjects.java
trunk/rvsn00p/src/org/rvsnoop/actions/PruneEmptySubjects.properties
trunk/rvsn00p/src/org/rvsnoop/actions/SelectAllRecords.java
trunk/rvsn00p/src/org/rvsnoop/actions/SelectAllRecords.properties
trunk/rvsn00p/src/org/rvsnoop/actions/ShowAllColumns.java
trunk/rvsn00p/src/org/rvsnoop/actions/ShowAllColumns.properties
trunk/rvsn00p/src/org/rvsnoop/io/
trunk/rvsn00p/src/org/rvsnoop/io/ExportFormat.java
trunk/rvsn00p/src/org/rvsnoop/io/HTMLExportFormat.java
trunk/rvsn00p/src/org/rvsnoop/io/RecordBundleV1ExportFormat.java
trunk/rvsn00p/src/org/rvsnoop/io/RvScriptExportFormat.java
trunk/rvsn00p/src/org/rvsnoop/io/RvTestExportFormat.java
trunk/rvsn00p/src/org/rvsnoop/io/RvTestExportFormat.properties
trunk/rvsn00p/src/org/rvsnoop/ui/ExportDialog.properties
trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.properties
trunk/rvsn00p/src/org/rvsnoop/ui/RecentProjectsMenuManager.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecentProjectsMenuManager.properties
trunk/rvsn00p/src/org/rvsnoop/ui/StatusBar.java
trunk/rvsn00p/src/org/rvsnoop/ui/TrackingAdjustmentListener.java
trunk/rvsn00p/src/resources/banners/error.png
trunk/rvsn00p/src/resources/banners/updateAvailable.png
trunk/rvsn00p/src/resources/banners/updateNotAvailable.png
trunk/rvsn00p/src/resources/icons/checkForUpdates.png
trunk/rvsn00p/src/resources/icons/exportTo.png
trunk/rvsn00p/src/resources/icons/next.png
trunk/rvsn00p/src/resources/icons/payload.png
trunk/rvsn00p/src/resources/icons/previous.png
trunk/rvsn00p/src/resources/icons/rvField.png
trunk/rvsn00p/src/resources/icons/rvMessage.png
trunk/rvsn00p/src/resources/icons/selectAllRecords.png
trunk/rvsn00p/src/resources/icons/showAllColumns.png
trunk/rvsn00p/src/resources/icons/statusBarCount.png
trunk/rvsn00p/src/resources/icons/statusBarEncoding.png
Removed Paths:
-------------
trunk/rvsn00p/src/resources/banners/update_already.png
trunk/rvsn00p/src/resources/banners/update_available.png
trunk/rvsn00p/src/resources/icons/check_updates.png
trunk/rvsn00p/src/resources/icons/export.png
trunk/rvsn00p/src/resources/icons/filter_columns.png
trunk/rvsn00p/src/resources/icons/rv_field.png
trunk/rvsn00p/src/resources/icons/rv_message.png
trunk/rvsn00p/src/resources/icons/select_all.png
trunk/rvsn00p/src/rvsnoop/AeMsgTreeNode.java
trunk/rvsn00p/src/rvsnoop/InterningTrimmingNodeFactory.java
trunk/rvsn00p/src/rvsnoop/LazyTreeNode.java
trunk/rvsn00p/src/rvsnoop/PreferencesManager.java
trunk/rvsn00p/src/rvsnoop/Project.java
trunk/rvsn00p/src/rvsnoop/ProjectFileFilter.java
trunk/rvsn00p/src/rvsnoop/RecentConnections.java
trunk/rvsn00p/src/rvsnoop/RecentProjects.java
trunk/rvsn00p/src/rvsnoop/RvFieldTreeNode.java
trunk/rvsn00p/src/rvsnoop/RvMessageTreeNode.java
trunk/rvsn00p/src/rvsnoop/XMLConfigFile.java
trunk/rvsn00p/src/rvsnoop/XMLTreeNode.java
trunk/rvsn00p/src/rvsnoop/actions/CheckForUpdates.java
trunk/rvsn00p/src/rvsnoop/actions/ChooseColour.java
trunk/rvsn00p/src/rvsnoop/actions/ExportToFile.java
trunk/rvsn00p/src/rvsnoop/actions/LedgerSelectionAction.java
trunk/rvsn00p/src/rvsnoop/actions/PruneEmptySubjects.java
trunk/rvsn00p/src/rvsnoop/actions/SelectAllMessages.java
trunk/rvsn00p/src/rvsnoop/actions/ShowAllColumns.java
trunk/rvsn00p/src/rvsnoop/ui/FilterDialog.java
trunk/rvsn00p/src/rvsnoop/ui/SearchDialog.java
trunk/rvsn00p/src/rvsnoop/ui/StatusBar.java
trunk/rvsn00p/src/rvsnoop/ui/TextFieldTableCellRenderer.java
trunk/rvsn00p/src/rvsnoop/ui/TrackingAdjustmentListener.java
Modified: trunk/rvsn00p/build.properties
===================================================================
--- trunk/rvsn00p/build.properties 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/build.properties 2007-05-06 14:09:58 UTC (rev 392)
@@ -16,11 +16,12 @@
lib.cli=/usr/local/share/java/commons-cli-1.0/commons-cli-1.0.jar
lib.forms=/usr/local/share/java/forms-1.0.7/forms-1.0.7.jar
lib.glazed=/usr/local/share/java/glazedlists-1.7.0/glazedlists.jar
-lib.io=/usr/local/share/java/commons-io-1.2/commons-io-1.2.jar
-lib.lang=/usr/local/share/java/commons-lang-2.2/commons-lang-2.2.jar
+lib.io=/usr/local/share/java/commons-io-1.3.1/commons-io-1.3.1.jar
+lib.lang=/usr/local/share/java/commons-lang-2.3/commons-lang-2.3.jar
lib.logging=/usr/local/share/java/commons-logging-1.1/commons-logging-1.1.jar
lib.looks=/usr/local/share/java/looks-2.1.0/looks-2.1.0.jar
lib.swinglayout=/usr/local/share/java/swing-layout-1.0.1/swing-layout-1.0.1.jar
+lib.wizard=/usr/local/share/java/wizard-0.1.12/wizard-0.1.12.jar
lib.xmlenc=/usr/local/share/java/xmlenc-0.52/xmlenc.jar
lib.xom=/usr/local/share/java/xom-1.1/xom-1.1.jar
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/build.xml 2007-05-06 14:09:58 UTC (rev 392)
@@ -63,6 +63,7 @@
<pathelement location="${lib.logging}"/>
<pathelement location="${lib.looks}"/>
<pathelement location="${lib.swinglayout}"/>
+ <pathelement location="${lib.wizard}"/>
<pathelement location="${lib.xmlenc}"/>
<pathelement location="${lib.xom}"/>
</path>
@@ -255,6 +256,7 @@
<fileset file="${lib.logging}"/>
<fileset file="${lib.looks}"/>
<fileset file="${lib.swinglayout}"/>
+ <fileset file="${lib.wizard}"/>
<fileset file="${lib.xmlenc}"/>
<fileset file="${lib.xom}"/>
<fileset file="${dir.stage}/src/*.properties"/>
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Copied: trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java (from rev 383, trunk/rvsn00p/src/rvsnoop/AeMsgTreeNode.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,96 @@
+/*
+ * Class: AeMessageTreeNode
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import org.rvsnoop.ui.ImageFactory;
+
+import com.tibco.sdk.MMessageFormat;
+import com.tibco.sdk.MTree;
+import com.tibco.tibrv.TibrvException;
+import com.tibco.tibrv.TibrvMsg;
+
+/**
+ * A {@link javax.swing.tree.TreeNode TreeNode} that wraps an Active Enterprise
+ * message.
+ * <p>
+ * This works directly with <code>MTree</code>s at the moment. It would be nice
+ * to also have a tree node that works with <code>MInstance</code>s, this would
+ * require a connection to a repository however.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public final class AeMessageTreeNode extends LazyTreeNode {
+
+ private static final Icon messageIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("rvMessage"));
+ private static final Icon payloadIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("payload"));
+ private static final Icon trackingIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("tracking"));
+
+ static { NLSUtils.internationalize(AeMessageTreeNode.class); }
+
+ static String AERV, RV, XMLJMS, XMLRV, UNKNOWN, TRACKING, DATA;
+
+ private final List children = new ArrayList(2);
+
+ private final String text;
+
+ public AeMessageTreeNode(TibrvMsg message) throws TibrvException {
+ super(null);
+ final MTree data = new MTree("");
+ data.use_tibrvMsg(message);
+ final int format = data.getMessageFormat();
+ if (format == MMessageFormat.AERV) {
+ text = MessageFormat.format(AERV, new Object[] { message.getField("^ver^").data });
+ } else if (format == MMessageFormat.RV) {
+ text = MessageFormat.format(RV, new Object[] { message.getField("^ver^").data });
+ } else if (format == MMessageFormat.XMLJMS) {
+ text = MessageFormat.format(XMLJMS, new Object[] { message.getField("^ver^").data });
+ } else if (format == MMessageFormat.XMLRV) {
+ text = MessageFormat.format(XMLRV, new Object[] { message.getField("^ver^").data });
+ } else {
+ text = UNKNOWN;
+ }
+ children.add(new RvFieldTreeNode(this, message.getField("^data^"), DATA, payloadIcon));
+ children.add(new RvFieldTreeNode(this, message.getField("^tracking^"), TRACKING, trackingIcon));
+ }
+
+
+ /* (non-Javadoc)
+ * @see rvsnoop.LazyTreeNode#createChildren()
+ */
+ protected List createChildren() {
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see rvsnoop.LazyTreeNode#getAllowsChildren()
+ */
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public Icon getIcon() {
+ return messageIcon;
+ }
+
+ /* (non-Javadoc)
+ * @see rvsnoop.LazyTreeNode#getText()
+ */
+ public String getText() {
+ return text;
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/AeMessageTreeNode.properties 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,7 @@
+AERV=Active Enterprise Message (Format: AERV, Version: {0})
+RV=Rendezvous Message (Format: RV, Version: {0})
+XMLJMS=Active Enterprise XML Message (Format: XMLJMS, Version: {0})
+XMLRV=Active Enterprise XML Message (Format: XMLRV, Version: {0})
+UNKNOWN=Active Enterprise Message (Unknown Format)
+TRACKING=Tracking Information
+DATA=Message Payload
\ No newline at end of file
Modified: trunk/rvsn00p/src/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -7,6 +7,9 @@
*/
package org.rvsnoop;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
import java.io.IOException;
import org.apache.commons.logging.Log;
@@ -14,10 +17,9 @@
import org.rvsnoop.actions.RvSnoopAction;
import org.rvsnoop.ui.RecordLedgerTable;
-import rvsnoop.PreferencesManager;
-import rvsnoop.Project;
import rvsnoop.RecordTypes;
import rvsnoop.RvConnection;
+import rvsnoop.SubjectHierarchy;
import rvsnoop.actions.Actions;
import rvsnoop.ui.UIManager;
@@ -33,14 +35,19 @@
*/
public final class Application {
+ /** Key for the 'project' JavaBean property. */
+ public static final String KEY_PROJECT = "project";
+
+ private static final Log log = LogFactory.getLog(Application.class);
+
static { NLSUtils.internationalize(Application.class); }
- private static final Log log = LogFactory.getLog(Application.class);
-
static String ERROR_SHUTDOWN;
private Actions actionFactory;
+ private Connections connections;
+
private FilteredLedgerView filteredLedger;
/** The main application frame. */
@@ -51,10 +58,31 @@
/** The current project. */
private Project project;
- /** The session state for the application. */
- private PreferencesManager sessionState;
+ private final PropertyChangeSupport propertyChangeSupport =
+ new PropertyChangeSupport(this);
+
+ public Application() {
+ UserPreferences.getInstance().listenToChangesFrom(this);
+ }
/**
+ * @param listener
+ * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * @param propertyName
+ * @param listener
+ * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
+ */
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+
+ /**
* Get an action from the applications action factory.
*
* @param command The action command to get.
@@ -78,6 +106,16 @@
}
/**
+ * Get the connections list for the current project.
+ *
+ * @return The connections list.
+ */
+ public synchronized Connections getConnections() {
+ if (connections == null) { connections = new Connections(null, true); }
+ return connections;
+ }
+
+ /**
* Get the main filtered ledger view.
* <p>
* There is a single shared view used by the main frame of the application
@@ -96,6 +134,17 @@
}
/**
+ * @return the frame
+ */
+ public synchronized UIManager getFrame() {
+ if (frame == null) {
+ frame = new UIManager(this);
+ getActionFactory().configureListeners();
+ }
+ return frame;
+ }
+
+ /**
* Get the record ledger.
* <p>
* If no project has been loaded yet this method creates a new in-memory
@@ -116,7 +165,7 @@
* @return The ledger table.
*/
public RecordLedgerTable getLedgerTable() {
- return getFrame().getMessageLedger();
+ return getFrame().getRecordLedger();
}
/**
@@ -130,6 +179,43 @@
}
/**
+ * Get all of the known record types.
+ *
+ * @return The record types.
+ */
+ public synchronized RecordTypes getRecordTypes() {
+ // FIXME this should not use a static instance, they should be loaded from the project.
+ return RecordTypes.getInstance();
+ }
+
+ /**
+ * Get the shared subject hierarchy.
+ *
+ * @return The subject hierarchy.
+ */
+ public synchronized SubjectHierarchy getSubjectHierarchy() {
+ // FIXME this should not use a static instance, they should be loaded from the project.
+ return SubjectHierarchy.INSTANCE;
+ }
+
+ /**
+ * @param listener
+ * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * @param propertyName
+ * @param listener
+ * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
+ */
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /**
* Set a new current project.
* <p>
* This will close and unload the current project if there is one.
@@ -139,6 +225,8 @@
* synchronized (applies to persistent ledgers only).
*/
public synchronized void setProject(Project project) throws IOException {
+ final Project oldProject = this.project;
+ if (project.equals(oldProject)) { return; }
// XXX when changing the ledger be sure to copy any listeners across
// to the new ledger instance.
if (this.project != null) {
@@ -150,42 +238,41 @@
// TODO configure the ledger from data in the project file.
ledger = new InMemoryLedger();
filteredLedger = FilteredLedgerView.newInstance(ledger, false);
- }
- /**
- * @return the frame
- */
- public synchronized UIManager getFrame() {
- if (frame == null) {
- frame = new UIManager(this);
- getActionFactory().configureListeners();
- }
- return frame;
+ getConnections().clear();
+ project.loadConnections(getConnections());
+
+ getRecordTypes().clear();
+ project.loadRecordTypes(getRecordTypes());
+
+ propertyChangeSupport.firePropertyChange(KEY_PROJECT, oldProject, project);
}
-
+
/**
- * Get all of the known record types.
+ * Set a project for the application.
+ * <p>
+ * This should only be called if no current project is set. This method will
+ * cause the project to be written to disk.
*
- * @return The record types.
+ * @param directory The directory to store the project in.
+ * @throws IOException If there is a problem storing the project.
*/
- public synchronized RecordTypes getRecordTypes() {
- // FIXME this should not use a static instance, they should be loaded from the project.
- return RecordTypes.getInstance();
+ public synchronized void setProject(File directory) throws IOException {
+ if (project != null) { throw new IllegalStateException(); }
+ project = new Project(directory);
+ project.store(this);
+ propertyChangeSupport.firePropertyChange(KEY_PROJECT, null, project);
}
/**
- * @return the sessionState
- */
- public synchronized PreferencesManager getSessionState() {
- if (sessionState == null) { sessionState = new PreferencesManager(this); }
- return sessionState;
- }
-
- /**
* Shut down the applicatiopn and stop the VM.
*/
public void shutdown() {
try {
+ final RvConnection[] conns = connections.toArray();
+ for (int i = 0, imax = conns.length; i < imax; ++i) {
+ conns[i].stop();
+ }
RvConnection.shutdown();
System.exit(0);
} catch (Exception e) {
Modified: trunk/rvsn00p/src/org/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Connections.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/Connections.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -10,6 +10,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
+import java.io.OutputStream;
import java.text.Collator;
import java.util.Collection;
import java.util.Collections;
@@ -112,18 +113,8 @@
}
}
- private static Connections instance;
-
private static final Log log = LogFactory.getLog(Connections.class);
- public static final String NAMESPACE = "http://rvsnoop.org/ns/connections/1";
-
- // TODO remove this method, access connections via the application object
- public static synchronized Connections getInstance() {
- if (instance == null) { instance = new Connections(null, true); }
- return instance;
- }
-
private final ObservableElementList list;
private final boolean ownsConnections;
@@ -300,13 +291,15 @@
}
}
- public void toXML(XMLBuilder builder) throws IOException {
- builder.startTag("connections", NAMESPACE);
+ public void toXML(OutputStream stream) throws IOException {
+ final XMLBuilder builder = new XMLBuilder(stream, XMLBuilder.NS_CONNECTIONS)
+ .namespace(XMLBuilder.PREFIX_RENDEZVOUS, XMLBuilder.NS_RENDEZVOUS)
+ .startTag("connections", XMLBuilder.NS_CONNECTIONS);
final RvConnection[] connections = toArray();
for (int i = 0, imax = connections.length; i < imax; ++i) {
connections[i].toXML(builder);
}
- builder.endTag();
+ builder.endTag().close();
}
}
Modified: trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -99,6 +99,16 @@
}
/**
+ * Is this list filtering on <em>any</em> criteria.
+ *
+ * @return <code>true</code> if any filtering is turned on,
+ * <code>false</code> otherwise.
+ */
+ public synchronized boolean isFiltering() {
+ return filters.getMatcherEditors().size() > 0;
+ }
+
+ /**
* Is this view currently filtering records based on the subject hierarchy.
*
* @return <code>true</code> if subject filtering is turned on,
Copied: trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java (from rev 383, trunk/rvsn00p/src/rvsnoop/InterningTrimmingNodeFactory.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,91 @@
+/*
+ * Class: InterningTrimmingNodeFactory
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import nu.xom.Element;
+import nu.xom.NodeFactory;
+import nu.xom.Nodes;
+import nu.xom.Attribute.Type;
+
+/**
+ * A node factory that interns all structural strings and removes empty text.
+ * <p>
+ * A structural string is defined as any element or attribute name, as well as
+ * any namespace URI or prefix.
+ * <p>
+ * This will generally have the effect of slowing down parsing but reducing the
+ * space requirements and improving performance once parsed (because
+ * <code>equals</code> calls will always match on the initial identity test).
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.3
+ */
+public final class InterningTrimmingNodeFactory extends NodeFactory {
+ private static final Nodes EMPTY = new Nodes();
+
+ private final boolean trim;
+
+ /**
+ * Create a new factory which trims text nodes.
+ */
+ public InterningTrimmingNodeFactory() {
+ this(true);
+ }
+
+ /**
+ * Create a new factory.
+ *
+ * @param trim Should text nodes be trimmed or not.
+ */
+ private InterningTrimmingNodeFactory(boolean trim) {
+ super();
+ this.trim = trim;
+ }
+
+ /* (non-Javadoc)
+ * @see nu.xom.NodeFactory#makeAttribute(java.lang.String, java.lang.String, java.lang.String, nu.xom.Attribute.Type)
+ */
+ public Nodes makeAttribute(String name, String URI, String value, Type type) {
+ return super.makeAttribute(name.intern(), URI.intern(), value, type);
+ }
+
+ /* (non-Javadoc)
+ * @see nu.xom.NodeFactory#makeDocType(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public Nodes makeDocType(String rootElementName, String publicID, String systemID) {
+ return super.makeDocType(rootElementName.intern(), publicID.intern(), systemID.intern());
+ }
+
+ /* (non-Javadoc)
+ * @see nu.xom.NodeFactory#makeProcessingInstruction(java.lang.String, java.lang.String)
+ */
+ public Nodes makeProcessingInstruction(String target, String data) {
+ return super.makeProcessingInstruction(target.intern(), data);
+ }
+
+ /* (non-Javadoc)
+ * @see nu.xom.NodeFactory#makeRootElement(java.lang.String, java.lang.String)
+ */
+ public Element makeRootElement(String name, String namespace) {
+ return super.makeRootElement(name.intern(), namespace.intern());
+ }
+
+ // We don't need text nodes at all.
+ public Nodes makeText(String data) {
+ if (trim) data = data.trim();
+ return data.length() > 0 ? super.makeText(data) : EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see nu.xom.NodeFactory#startMakingElement(java.lang.String, java.lang.String)
+ */
+ public Element startMakingElement(String name, String namespace) {
+ return super.startMakingElement(name.intern(), namespace.intern());
+ }
+}
\ No newline at end of file
Property changes on: trunk/rvsn00p/src/org/rvsnoop/InterningTrimmingNodeFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java (from rev 383, trunk/rvsn00p/src/rvsnoop/LazyTreeNode.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,150 @@
+/*
+ * Class: LazyTreeNode
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.awt.Component;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeNode;
+
+/**
+ * A {@link TreeNode} that lazily created it's children.
+ * <p>
+ * This class also supports providing icons and text as suitable for use in a renderer.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class LazyTreeNode implements TreeNode {
+
+ public static class Renderer extends DefaultTreeCellRenderer {
+ private static final long serialVersionUID = -1587671692812026948L;
+ public Renderer() {
+ super();
+ }
+ /* (non-Javadoc)
+ * @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
+ */
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ if (!(value instanceof LazyTreeNode)) return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ final LazyTreeNode treeNode = (LazyTreeNode) value;
+ final JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ label.setText(treeNode.getText());
+ label.setIcon(treeNode.getIcon());
+ label.setToolTipText(treeNode.getTooltip());
+ return label;
+ }
+
+ }
+
+ private List children;
+
+ private final TreeNode parent;
+
+ /**
+ * @param parent The parent of this node.
+ */
+ protected LazyTreeNode(TreeNode parent) {
+ super();
+ this.parent = parent;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#children()
+ */
+ public final Enumeration children() {
+ if (children == null)
+ children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ return Collections.enumeration(children);
+ }
+
+ /**
+ * Concrete subclasses should use this hook to create the list of children.
+ *
+ * @return A list of tree nodes.
+ */
+ protected abstract List createChildren();
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getAllowsChildren()
+ */
+ public abstract boolean getAllowsChildren();
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getChildAt(int)
+ */
+ public final TreeNode getChildAt(int childIndex) {
+ if (children == null)
+ children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ return (TreeNode) children.get(childIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getChildCount()
+ */
+ public final int getChildCount() {
+ if (children == null)
+ children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ return children.size();
+ }
+
+ /**
+ * Get an icon suitable for decorating a graphical widget.
+ *
+ * @return The icon or <code>null</code>.
+ */
+ public Icon getIcon() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
+ */
+ public final int getIndex(TreeNode node) {
+ if (children == null)
+ children = getAllowsChildren() ? createChildren() : Collections.EMPTY_LIST;
+ return children.indexOf(node);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getParent()
+ */
+ public final TreeNode getParent() {
+ return parent;
+ }
+
+ /**
+ * Get a text string suitable for displaying in a graphical widget.
+ *
+ * @return The text string, should not be <code>null</code>.
+ */
+ protected abstract String getText();
+
+ /**
+ * Get a text string suitable for displaying in a graphical widget.
+ *
+ * @return The text string, may be <code>null</code>.
+ */
+ protected String getTooltip() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#isLeaf()
+ */
+ public final boolean isLeaf() {
+ return !getAllowsChildren();
+ }
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/LazyTreeNode.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -11,6 +11,7 @@
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -203,7 +204,7 @@
* @param clazz The context ({@link java.lang.ClassLoader}) to load from.
* @return The resource, or <code>null</code> if it could not be found.
*/
- public static InputStream findNLSResource(String resourcePath, Class clazz) {
+ public static URL findNLSResource(String resourcePath, Class clazz) {
if (log.isDebugEnabled()) {
log.debug("Loading NLS resource from path: " + resourcePath);
}
@@ -215,8 +216,8 @@
if (log.isTraceEnabled()) {
log.trace("Trying variant: " + variants[i]);
}
- InputStream stream = clazz.getResourceAsStream(variants[i]);
- if (stream != null) { return stream; }
+ URL url = clazz.getResource(variants[i]);
+ if (url != null) { return url; }
}
return null;
}
Copied: trunk/rvsn00p/src/org/rvsnoop/Project.java (from rev 390, trunk/rvsn00p/src/rvsnoop/Project.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Project.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/Project.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,237 @@
+/*
+ * Class: Project
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.awt.Color;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+
+import nu.xom.Builder;
+import nu.xom.Element;
+import nu.xom.Elements;
+import nu.xom.ParsingException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.text.StrBuilder;
+
+import rvsnoop.RecordMatcher;
+import rvsnoop.RecordType;
+import rvsnoop.RecordTypes;
+import rvsnoop.RvConnection;
+import rvsnoop.SubjectElement;
+import rvsnoop.SubjectHierarchy;
+
+/**
+ * Handles all of the project specific settings.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public final class Project {
+
+ private static final String NAMESPACE = "http://rvsnoop.org/ns/rvsnoop/1";
+
+ private static String colourToHexString(Color c) {
+ return new StrBuilder(7).append('#')
+ .appendFixedWidthPadLeft(Integer.toHexString(c.getRed()), 2, '0')
+ .appendFixedWidthPadLeft(Integer.toHexString(c.getGreen()), 2, '0')
+ .appendFixedWidthPadLeft(Integer.toHexString(c.getBlue()), 2, '0')
+ .toString();
+ }
+
+ private final File projectDirectory;
+
+ public Project(File file) {
+ this.projectDirectory = file;
+ }
+
+ public void loadConnections(Connections connections) throws IOException {
+ final File file = new File(projectDirectory, "Connections.xml");
+ InputStream stream = null;
+ try {
+ stream = new BufferedInputStream(new FileInputStream(file));
+ final Element root = new Builder().build(stream).getRootElement();
+ final Elements elts = root.getChildElements();
+ for (int i = 0, imax = elts.size(); i < imax; ++i) {
+ connections.add(RvConnection.fromXML(elts.get(i)));
+ }
+ } catch (ParsingException e) {
+ // TODO log this exception, maybe pop a dialog.
+ }
+ }
+
+ private void loadRecordType(Element element, RecordTypes types) {
+ final Element matcherElt = element.getFirstChildElement("matcher", NAMESPACE);
+ final RecordMatcher matcher = RecordMatcher.fromXml(matcherElt);
+ final Color colour = Color.decode(element.getAttributeValue(RecordType.KEY_COLOUR));
+ if (RecordMatcher.DEFAULT_MATCHER.equals(matcher)) {
+ RecordTypes.DEFAULT.setColour(colour);
+ } else {
+ final String name = element.getAttributeValue(RecordType.KEY_NAME);
+ final String selected = element.getAttributeValue(RecordType.KEY_SELECTED);
+ final RecordType type = types.createType(name, colour, matcher);
+ type.setSelected(BooleanUtils.toBoolean(selected));
+ }
+ }
+
+ public void loadRecordTypes(RecordTypes types) throws IOException {
+ final File file = new File(projectDirectory, "Record Types.xml");
+ InputStream stream = null;
+ try {
+ stream = new BufferedInputStream(new FileInputStream(file));
+ final Element root = new Builder().build(stream).getRootElement();
+ final Elements elements = root.getChildElements("type", NAMESPACE);
+ for (int i = 0, imax = elements.size(); i < imax; ++i) {
+ loadRecordType(elements.get(i), types);
+ }
+ } catch (ParsingException e) {
+ // TODO log the exception
+ }
+ }
+
+ private void loadSubject(Element xmlElt, SubjectElement parent, SubjectHierarchy hierarchy, JTree tree) {
+ final String name = xmlElt.getAttributeValue("name");
+ final boolean selected = BooleanUtils.toBoolean(xmlElt.getAttributeValue("selected"));
+ final SubjectElement child = hierarchy.getSubjectElement(parent, name, selected);
+ if (BooleanUtils.toBoolean(xmlElt.getAttributeValue("expanded"))) {
+ tree.expandPath(new TreePath(child.getPath()));
+ }
+ final Elements xmlElts = xmlElt.getChildElements();
+ for (int i = 0, imax = xmlElts.size(); i < imax; ++i) {
+ loadSubject(xmlElts.get(i), parent, hierarchy, tree);
+ }
+ }
+
+ public SubjectHierarchy loadSubjects(JTree tree) throws IOException {
+ final File file = new File(projectDirectory, "Subjects.xml");
+ InputStream stream = null;
+ try {
+ stream = new BufferedInputStream(new FileInputStream(file));
+ final Element root = new Builder().build(stream).getRootElement();
+ final SubjectHierarchy hierarchy = new SubjectHierarchy();
+ final Elements xmlElts = root.getChildElements();
+ final SubjectElement parent = (SubjectElement) hierarchy.getRoot();
+ for (int i = 0, imax = xmlElts.size(); i < imax; ++i) {
+ loadSubject(xmlElts.get(i), parent, hierarchy, tree);
+ }
+ return hierarchy;
+ } catch (ParsingException e) {
+ // TODO log this exception, maybe pop a dialog.
+ return new SubjectHierarchy();
+ }
+ }
+
+ public File getDirectory() {
+ return projectDirectory;
+ }
+
+ public void store(Application application) throws IOException {
+ storeMetadata(application);
+ storeConnections(application.getConnections());
+ storeSubjects(application.getSubjectHierarchy(),
+ application.getFrame().getSubjectExplorer());
+ storeTypes(application.getRecordTypes());
+ }
+
+ public void storeConnections(Connections connections) throws IOException {
+ final File file = new File(projectDirectory, "Connections.xml");
+ final OutputStream stream = new FileOutputStream(file);
+ try {
+ connections.toXML(stream);
+ } finally {
+ IOUtils.closeQuietly(stream);
+ }
+ }
+
+ private void storeMetadata(Application application) throws IOException {
+ final File file = new File(projectDirectory, "RvSnoop Project.xml");
+ final OutputStream stream = new FileOutputStream(file);
+ try {
+ new XMLBuilder(stream, NAMESPACE)
+ .startTag("project", NAMESPACE)
+ .startTag("creationDate", NAMESPACE)
+ .pcdata(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()))
+ .endTag()
+ .startTag("ledger", NAMESPACE)
+ .attribute("class", InMemoryLedger.class.getName())
+ .endTag()
+ .endTag().close();
+ } finally {
+ IOUtils.closeQuietly(stream);
+ }
+ }
+
+ private void storeSubject(SubjectElement element, XMLBuilder builder, JTree tree) throws IOException {
+ boolean expanded = tree != null ? tree.isExpanded(new TreePath(element.getPath())) : true;
+ builder.startTag("subject", XMLBuilder.NS_CONNECTIONS)
+ .attribute("name", element.getElementName())
+ .attribute("selected", Boolean.toString(element.isSelected()))
+ .attribute("expanded", Boolean.toString(expanded));
+ for (Enumeration e = element.children(); e.hasMoreElements(); ) {
+ storeSubject((SubjectElement) e.nextElement(), builder, tree);
+ }
+ builder.endTag();
+ }
+
+ public void storeSubjects(SubjectHierarchy subjects, JTree tree) throws IOException {
+ final File file = new File(projectDirectory, "Subjects.xml");
+ final OutputStream stream = new FileOutputStream(file);
+ try {
+ final XMLBuilder builder = new XMLBuilder(stream, NAMESPACE)
+ .namespace(XMLBuilder.PREFIX_RENDEZVOUS, XMLBuilder.NS_RENDEZVOUS)
+ .startTag("subjects", NAMESPACE);
+ final DefaultMutableTreeNode root = (DefaultMutableTreeNode) subjects.getRoot();
+ for (Enumeration e = root.children(); e.hasMoreElements(); ) {
+ storeSubject((SubjectElement) e.nextElement(), builder, tree);
+ }
+ builder.endTag().close();
+ } finally {
+ IOUtils.closeQuietly(stream);
+ }
+ }
+
+ public void storeTypes(RecordTypes types) throws IOException {
+ final File file = new File(projectDirectory, "Record Types.xml");
+ final OutputStream stream = new FileOutputStream(file);
+ try {
+ final XMLBuilder builder = new XMLBuilder(stream, NAMESPACE);
+ builder.startTag("types", NAMESPACE);
+ final RecordType[] allTypes = types.getAllTypes();
+ for (int i = 0, imax = allTypes.length; i < imax; ++i) {
+ final RecordType type = allTypes[i];
+ builder.startTag("type", NAMESPACE)
+ .attribute(RecordType.KEY_NAME, type.getName())
+ .attribute(RecordType.KEY_SELECTED, Boolean.toString(type.isSelected()))
+ .attribute(RecordType.KEY_COLOUR, colourToHexString(type.getColour()))
+ .startTag("matcher", NAMESPACE)
+ .attribute(RecordMatcher.PROP_TYPE, type.getMatcherName())
+ .attribute(RecordMatcher.PROP_VALUE, type.getMatcherValue())
+ .endTag()
+ .endTag();
+ }
+ builder.endTag().close();
+ } finally {
+ IOUtils.closeQuietly(stream);
+ }
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/Project.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java (from rev 384, trunk/rvsn00p/src/rvsnoop/ProjectFileFilter.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,36 @@
+/*
+ * Class: ProjectFileFilter
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.io.File;
+import java.util.Locale;
+
+import javax.swing.filechooser.FileFilter;
+
+/**
+ * Filter for project files.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public final class ProjectFileFilter extends FileFilter {
+
+ public ProjectFileFilter() {
+ super();
+ }
+
+ public boolean accept(File f) {
+ return f.isDirectory()
+ || f.getName().toLowerCase(Locale.ENGLISH).equals("rvsnoop-project.xml");
+ }
+
+ public String getDescription() {
+ return "RvSnoop Projects";
+ }
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/ProjectFileFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/rvsn00p/src/org/rvsnoop/RecordLedger.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedger.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordLedger.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -12,6 +12,7 @@
import rvsnoop.Record;
import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.swing.EventTableModel;
import ca.odell.glazedlists.util.concurrent.Lock;
@@ -87,6 +88,14 @@
}
/**
+ * @param listChangeListener
+ * @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
+ */
+ public void addListEventListener(ListEventListener listChangeListener) {
+ list.addListEventListener(listChangeListener);
+ }
+
+ /**
* Remove all of the records from the ledger.
* <p>
* This method acquires a write lock on the underlying list.
@@ -314,6 +323,14 @@
}
/**
+ * @param listChangeListener
+ * @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
+ */
+ public void removeListEventListener(ListEventListener listChangeListener) {
+ list.removeListEventListener(listChangeListener);
+ }
+
+ /**
* Return the number of records currently in the ledger.
* <p>
* This method acquires a read lock on the underlying list.
Modified: trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-01-18 13:31:58 UTC (rev 391)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -144,6 +144,16 @@
SUBJECT, SIZE_IN_BYTES, TRACKING_ID, MESSAGE
}));
+ public static String displayNameToIdentifier(String displayName) {
+ for (int i = 0, imax = ALL_COLUMNS.size(); i < imax; ++i) {
+ final ColumnFormat column = (ColumnFormat) ALL_COLUMNS.get(i);
+ if (column.getName().equals(displayName)) {
+ return column.identifier;
+ }
+ }
+ return null;
+ }
+
/**
* Gets a column format by it's ID.
*
Copied: trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.java (from rev 383, trunk/rvsn00p/src/rvsnoop/RvFieldTreeNode.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/RvFieldTreeNode.java 2007-05-06 14:09:58 UTC (rev 392)
@@ -0,0 +1,244 @@
+/*
+ * Class: RvFieldTreeNode
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.lang.reflect.Array;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.tree.TreeNode;
+
+import nu.xom.Builder;
+import nu.xom.Document;
+import nu.xom.ParsingException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.ui.ImageFactory;
+
+import com.tibco.tibrv.TibrvException;
+import com.tibco.tibrv.TibrvIPAddr;
+import com.tibco.tibrv.TibrvIPPort;
+import com.tibco.tibrv.TibrvMsg;
+import com.tibco.tibrv.TibrvMsgField;
+import com.tibco.tibrv.TibrvXml;
+
+/**
+ * A {@link TreeNode} that wraps a Rendezvous message field.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.3
+ */
+public final class RvFieldTreeNode extends LazyTreeNode {
+
+ private static final Icon defaultIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("rvField"));
+ private static final Icon messageIcon = new ImageIcon(ImageFactory.getInstance().getIconImage("rvMessage"));
+
+ static String ENCRYPTED, F32ARRAY, F64ARRAY, I8ARRAY, I16ARRAY, I32ARRAY, I64ARRAY;
+ static String U8ARRAY, U16ARRAY, U32ARRAY, U64ARRAY, IPADDR32, IPPORT16;
+ static String F32, F64, I8, I16, I32, I64, U8, U16, U32, U64, MSG, OPAQUE;
+ static String BOOL, DATETIME, XML, STRING, STRING_LONG, STRING_XML, USER;
+ static String ERROR_FIELD, ERROR_XML_IO, ERROR_XML_PARSE;
+
+ static { NLSUtils.internationalize(RvFieldTreeNode.class); }
+
+ private static String describeField(TibrvMsgField field) {
+ final short type = field.type;
+ switch (type) {
+ case TibrvMsg.ENCRYPTED: return FD_ENCRYPTED.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.MSG: return FD_MSG.format(new Object[] {field.name, new Integer(((TibrvMsg) field.data).getNumFields())});
+ case TibrvMsg.OPAQUE: return FD_OPAQUE.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.BOOL: return FD_BOOL.format(new Object[] {field.name, field.data});
+ case TibrvMsg.DATETIME: return FD_DATETIME.format(new Object[] {field.name, field.data});
+ case TibrvMsg.IPADDR32: return FD_IPADDR32.format(new Object[] {field.name, ((TibrvIPAddr) field.data).getAsString()});
+ case TibrvMsg.IPPORT16: return FD_IPPORT16.format(new Object[] {field.name, new Integer(((TibrvIPPort) field.data).getPort())});
+ case TibrvMsg.F32ARRAY: return FD_F32ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.F64ARRAY: return FD_F64ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.I8ARRAY: return FD_I8ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.I16ARRAY: return FD_I16ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.I32ARRAY: return FD_I32ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.I64ARRAY: return FD_I64ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.U8ARRAY: return FD_U8ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.U16ARRAY: return FD_U16ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.U32ARRAY: return FD_U32ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.U64ARRAY: return FD_U64ARRAY.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ case TibrvMsg.F32: return FD_F32.format(new Object[] {field.name, field.data});
+ case TibrvMsg.F64: return FD_F64.format(new Object[] {field.name, field.data});
+ case TibrvMsg.I8: return FD_I8.format(new Object[] {field.name, field.data});
+ case TibrvMsg.I16: return FD_I16.format(new Object[] {field.name, field.data});
+ case TibrvMsg.I32: return FD_I32.format(new Object[] {field.name, field.data});
+ case TibrvMsg.I64: return FD_I64.format(new Object[] {field.name, field.data});
+ case TibrvMsg.U8: return FD_U8.format(new Object[] {field.name, field.data});
+ case TibrvMsg.U16: return FD_U16.format(new Object[] {field.name, field.data});
+ case TibrvMsg.U32: return FD_U32.format(new Object[] {field.name, field.data});
+ case TibrvMsg.U64: return FD_U64.format(new Object[] {field.name, field.data});
+ case TibrvMsg.XML:
+ return FD_XML.format(new Object[] {field.name, new Integer(((TibrvXml) field.data).getBytes().length)});
+ case TibrvMsg.STRING:
+ final String s = (String) field.data;
+ if (s.startsWith("<?xml ")) return FD_STRING_XML.format(new Object[] {field.name, new Integer(s.length())});
+ if (s.length() > 60) return FD_STRING_LONG.format(new Object[] {field.name, new Integer(s.length()), s.substring(0, 60)});
+ return FD_STRING.format(new Object[] {field.name, s});
+ default: return FD_USER.format(new Object[] {field.name, new Integer(Array.getLength(field.data))});
+ }
+ }
+
+ private static final MessageFormat FD_ENCRYPTED = new MessageFormat(ENCRYPTED);
+ private static final MessageFormat FD_F32ARRAY = new MessageFormat(F32ARRAY);
+ private static final MessageFormat FD_F64ARRAY = new MessageFormat(F64ARRAY);
+ private static final MessageFormat FD_I8ARRAY = new MessageFormat(I8ARRAY);
+ private static final MessageFormat FD_I16ARRAY = new MessageFormat(I16ARRAY);
+ private static final MessageFormat FD_I32ARRAY = new MessageFormat(I32ARRAY);
+ private static final MessageFormat FD_I64ARRAY = new MessageFormat(I64ARRAY);
+ private static final MessageFormat FD_U8ARRAY = new MessageFormat(U8ARRAY);
+ private static final MessageFormat FD_U16ARRAY = new MessageFormat(U16ARRAY);
+ private static final MessageFormat FD_U32ARRAY = new MessageFormat(U32ARRAY);
+ private static final MessageFormat FD_U64ARRAY = new MessageFormat(U64ARRAY);
+ private static final MessageFormat FD_IPADDR32 = new MessageFormat(IPADDR32);
+ private static final MessageFormat FD_IPPORT16 = new MessageFormat(IPPORT16);
+ private static final MessageFormat FD_F32 = new MessageFormat(F32);
+ private static final MessageFormat FD_F64 = new MessageFormat(F64);
+ private static final MessageFormat FD_I8 = new MessageFormat(I8);
+ private static final MessageFormat FD_I16 = new MessageFormat(I16);
+ private static final MessageFormat FD_I32 = new MessageFormat(I32);
+ private static final MessageFormat FD_I64 = new MessageFormat(I64);
+ private static final MessageFormat FD_U8 = new MessageFormat(U8);
+ private static final MessageFormat FD_U16 = new MessageFormat(U16);
+ private static final MessageFormat FD_U32 = new MessageFormat(U32);
+ private static final MessageFormat FD_U64 = new MessageFormat(U64);
+ private static final MessageFormat FD_MSG = new MessageFormat(MSG);
+ private static final MessageFormat FD_OPAQUE = new MessageFormat(OPAQUE);
+ private static final MessageFormat FD_BOOL = new MessageFormat(BOOL);
+ private static final MessageFormat FD_DATETIME = new MessageFormat(DATETIME);
+ private static final MessageFormat FD_XML = new MessageFormat(XML);
+ private static final MessageFormat FD_STRING = new MessageFormat(STRING);
+ private static final MessageFormat FD_STRING_LONG = new MessageFormat(STRING_LONG);
+ private static final MessageFormat FD_STRING_XML = new MessageFormat(STRING_XML);
+ private static final MessageFormat FD_USER = new MessageFormat(USER);
+
+ private final boolean allowsChildren;
+
+ private final Icon icon;
+
+ private final String text;
+
+ private static final Log log = LogFactory.getLog(RvFieldTreeNode.class);
+
+ private final TibrvMsgField field;
+
+ /**
+ * @param parent The parent of this node.
+ * @param field The field represented by this node.
+ * @param text A custom label to use when displaying this field.
+ * @param icon A custom icon to use when displaying this field.
+ */
+ public RvFieldTreeNode(TreeNode parent, TibrvMsgField field, String text, Icon icon) {
+ super(parent);
+ this.text = text != null ? text : describeField(field);
+ this.field = field;
+ if (field.type == TibrvMsg.MSG) {
+ allowsChildren = true;
+ this.icon = icon != null ? icon : messageIcon;
+ ...
[truncated message content] |
|
From: <ia...@us...> - 2007-01-18 13:32:02
|
Revision: 391
http://svn.sourceforge.net/rvsn00p/?rev=391&view=rev
Author: ianp
Date: 2007-01-18 05:31:58 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Rewrote the record types dialog to use the same reorderable list as the search dialogs.
Removed no longer needed classes that were used by the old implementation.
Modified Paths:
--------------
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.java
trunk/rvsn00p/src/rvsnoop/RecordTypes.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.properties
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesListCellRenderer.java
trunk/rvsn00p/src/resources/banners/recordTypeDeselected.png
trunk/rvsn00p/src/resources/banners/recordTypeSelected.png
Removed Paths:
-------------
trunk/rvsn00p/src/rvsnoop/ui/ColourButtonTableCellRenderer.java
trunk/rvsn00p/src/rvsnoop/ui/GhostDropPane.java
trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Modified: trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -48,8 +48,8 @@
try {
this.xml = new XMLOutputter(new OutputStreamWriter(stream), "UTF-8");
xml.setEscaping(true);
+ xml.setLineBreak(LineBreak.UNIX);
xml.setIndentation(" ");
- xml.setLineBreak(LineBreak.UNIX);
xml.setQuotationMark('\'');
this.namespace = ns != null ? ns : "";
this.namespaces = new LinkedHashMap(namespaces);
@@ -70,7 +70,7 @@
}
public XMLBuilder attribute(String name, String value, String ns) throws IOException {
- return attribute(namespaces.get(ns).toString() + ':' + name, value);
+ return attribute(prefixify(name, ns), value);
}
public void close() throws IOException {
@@ -116,6 +116,18 @@
}
}
+ private void namespaceDeclarations() throws IOException {
+ if (namespace.length() > 0) {
+ xml.attribute("xmlns", namespace);
+ }
+ for (Iterator i = namespaces.keySet().iterator(); i.hasNext(); ) {
+ final String nsuri = (String) i.next();
+ if (namespace.equals(nsuri)) { continue; }
+ final String prefix = (String) namespaces.get(nsuri);
+ xml.attribute("xmlns:" + prefix, nsuri);
+ }
+ }
+
public XMLBuilder pcdata(String text) throws IOException {
try {
xml.pcdata(text);
@@ -127,6 +139,11 @@
}
}
+ private String prefixify(String name, String ns) {
+ if (namespace.equals(ns)) { return name; }
+ return namespaces.get(ns).toString() + ':' + name;
+ }
+
public XMLBuilder startTag(String type) throws IOException {
try {
if (!declared) {
@@ -135,14 +152,7 @@
}
xml.startTag(type);
if (!started) {
- if (namespace.length() > 0) {
- xml.attribute("xmlns", namespace);
- }
- for (Iterator i = namespaces.keySet().iterator(); i.hasNext(); ) {
- final String nsuri = (String) i.next();
- final String prefix = (String) namespaces.get(nsuri);
- xml.attribute("xmlns:" + prefix, nsuri);
- }
+ namespaceDeclarations();
started = true;
}
return this;
@@ -154,7 +164,7 @@
}
public XMLBuilder startTag(String type, String ns) throws IOException {
- return startTag(namespaces.get(ns).toString() + ':' + type);
+ return startTag(prefixify(type, ns));
}
}
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -13,9 +13,11 @@
import org.rvsnoop.Application;
import org.rvsnoop.NLSUtils;
+import org.rvsnoop.ui.RecordTypesDialog;
-import rvsnoop.ui.RecordTypesDialog;
+import rvsnoop.RecordTypes;
+
/**
* Display a dialog to allow editing of the record types.
*
@@ -44,7 +46,10 @@
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent event) {
- final RecordTypesDialog dialog = new RecordTypesDialog();
+ final RecordTypesDialog dialog =
+ new RecordTypesDialog(
+ application.getFrame().getFrame(),
+ RecordTypes.getInstance());
dialog.setModal(true);
dialog.pack();
dialog.setVisible(true);
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -121,15 +121,18 @@
static String DEBUG_ADDED, DEBUG_ADDING, TITLE;
private static final Log log = LogFactory.getLog(MatcherEditorListDialog.class);
+
private static final RvSnoopMatcherEditor PROTOTYPE =
new RvSnoopMatcherEditor(
DataAccessorFactory.getInstance().createSendSubjectAccessor(),
PredicateFactory.getInstance().createStringStartsWithPredicate("PROTOTYPE", false));
+
private static final long serialVersionUID = -642470709671436909L;
static { NLSUtils.internationalize(MatcherEditorListDialog.class); }
private EventList copyOfEditors;
+
private final JList editorsList;
private final FooterPanel footer;
Copied: trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java (from rev 385, trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -0,0 +1,120 @@
+/*
+ * Class: RecordTypesDialog
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JDialog;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.rvsnoop.NLSUtils;
+
+import rvsnoop.RecordType;
+import rvsnoop.RecordTypes;
+
+/**
+ * A dialog to allow the record types in a project to be customized.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.6
+ */
+public final class RecordTypesDialog extends JDialog {
+
+ private final class AddTypeAction extends AbstractAction {
+ private static final long serialVersionUID = 5919428615655075591L;
+ AddTypeAction() {
+ super(BUTTON_ADD);
+ }
+ public void actionPerformed(ActionEvent e) {
+ types.createType();
+ }
+ }
+
+ private final class OKAction extends AbstractAction {
+ private static final long serialVersionUID = 1366301664349178313L;
+ OKAction() {
+ super(BUTTON_OK);
+ }
+ public void actionPerformed(ActionEvent e) {
+ setVisible(false);
+ dispose();
+ }
+ }
+
+ private final class RemoveTypeAction extends AbstractAction implements ListSelectionListener {
+ private static final long serialVersionUID = 4827030412184767246L;
+ RemoveTypeAction() {
+ super(BUTTON_REMOVE);
+ setEnabled(false);
+ }
+ public void actionPerformed(ActionEvent e) {
+ types.removeType((RecordType) typesList.getSelectedValue());
+ }
+ public void valueChanged(ListSelectionEvent e) {
+ setEnabled(!typesList.isSelectionEmpty());
+ }
+ }
+
+ static { NLSUtils.internationalize(RecordTypesDialog.class); }
+
+ private static final long serialVersionUID = -2564241831430080435L;
+
+ private static final Image BANNER = ImageFactory.getInstance().getBannerImage("editRecordTypes");
+
+ static String DIALOG_TITLE, TITLE, DESCRIPTION;
+ static String BUTTON_ADD, BUTTON_OK, BUTTON_REMOVE;
+
+ private final FooterPanel footer;
+
+ private final HeaderPanel header;
+
+ private final RecordTypes types;
+
+ private final JList typesList;
+
+ /**
+ * Creates a new <code>RecordTypesDialog</code>.
+ *
+ * @param parent The parent frame, may be <code>null</code>.
+ * @param types The types to display.
+ */
+ public RecordTypesDialog(Frame parent, RecordTypes types) {
+ super(parent, DIALOG_TITLE, true); // true == modal
+ this.types = types;
+ final GhostGlassPane glasspane = new GhostGlassPane();
+ setGlassPane(glasspane);
+ header = new HeaderPanel(TITLE, DESCRIPTION, BANNER);
+ typesList = new ReorderableList(types.getEventList(), glasspane);
+ final JScrollPane scrollpane = new JScrollPane(typesList);
+ scrollpane.setBackground(typesList.getBackground());
+ scrollpane.setBorder(null);
+ typesList.setCellRenderer(new RecordTypesListCellRenderer());
+ typesList.setPrototypeCellValue(RecordTypes.DEFAULT);
+ AddTypeAction add = new AddTypeAction();
+ OKAction ok = new OKAction();
+ RemoveTypeAction remove = new RemoveTypeAction();
+ typesList.addListSelectionListener(remove);
+ footer = new FooterPanel(ok, null, new Action[] { add, remove });
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(header, BorderLayout.NORTH);
+ getContentPane().add(scrollpane, BorderLayout.CENTER);
+ getContentPane().add(footer, BorderLayout.SOUTH);
+ pack();
+ setLocationRelativeTo(parent);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesDialog.properties 2007-01-18 13:31:58 UTC (rev 391)
@@ -0,0 +1,6 @@
+BUTTON_ADD=New Type
+BUTTON_OK=Close
+BUTTON_REMOVE=Remove Type
+DESCRIPTION=Drag the record types to re-order their priorities.\nAll changes will take effect immediately.
+DIALOG_TITLE=Record Types
+TITLE=Edit Record Types
\ No newline at end of file
Added: trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesListCellRenderer.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesListCellRenderer.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesListCellRenderer.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -0,0 +1,115 @@
+/*
+ * Class: RecordTypesListCellRenderer
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.awt.Component;
+import java.awt.Font;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.ListCellRenderer;
+import javax.swing.border.EmptyBorder;
+
+import org.apache.commons.lang.text.StrBuilder;
+import org.jdesktop.layout.GroupLayout;
+
+import rvsnoop.RecordType;
+
+/**
+ * A renderer for record types.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.7
+ */
+public final class RecordTypesListCellRenderer extends JPanel implements ListCellRenderer {
+
+ private static final long serialVersionUID = -7242365820031903080L;
+
+ private static final Icon BANNER_DESELECTED =
+ new ImageIcon(ImageFactory.getInstance().getBannerImage("recordTypeDeselected"));
+ private static final Icon BANNER_SELECTED =
+ new ImageIcon(ImageFactory.getInstance().getBannerImage("recordTypeSelected"));
+
+ private final StrBuilder builder = new StrBuilder();
+
+ private final JLabel imageLabel = new DefaultListCellRenderer();
+ private final JLabel titleLabel = new DefaultListCellRenderer();
+ private final JLabel valueLabel = new DefaultListCellRenderer();
+
+ public RecordTypesListCellRenderer() {
+ setBorder(new EmptyBorder(4, 4, 4, 4));
+ setOpaque(true);
+ Font f = titleLabel.getFont();
+ imageLabel.setOpaque(true);
+ titleLabel.setFont(f.deriveFont(Font.BOLD));
+ titleLabel.setOpaque(false);
+ valueLabel.setOpaque(false);
+ configureLayout();
+ }
+
+ private void configureLayout() {
+ // Layout
+ GroupLayout layout = new GroupLayout(this);
+ setLayout(layout);
+ layout.setAutocreateGaps(true);
+ // Horizontal group
+ GroupLayout.SequentialGroup hgp = layout.createSequentialGroup();
+ layout.setHorizontalGroup(hgp);
+ hgp.add(imageLabel)
+ .add(layout.createParallelGroup()
+ .add(titleLabel)
+ .add(valueLabel));
+ // Vertical group
+ GroupLayout.ParallelGroup vgp = layout.createParallelGroup();
+ layout.setVerticalGroup(vgp);
+ vgp.add(imageLabel)
+ .add(layout.createSequentialGroup()
+ .add(titleLabel)
+ .add(valueLabel));
+ }
+
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+ if (value instanceof RecordType) {
+ final RecordType type = (RecordType) value;
+ if (type.isSelected()) {
+ imageLabel.setIcon(BANNER_SELECTED);
+ } else {
+ imageLabel.setIcon(BANNER_DESELECTED);
+ }
+ imageLabel.setBackground(type.getColour());
+ titleLabel.setText(type.getName());
+ builder.append(type.getMatcherName());
+ final String mv = type.getMatcherValue();
+ if (mv != null && mv.length() > 0) {
+ builder.append(' ').append('\u2018').append(mv).append('\u2019');
+ }
+ valueLabel.setText(builder.toString());
+ builder.setLength(0);
+ } else {
+ imageLabel.setIcon(null);
+ titleLabel.setText(" ");
+ valueLabel.setText(" ");
+ }
+ if (isSelected) {
+ setBackground(list.getSelectionBackground());
+ setForeground(list.getSelectionForeground());
+ } else {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ }
+ setBorder(null);
+ return this;
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesListCellRenderer.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/resources/banners/recordTypeDeselected.png
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/src/resources/banners/recordTypeDeselected.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/src/resources/banners/recordTypeSelected.png
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/src/resources/banners/recordTypeSelected.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/rvsnoop/RecordTypes.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/RecordTypes.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/rvsnoop/RecordTypes.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -133,6 +133,10 @@
}
}
+ public EventList getEventList() {
+ return types;
+ }
+
public RecordType getFirstMatchingType(Record record) {
types.getReadWriteLock().readLock().lock();
try {
Deleted: trunk/rvsn00p/src/rvsnoop/ui/ColourButtonTableCellRenderer.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/ui/ColourButtonTableCellRenderer.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/rvsnoop/ui/ColourButtonTableCellRenderer.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -1,87 +0,0 @@
-/*
- * Class: ColourButtonTableCellRenderer
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop.ui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-
-/**
- * A table cell renderer that uses a {@link JButton} to display a cell's
- * contents. The cell is assumed to hold a {@link Color} value.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
-public final class ColourButtonTableCellRenderer extends JLabel implements
- TableCellRenderer {
-
- static final long serialVersionUID = 8657616060311680421L;
-
- /**
- * Creates a colour button table cell renderer.
- */
- public ColourButtonTableCellRenderer() {
- setOpaque(true);
- setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
- final Dimension size = new Dimension(16, 16);
- setMaximumSize(size);
- setMinimumSize(size);
- setPreferredSize(size);
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
- */
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- setBackground((Color) value);
- return this;
- }
-
- /** Overridden for performance reasons. */
- public boolean isOpaque() {
- final Color back = getBackground();
- Component p = getParent();
- if (p != null) p = p.getParent();
- final boolean colorMatch = (back != null) && (p != null)
- && back.equals(p.getBackground()) && p.isOpaque();
- return !colorMatch && super.isOpaque();
- }
-
- /** Overridden for performance reasons. */
- public void repaint(long tm, int x, int y, int width, int height) {
- // Do nothing.
- }
-
- /** Overridden for performance reasons. */
- public void repaint(Rectangle r) {
- // Do nothing.
- }
-
- /**
- * Notification from the <code>UIManager</code> that the look and feel
- * [L&F] has changed. Replaces the current UI object with the latest version
- * from the <code>UIManager</code>.
- *
- * @see JComponent#updateUI
- */
- public void updateUI() {
- super.updateUI();
- setForeground(null);
- setBackground(null);
- }
-
-}
Deleted: trunk/rvsn00p/src/rvsnoop/ui/GhostDropPane.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/ui/GhostDropPane.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/rvsnoop/ui/GhostDropPane.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -1,287 +0,0 @@
-/*
- * Class: GhostDropPane
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop.ui;
-
-import java.awt.AlphaComposite;
-import java.awt.Component;
-import java.awt.Composite;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Transparency;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionListener;
-import java.util.ArrayList;
-import java.util.EventListener;
-import java.util.EventObject;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-
-/**
- * A glass pane that can draw ‘ghosted’ images.
- * <p>
- * This is based on the ideas in Romain Guy’s <a
- * href="http://www.jroller.com/page/gfx/20050216">weblog</a>.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
-public class GhostDropPane extends JPanel {
-
- /**
- * A utility class implementing {@link DropListener}.
- * <p>
- * Methods are provided to determine whether the drop event occurred inside a
- * given target component.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
- public class DropAdapter implements DropListener {
- protected final Component component;
-
- public DropAdapter(final Component component) {
- this.component = component;
- }
-
- protected Point getTranslatedPoint(final Point point) {
- final Point p = (Point) point.clone();
- SwingUtilities.convertPointFromScreen(p, component);
- return p;
- }
-
- /**
- * Override this method to set the drop behaviour.
- *
- * @see rvsnoop.ui.GhostDropPane.DropListener#ghostDropped(rvsnoop.ui.GhostDropPane.DropEvent)
- */
- public void ghostDropped(DropEvent e) {
- // Do nothing by default.
- }
-
- protected boolean isInTarget(final Point point) {
- final Rectangle bounds = component.getBounds();
- return bounds.contains(point);
- }
-
- }
-
- /**
- * An event indicating a ghosted component has been dropped.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
- public static class DropEvent extends EventObject {
-
- static final long serialVersionUID = -1760127114801081816L;
-
- private final Component component;
-
- private final Point point;
-
- public DropEvent(GhostDropPane source, Component component, Point point) {
- super(source);
- this.component = component;
- this.point = point;
- }
-
- /**
- * Get the component that was dropped.
- *
- * @return The component.
- */
- public Component getComponent() {
- return component;
- }
-
- /**
- * Get the point at which the drop occurred.
- *
- * @return The drop point.
- */
- public Point getDropLocation() {
- return point;
- }
-
- }
-
- /**
- * The interface for listening to ghost drop events.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
- public interface DropListener extends EventListener {
-
- /**
- * Invoked when a ghost drop event occurrs.
- *
- * @param e The drop event object.
- */
- public void ghostDropped(DropEvent e);
-
- }
-
- /**
- * A handler for mouse and mouse motion events relating to a ghost glass pane.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
- public class MouseHandler extends MouseAdapter
- implements MouseMotionListener {
-
- protected Component component;
-
- private List listeners;
-
- protected MouseHandler(final Component component) {
- this.component = component;
- }
-
- public synchronized void addGhostDropListener(final DropListener listener) {
- if (listener == null) return;
- if (listeners == null) listeners = new ArrayList(1);
- listeners.add(listener);
- }
-
- /**
- * Create the image that will be ghosted.
- * <p>
- * This is a hook for custom ghost images, normally the component is
- * drawn and subclasses can ignore this method.
- *
- * @param component The component to be drawn by default.
- * @param point The point drawn at.
- * @return The image to ghost.
- */
- protected Image createImage() {
- final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
- final GraphicsConfiguration config = env.getDefaultScreenDevice().getDefaultConfiguration();
- final Image image = config.createCompatibleImage(
- component.getWidth(), component.getHeight(), Transparency.TRANSLUCENT);
- final Graphics g = image.getGraphics();
- component.paint(g);
- g.dispose();
- return image;
- }
-
- /**
- * Can be used to provide an image offset if the image returned by
- * createImage is an irregular size.
- *
- * @return How to shift the ghosted image.
- */
- protected Point createImageOffset() {
- return null;
- }
-
- protected void fireGhostDropEvent(final Point point) {
- if (listeners == null || listeners.size() == 0) return;
- final DropEvent event = new DropEvent(GhostDropPane.this, component, point);
- for (final Iterator it = listeners.iterator(); it.hasNext(); )
- ((DropListener) it.next()).ghostDropped(event);
- }
-
- public void mouseDragged(final MouseEvent event) {
- if (!isVisible()) setVisible(true);
- setPoint(event);
- repaint();
- }
-
- public void mouseMoved(final MouseEvent event) {
- // NO-OP
- }
-
- public void mousePressed(final MouseEvent event) {
- final Image image = createImage();
- setPoint(event);
- setImage(image);
- setImageOffset(createImageOffset());
- }
-
- public void mouseReleased(final MouseEvent event) {
- setPoint(event);
- setVisible(false);
- setImage(null);
- fireGhostDropEvent(event.getPoint());
- }
-
- public void removeGhostDropListener(final DropListener listener) {
- if (listener == null || listeners == null) return;
- listeners.remove(listener);
- }
-
- /**
- * Ensures that a clone of the point is used and that it is in the
- * correct co-ordinate space.
- */
- protected void setPoint(MouseEvent event) {
- event = SwingUtilities.convertMouseEvent(event.getComponent(), event, GhostDropPane.this);
- GhostDropPane.this.setPoint(event.getPoint());
- }
-
- }
-
- static final long serialVersionUID = 1275432519912812028L;
-
- private final AlphaComposite composite =
- AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
-
- private Image dragged;
-
- private Point location = new Point(0, 0);
-
- private Point imageOffset;
-
- public GhostDropPane() {
- setOpaque(false);
- }
-
- public void paintComponent(final Graphics g) {
- if (dragged == null) return;
- final Graphics2D g2 = (Graphics2D) g;
- final Composite savedComposite = g2.getComposite();
- g2.setComposite(composite);
- int x = (int) (location.getX() - dragged.getWidth(this) / 2);
- int y = (int) (location.getY() - dragged.getHeight(this) / 2);
- if (imageOffset != null) {
- x += imageOffset.x;
- y += imageOffset.y;
- }
- g2.drawImage(dragged, x, y, null);
- g2.setComposite(savedComposite);
- }
-
- public void setImage(final Image dragged) {
- this.dragged = dragged;
- }
-
- public void setImageOffset(final Point offset) {
- this.imageOffset = offset;
- }
-
- public void setPoint(final Point location) {
- this.location = location;
- }
-
-}
\ No newline at end of file
Deleted: trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java 2007-01-18 12:39:10 UTC (rev 390)
+++ trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java 2007-01-18 13:31:58 UTC (rev 391)
@@ -1,463 +0,0 @@
-/*
- * Class: RecordTypesDialog
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop.ui;
-
-import java.awt.AlphaComposite;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.HeadlessException;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Robot;
-import java.awt.Transparency;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.image.BufferedImage;
-import java.util.Comparator;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractCellEditor;
-import javax.swing.DefaultCellEditor;
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JColorChooser;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.ListSelectionModel;
-import javax.swing.SwingUtilities;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import javax.swing.table.TableModel;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rvsnoop.actions.EditRecordTypes;
-import org.rvsnoop.ui.FooterPanel;
-import org.rvsnoop.ui.HeaderPanel;
-import org.rvsnoop.ui.ImageFactory;
-
-import rvsnoop.RecordMatcher;
-import rvsnoop.RecordType;
-import rvsnoop.RecordTypes;
-import ca.odell.glazedlists.gui.AdvancedTableFormat;
-import ca.odell.glazedlists.gui.WritableTableFormat;
-
-/**
- * A dialog to allow the record types in a project to be customized.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
-public final class RecordTypesDialog extends JDialog {
-
- private class ColourEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
- private static final String EDIT = "edit";
- static final long serialVersionUID = -5137692296675824971L;
- private final JButton button = new JButton();
- private JColorChooser colorChooser;
- private Color currentColor;
- private JDialog dialog;
-
- public ColourEditor() {
- button.setActionCommand(EDIT);
- button.addActionListener(this);
- button.setBorderPainted(false);
- final Dimension size = new Dimension(16, 16);
- button.setMaximumSize(size);
- button.setMinimumSize(size);
- button.setPreferredSize(size);
- }
-
- public void actionPerformed(ActionEvent e) {
- if (EDIT.equals(e.getActionCommand())) {
- if (colorChooser == null) {
- colorChooser = new JColorChooser();
- dialog = JColorChooser.createDialog(button,
- "Pick a Color", true, colorChooser, this, null);
- }
- button.setBackground(currentColor);
- colorChooser.setColor(currentColor);
- dialog.setVisible(true);
- fireEditingStopped();
- } else {
- currentColor = colorChooser.getColor();
- }
- }
-
- public Object getCellEditorValue() {
- return currentColor;
- }
-
- public Component getTableCellEditorComponent(JTable table,
- Object value, boolean isSelected, int row, int column) {
- currentColor = (Color)value;
- return button;
- }
- }
-
- private class DeleteEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
- private static final String EDIT = "edit";
- static final long serialVersionUID = 1812389580066670903L;
- private final JButton button = new JButton(Icons.DELETE);
- private int row = -1;
-
- public DeleteEditor() {
- button.setActionCommand(EDIT);
- button.addActionListener(this);
- button.setBorderPainted(false);
- }
-
- public void actionPerformed(ActionEvent e) {
- if (EDIT.equals(e.getActionCommand())) {
- fireEditingStopped();
- if (row >= 0) {
- final RecordTypes types = RecordTypes.getInstance();
- types.removeType(types.getType(row));
- }
- }
- }
-
- public Object getCellEditorValue() {
- return Icons.DELETE;
- }
-
- public Component getTableCellEditorComponent(JTable table,
- Object value, boolean isSelected, int row, int column) {
- this.row = row;
- return button;
- }
- }
-
- private class OKAction extends AbstractAction {
- static final long serialVersionUID = -652700991471360994L;
-
- OKAction() {
- super("OK");
- }
-
- public void actionPerformed(ActionEvent e) {
- RecordTypesDialog.this.setVisible(false);
- }
-
- }
-
- private class TypeMouseHandler extends GhostDropPane.MouseHandler {
- private Image image;
- private Point imageOffset;
- private long lastDragTime;
- private RecordType type;
-
- TypeMouseHandler(final Component component) {
- glass.super(component);
- }
-
- protected Image createImage() {
- return image;
- }
-
- protected Point createImageOffset() {
- return imageOffset;
- }
-
- private int getDropTarget(final Point point) {
- final int row = typesTable.rowAtPoint(point);
- if (row != -1) return row;
- SwingUtilities.convertPointToScreen(point, typesTable);
- final Point location = typesTable.getLocationOnScreen();
- if (point.y < location.y) return 0;
- return RecordTypes.getInstance().size();
- }
-
- /** Set the location for the drop target line to be drawn. */
- public void mouseDragged(final MouseEvent event) {
- dropIndex = getDropTarget(event.getPoint());
- lastDragTime = event.getWhen();
- super.mouseDragged(event);
- }
-
- /**
- * Cancel the drop target 250ms after the last drag gesture.
- *
- * @see rvsnoop.ui.GhostDropPane.MouseHandler#mouseMoved(java.awt.event.MouseEvent)
- */
- public void mouseMoved(final MouseEvent event) {
- if (event.getWhen() > lastDragTime + 250) dropIndex = -1;
- }
-
- public void mousePressed(final MouseEvent event) {
- final Point point = event.getPoint();
- type = RecordTypes.getInstance().getType(getDropTarget(event.getPoint()));
- // Create the image that will be used for ghosting
- final Rectangle bounds = typesTable.getCellRect(dropIndex, 0, true);
- bounds.add(typesTable.getCellRect(dropIndex, 5, true));
- final Point location = bounds.getLocation();
- SwingUtilities.convertPointToScreen(location, component);
- bounds.setLocation(location);
- try {
- image = new Robot().createScreenCapture(bounds);
- } catch (Exception e) {
- // If robot isn't supported by the graphics configuration
- // just use a plain gray rectangle of the correct size.
- if (log.isDebugEnabled()) {
- log.debug("Robotic image capture failed, using fallback method.", e);
- }
- image = new BufferedImage(bounds.width, bounds.height, Transparency.TRANSLUCENT);
- final Graphics2D g = (Graphics2D) image.getGraphics();
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f));
- g.setColor(Color.BLACK);
- g.fillRect(0, 0, bounds.width, bounds.height);
- g.dispose();
- }
- // Set the offset so that the image doesn't jump away from the cursor
- imageOffset = new Point(point.x / 2, image.getHeight(null) / 2);
- super.mousePressed(event);
- }
-
- /** Clear the location for the drop target line. */
- public void mouseReleased(MouseEvent event) {
- super.mouseReleased(event);
- dropIndex = getDropTarget(event.getPoint());
- RecordTypes.getInstance().reorderType(type, dropIndex);
- type = null;
- dropIndex = -1;
- }
-
- }
-
- /**
- * A table that draws a line over the drop index.
- */
- private class TypeTable extends JTable {
- static final long serialVersionUID = 5262986877021980127L;
-
- TypeTable(TableModel model) {
- super(model);
- }
-
- public void paint(Graphics g) {
- super.paint(g);
- if (dropIndex < 0) return;
- final Rectangle bounds = this.getCellRect(dropIndex, 0, true);
- bounds.add(getCellRect(dropIndex, 5, true));
- final Color color = g.getColor();
- g.setColor(Color.BLACK);
- g.fillRect(bounds.x, bounds.y, bounds.width, 2);
- g.setColor(color);
- }
- }
-
- private class TypeTableFormat implements AdvancedTableFormat, WritableTableFormat {
- TypeTableFormat() {
- super();
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.AdvancedTableFormat#getColumnClass(int)
- */
- public Class getColumnClass(int column) {
- switch (column) {
- case 0: return Boolean.class; // is selected
- case 1: return String.class; // name
- case 2: return Color.class; // colour
- case 3: return String.class; // matcher name
- case 4: return String.class; // matcher value
- case 5: return Icon.class; // delete button
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- /**
- * As the table is not sortable, this always returns <code>null</code>.
- *
- * @see ca.odell.glazedlists.gui.AdvancedTableFormat#getColumnComparator(int)
- */
- public Comparator getColumnComparator(int column) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.TableFormat#getColumnCount()
- */
- public int getColumnCount() {
- return 6;
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.TableFormat#getColumnName(int)
- */
- public String getColumnName(int column) {
- switch (column) {
- case 0: return " ";
- case 1: return "Type Name";
- case 2: return " ";
- case 3: return "Matcher Type";
- case 4: return "Matcher Value";
- case 5: return " ";
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.TableFormat#getColumnValue(java.lang.Object, int)
- */
- public Object getColumnValue(Object baseObject, int column) {
- final RecordType type = (RecordType) baseObject;
- switch (column) {
- case 0: return type.isSelected() ? Boolean.TRUE : Boolean.FALSE;
- case 1: return type.getName();
- case 2: return type.getColour();
- case 3: return type.getMatcherName();
- case 4: return type.getMatcherValue();
- case 5: return Icons.DELETE;
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.WritableTableFormat#isEditable(java.lang.Object, int)
- */
- public boolean isEditable(Object baseObject, int column) {
- // For the default type only the colour can be edited.
- if (RecordTypes.DEFAULT.equals(baseObject)) return column == 2;
- // For other types, allow editing of anything.
- return true;
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.gui.WritableTableFormat#setColumnValue(java.lang.Object, java.lang.Object, int)
- */
- public Object setColumnValue(Object baseObject, Object editedValue, int column) {
- final RecordType type = (RecordType) baseObject;
- try {
- switch (column) {
- case 0:
- final boolean selected = ((Boolean) editedValue).booleanValue();
- if (type.isSelected() == selected) return null;
- type.setSelected(selected);
- return type;
- case 1:
- if (type.getName().equals(editedValue)) return null;
- type.setName((String) editedValue);
- return type;
- case 2:
- if (type.getColour().equals(editedValue)) return null;
- type.setColour((Color) editedValue);
- return type;
- case 3:
- if (type.getMatcherName().equals(editedValue)) return null;
- type.setMatcherName((String) editedValue);
- return type;
- case 4:
- if (type.getMatcherValue().equals(editedValue)) return null;
- type.setMatcherValue((String) editedValue);
- return type;
- }
- } catch (IllegalArgumentException e) {
- JOptionPane.showMessageDialog(RecordTypesDialog.this,
- e.getMessage(), "Warning: Invalid Value",
- JOptionPane.WARNING_MESSAGE);
- }
- return null;
- }
- }
-
- static String HEADER_MESSAGE = "Drag the record types to re-order their priorities."
- + "\nAll changes will take effect immediately.";
-
- static String HEADER_TITLE = "Edit Record Types";
-
- private static final Log log = LogFactory.getLog(RecordTypesDialog.class);
-
- static final long serialVersionUID = -7458805721398275868L;
-
- private int dropIndex = -1;
-
- private final GhostDropPane glass = new GhostDropPane();
-
- private final JTable typesTable;
-
- /**
- * Creates a new <code>RecordTypesDialog</code>.
- *
- * @throws HeadlessException if the VM is running in headless mode.
- */
- public RecordTypesDialog() {
- super((Frame) null, true); // true == modal
- setGlassPane(glass);
- Container contents = getContentPane();
- contents.setLayout(new BorderLayout());
- final HeaderPanel header = new HeaderPanel(HEADER_TITLE, HEADER_MESSAGE,
- ImageFactory.getInstance().getBannerImage(EditRecordTypes.COMMAND));
- contents.add(header, BorderLayout.NORTH);
- typesTable = createContents();
- JScrollPane scroller = new JScrollPane(typesTable);
- scroller.setBackground(typesTable.getBackground());
- contents.add(scroller, BorderLayout.CENTER);
- final FooterPanel footer = new FooterPanel(new OKAction(), null, null);
- contents.add(footer, BorderLayout.SOUTH);
- footer.configureActionMap();
- }
-
- private JTable createContents() {
- final TableModel model = RecordTypes.getInstance().getTableModel(new TypeTableFormat());
- final JTable table = new TypeTable(model);
- table.setRowSelectionAllowed(true);
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- table.setShowGrid(false);
- table.setRowHeight(24);
- final TableColumnModel columns = table.getColumnModel();
- columns.getColumn(1).setCellRenderer(new TextFieldTableCellRenderer());
- columns.getColumn(1).setCellEditor(new DefaultCellEditor(new JTextField()));
- columns.getColumn(2).setCellRenderer(new ColourButtonTableCellRenderer());
- columns.getColumn(2).setCellEditor(new ColourEditor());
- columns.getColumn(3).setCellEditor(new DefaultCellEditor(new JComboBox(RecordMatcher.getMatcherNames())));
- columns.getColumn(4).setCellRenderer(new TextFieldTableCellRenderer());
- columns.getColumn(5).setCellEditor(new DeleteEditor());
- final TypeMouseHandler handler = new TypeMouseHandler(table);
- table.addMouseListener(handler);
- table.addMouseMotionListener(handler);
- return table;
- }
-
- public void setVisible(boolean visible) {
- if (visible) {
- final TableColumnModel columns = typesTable.getColumnModel();
- shrinkColumn(columns, 0);
- shrinkColumn(columns, 2);
- shrinkColumn(columns, 5);
- }
- super.setVisible(visible);
- }
-
- private void shrinkColumn(TableColumnModel columns, int column) {
- final Object value = typesTable.getValueAt(0, column);
- final TableCellRenderer renderer = typesTable.getCellRenderer(0, column);
- final int width = renderer.getTableCellRendererComponent(typesTable, value, false, false, 0, column).getMinimumSize().width + 4;
- final TableColumn c = columns.getColumn(column);
- c.setMaxWidth(width);
- c.setMinWidth(width);
- c.setPreferredWidth(width);
- c.setResizable(false);
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2007-01-18 12:39:11
|
Revision: 390
http://svn.sourceforge.net/rvsn00p/?rev=390&view=rev
Author: ianp
Date: 2007-01-18 04:39:10 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Altered connections to use composition (HAS-A) instead of inheritance (IS-A).
Refactored RecentConnections menu manager into separate class in UI package.
Modified Paths:
--------------
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java
trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
trunk/rvsn00p/src/rvsnoop/Project.java
trunk/rvsn00p/src/rvsnoop/RecentConnections.java
trunk/rvsn00p/src/rvsnoop/RecordSelection.java
trunk/rvsn00p/src/rvsnoop/RvConnection.java
trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/Connections.java
trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.java
Removed Paths:
-------------
trunk/rvsn00p/src/rvsnoop/Connections.java
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Modified: trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -34,6 +34,14 @@
this.cause = cause;
}
+ /**
+ * @param cause
+ */
+ public CausedIOException(Throwable cause) {
+ super("");
+ this.cause = cause;
+ }
+
/* (non-Javadoc)
* @see java.lang.Throwable#getCause()
*/
Copied: trunk/rvsn00p/src/org/rvsnoop/Connections.java (from rev 384, trunk/rvsn00p/src/rvsnoop/Connections.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Connections.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/Connections.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -0,0 +1,312 @@
+/*
+ * Class: Connections
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.text.Collator;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EventListener;
+import java.util.Iterator;
+
+import javax.swing.ListModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import rvsnoop.RvConnection;
+import ca.odell.glazedlists.GlazedLists;
+import ca.odell.glazedlists.ObservableElementList;
+import ca.odell.glazedlists.SortedList;
+import ca.odell.glazedlists.event.ListEventListener;
+import ca.odell.glazedlists.swing.EventListModel;
+import ca.odell.glazedlists.util.concurrent.Lock;
+
+/**
+ * A list of connections.
+ * <p>
+ * The list of connections is responsible for ensuring that no duplicate
+ * connections are added to the list and then whenever a connection is removed
+ * from the list it is stopped first.
+ * <p>
+ * Also, whenever a connection is added to the list it is 'activated' by calling
+ * the protected method {@link RvConnection#setParentList(Connections)}.
+ * <p>
+ * This class wraps a sorted event list to which calls are delegated, the
+ * wrapper methods handle ensuring no duplicates are added to the list and also
+ * all synchronization using the Glazed Lists locking idiom.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date: 2007-01-08 08:07:22 +0000 (Mon, 08 Jan
+ * 2007) $
+ * @since 1.6
+ */
+public final class Connections {
+
+ private static class DescriptionComparator implements Comparator {
+ private final Collator collator = Collator.getInstance();
+
+ public DescriptionComparator() {
+ super();
+ }
+
+ public int compare(Object o1, Object o2) {
+ final String d1 = ((RvConnection) o1).getDescription();
+ final String d2 = ((RvConnection) o2).getDescription();
+ return collator.compare(d1, d2);
+ }
+ }
+
+ private static class Observer implements ObservableElementList.Connector,
+ PropertyChangeListener {
+ private ObservableElementList list;
+
+ Observer() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#installListener(java.lang.Object)
+ */
+ public EventListener installListener(Object element) {
+ ((RvConnection) element).addPropertyChangeListener(this);
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ list.elementChanged(evt.getSource());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#setObservableElementList(ca.odell.glazedlists.ObservableElementList)
+ */
+ public void setObservableElementList(ObservableElementList list) {
+ this.list = list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ca.odell.glazedlists.ObservableElementList.Connector#uninstallListener(java.lang.Object,
+ * java.util.EventListener)
+ */
+ public void uninstallListener(Object element, EventListener listener) {
+ ((RvConnection) element).removePropertyChangeListener(this);
+ }
+ }
+
+ private static Connections instance;
+
+ private static final Log log = LogFactory.getLog(Connections.class);
+
+ public static final String NAMESPACE = "http://rvsnoop.org/ns/connections/1";
+
+ // TODO remove this method, access connections via the application object
+ public static synchronized Connections getInstance() {
+ if (instance == null) { instance = new Connections(null, true); }
+ return instance;
+ }
+
+ private final ObservableElementList list;
+
+ private final boolean ownsConnections;
+
+ public Connections(Collection connections, boolean ownsConnections) {
+ if (connections == null) { connections = Collections.EMPTY_LIST; }
+ this.list = new ObservableElementList(
+ new SortedList(
+ GlazedLists.eventList(connections),
+ new DescriptionComparator()),
+ new Observer());
+ this.ownsConnections = ownsConnections;
+ }
+
+ /**
+ * As allowed by the contract for {@link java.util.Collection#add(Object)}
+ * this method will not add duplicates to the list.
+ *
+ * @param connection The connection to add.
+ * @return <code>true</code> if the argument was added, <code>false</code>
+ * otherwise.
+ * @see java.util.List#add(java.lang.Object)
+ */
+ public boolean add(RvConnection connection) {
+ final Lock lock = list.getReadWriteLock().writeLock();
+ lock.lock();
+ try {
+ if (list.contains(connection)) {
+ if (log.isInfoEnabled()) {
+ log.info("Ignoring attempt to add duplicate connection: "
+ + connection);
+ }
+ return false;
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Adding connection: " + connection);
+ }
+ if (ownsConnections) { connection.setParentList(this); }
+ list.add(connection);
+ return true;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * @param listChangeListener
+ * @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
+ */
+ public void addListEventListener(ListEventListener listChangeListener) {
+ list.addListEventListener(listChangeListener);
+ }
+
+ /**
+ * @see java.util.List#clear()
+ */
+ public void clear() {
+ final Lock lock = list.getReadWriteLock().writeLock();
+ lock.lock();
+ try {
+ while (list.size() > 0) {
+ final RvConnection connection = (RvConnection) list.get(0);
+ if (log.isInfoEnabled()) {
+ log.info("Removing connection: " + connection);
+ }
+ if (ownsConnections) {
+ connection.stop();
+ connection.setParentList(null);
+ }
+ list.remove(0);
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public ListModel createListModel() {
+ return new EventListModel(list);
+ }
+
+ /**
+ * Get an existing connection.
+ *
+ * @param service The Rendezvous service parameter.
+ * @param network The Rendezvous network parameter.
+ * @param daemon The Rendezvous daemon parameter.
+ * @return The existing connection, or <code>null</code> if it does not
+ * exist.
+ */
+ public RvConnection get(String service, String network, String daemon) {
+ final Lock lock = list.getReadWriteLock().readLock();
+ lock.lock();
+ try {
+ for (final Iterator i = list.iterator(); i.hasNext();) {
+ final RvConnection c = (RvConnection) i.next();
+ if (c.getService().equals(service)
+ && c.getDaemon().equals(daemon)
+ && c.getNetwork().equals(network))
+ return c;
+ }
+ return null;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * @return An iterator over all of the connections.
+ * @see java.util.List#iterator()
+ */
+ public Iterator iterator() {
+ return list.iterator();
+ }
+
+ /**
+ * @param connection The connection to remove.
+ * @return <code>true</code> if a connection was removed,
+ * <code>false</code> otherwise.
+ * @see java.util.List#remove(java.lang.Object)
+ */
+ public boolean remove(RvConnection connection) {
+ final Lock lock = list.getReadWriteLock().writeLock();
+ lock.lock();
+ try {
+ if (!list.contains(connection)) { return false; }
+ if (log.isInfoEnabled()) {
+ log.info("Removing connection: " + connection);
+ }
+ if (ownsConnections) {
+ connection.stop();
+ connection.setParentList(null);
+ }
+ list.remove(connection);
+ return true;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * @param listChangeListener
+ * @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
+ */
+ public void removeListEventListener(ListEventListener listChangeListener) {
+ list.removeListEventListener(listChangeListener);
+ }
+
+ /**
+ * @return The number of connections.
+ * @see java.util.List#size()
+ */
+ public int size() {
+ final Lock lock = list.getReadWriteLock().readLock();
+ lock.lock();
+ try {
+ return list.size();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * @return An array containing all of the connections. The contents may be
+ * safely cast to <code>RvConnection[]</code>.
+ * @see java.util.List#toArray()
+ */
+ public RvConnection[] toArray() {
+ final Lock lock = list.getReadWriteLock().readLock();
+ lock.lock();
+ try {
+ return (RvConnection[]) list.toArray(new RvConnection[list.size()]);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public void toXML(XMLBuilder builder) throws IOException {
+ builder.startTag("connections", NAMESPACE);
+ final RvConnection[] connections = toArray();
+ for (int i = 0, imax = connections.length; i < imax; ++i) {
+ connections[i].toXML(builder);
+ }
+ builder.endTag();
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/Connections.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -117,7 +117,7 @@
public synchronized boolean isFilteringOnType() {
return typeFilter != null;
}
-
+
public boolean isFreezable() {
return freezableList != null && !freezableList.isFrozen();
}
Added: trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -0,0 +1,160 @@
+/*
+ * Class: XMLBuilder
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.znerd.xmlenc.LineBreak;
+import org.znerd.xmlenc.XMLOutputter;
+
+/**
+ * A builder for writing XML documents.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class XMLBuilder {
+
+ private boolean declared;
+
+ private final String namespace;
+
+ private final Map namespaces;
+
+ private boolean started;
+
+ private final XMLOutputter xml;
+
+ /**
+ * @param stream The stream to write to.
+ * @param ns The default namespace for the document.
+ * @param namespaces A namespace to prefix mapping for the document.
+ */
+ public XMLBuilder(OutputStream stream, String ns, Map namespaces) {
+ if (!(stream instanceof BufferedOutputStream)) {
+ stream = new BufferedOutputStream(stream);
+ }
+ try {
+ this.xml = new XMLOutputter(new OutputStreamWriter(stream), "UTF-8");
+ xml.setEscaping(true);
+ xml.setIndentation(" ");
+ xml.setLineBreak(LineBreak.UNIX);
+ xml.setQuotationMark('\'');
+ this.namespace = ns != null ? ns : "";
+ this.namespaces = new LinkedHashMap(namespaces);
+ } catch (Exception e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ public XMLBuilder attribute(String name, String value) throws IOException {
+ try {
+ xml.attribute(name, value);
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder attribute(String name, String value, String ns) throws IOException {
+ return attribute(namespaces.get(ns).toString() + ':' + name, value);
+ }
+
+ public void close() throws IOException {
+ try {
+ xml.endDocument();
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder comment(String text) throws IOException {
+ try {
+ xml.comment(text);
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder dtd(String name, String publicID, String systemID) throws IOException {
+ try {
+ xml.declaration();
+ declared = true;
+ xml.dtd(name, publicID, systemID);
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder endTag() throws IOException {
+ try {
+ xml.endTag();
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder pcdata(String text) throws IOException {
+ try {
+ xml.pcdata(text);
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder startTag(String type) throws IOException {
+ try {
+ if (!declared) {
+ xml.declaration();
+ declared = true;
+ }
+ xml.startTag(type);
+ if (!started) {
+ if (namespace.length() > 0) {
+ xml.attribute("xmlns", namespace);
+ }
+ for (Iterator i = namespaces.keySet().iterator(); i.hasNext(); ) {
+ final String nsuri = (String) i.next();
+ final String prefix = (String) namespaces.get(nsuri);
+ xml.attribute("xmlns:" + prefix, nsuri);
+ }
+ started = true;
+ }
+ return this;
+ } catch (IllegalStateException e) {
+ throw new CausedIOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new CausedIOException(e);
+ }
+ }
+
+ public XMLBuilder startTag(String type, String ns) throws IOException {
+ return startTag(namespaces.get(ns).toString() + ':' + type);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/XMLBuilder.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -132,7 +132,7 @@
daf.createSendSubjectAccessor(),
pf.createStringStartsWithPredicate(sendSubject, false)));
}
-
+
for (int i = 0, imax = records.length; i < imax; ++i) {
strings[i] = records[i].getReplySubject();
}
@@ -142,7 +142,7 @@
daf.createReplySubjectAccessor(),
pf.createStringStartsWithPredicate(replySubject, false)));
}
-
+
for (int i = 0, imax = records.length; i < imax; ++i) {
strings[i] = records[i].getTrackingId();
}
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -12,9 +12,9 @@
import javax.swing.Action;
import org.rvsnoop.Application;
+import org.rvsnoop.Connections;
import org.rvsnoop.NLSUtils;
-import rvsnoop.Connections;
import rvsnoop.RecentConnections;
import rvsnoop.RvConnection;
import rvsnoop.ui.RvConnectionDialog;
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -17,11 +17,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.Application;
+import org.rvsnoop.Connections;
import org.rvsnoop.NLSUtils;
import org.rvsnoop.event.RecordLedgerSelectionEvent;
import org.rvsnoop.event.RecordLedgerSelectionListener;
-import rvsnoop.Connections;
import rvsnoop.Record;
import rvsnoop.RvConnection;
import rvsnoop.State;
@@ -64,7 +64,7 @@
final String question = MessageFormat.format(QUESTION_CONFIRM,
new Object[] { new Integer(currentSelection.length) });
// FIXME get the connection list from Application
- final RvConnection[] connections = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] connections = Connections.getInstance().toArray();
final String[] connectionNames = new String[connections.length];
for (int i = 0, imax = connections.length; i < imax; ++i) {
connectionNames[i] = connections[i].getDescription();
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -20,12 +20,10 @@
import javax.swing.event.PopupMenuListener;
import org.rvsnoop.Application;
+import org.rvsnoop.Connections;
import org.rvsnoop.actions.NewRvConnection;
-import rvsnoop.Connections;
-import rvsnoop.RecentConnections;
import rvsnoop.RvConnection;
-import ca.odell.glazedlists.swing.EventListModel;
/**
* A custom <code>JList</code> that is used to draw the connection list.
@@ -71,7 +69,7 @@
* @param connections The connections to display in the list.
*/
public ConnectionList(Application application, Connections connections) {
- super(new EventListModel(Connections.getInstance()));
+ super(Connections.getInstance().createListModel());
this.application = application;
setBorder(BorderFactory.createEmptyBorder());
final ConnectionListCellRenderer renderer =
@@ -110,7 +108,7 @@
final JMenu recent = new JMenu("Recent Connections");
recent.setIcon(new ImageIcon(
ImageFactory.getInstance().getIconImage(NewRvConnection.COMMAND)));
- recent.addMenuListener(RecentConnections.getInstance().new MenuManager());
+ recent.addMenuListener(new RecentConnectionsMenuManager());
popupMenu.add(recent);
popupMenu.show(this, x, y);
}
Added: trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/RecentConnectionsMenuManager.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -0,0 +1,109 @@
+/*
+ * Class: RecentConnectionsMenuManager
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.util.Iterator;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+
+import org.rvsnoop.Connections;
+
+import rvsnoop.RvConnection;
+
+/**
+ * A manager to handle the display of all known record types.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.7
+ */
+public final class RecentConnectionsMenuManager implements MenuListener, PopupMenuListener {
+
+ private final class MenuItem extends JMenuItem implements ActionListener {
+ private static final long serialVersionUID = -6436657697729548579L;
+ final RvConnection connection;
+ public MenuItem(RvConnection connection, int index) {
+ super(connection.getDescription());
+ this.connection = connection;
+ setMnemonic(KeyEvent.VK_0 + index);
+ addActionListener(this);
+ }
+ public void actionPerformed(ActionEvent e) {
+ Connections.getInstance().add(connection);
+ connection.start();
+ }
+ }
+
+ public RecentConnectionsMenuManager() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.MenuListener#menuCanceled(javax.swing.event.MenuEvent)
+ */
+ public void menuCanceled(MenuEvent e) {
+ ((JMenu) e.getSource()).removeAll();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.MenuListener#menuDeselected(javax.swing.event.MenuEvent)
+ */
+ public void menuDeselected(MenuEvent e) {
+ // Do nothing.
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.MenuListener#menuSelected(javax.swing.event.MenuEvent)
+ */
+ public void menuSelected(MenuEvent e) {
+ final JMenu menu = (JMenu) e.getSource();
+ menu.removeAll();
+ final Iterator i = Connections.getInstance().iterator();
+ int count = 0;
+ while (i.hasNext()) {
+ menu.add(new MenuItem((RvConnection) i.next(), ++count));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent)
+ */
+ public void popupMenuCanceled(PopupMenuEvent e) {
+ ((JPopupMenu) e.getSource()).removeAll();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent)
+ */
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+ // Do nothing.
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
+ */
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ final JPopupMenu menu = (JPopupMenu) e.getSource();
+ menu.removeAll();
+ final Iterator i = Connections.getInstance().iterator();
+ int count = 0;
+ while (i.hasNext()) {
+ menu.add(new MenuItem((RvConnection) i.next(), ++count));
+ }
+ }
+
+}
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -70,14 +70,14 @@
private static final Image BANNER =
ImageFactory.getInstance().getBannerImage("searchResults");
-
+
static String BUTTON_FREEZE, BUTTON_OK, BUTTON_UNFREEZE;
static String DIALOG_TITLE, TITLE, DESCRIPTION, TOOLTIP_VISIBLE_COLUMNS;
-
+
private final JPopupMenu columnsPopup = new JPopupMenu();
private final FilteredLedgerView results;
-
+
public SearchResultsDialog(Frame parent, RecordLedger results) {
super(parent, DIALOG_TITLE, false); // false == non-modal
if (results instanceof FilteredLedgerView) {
@@ -100,10 +100,10 @@
});
colsButton.setBorderPainted(false);
scrollpane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, colsButton);
-
+
final FreezeAction freeze = new FreezeAction();
final OKAction ok = new OKAction();
-
+
getContentPane().setLayout(new BorderLayout());
getContentPane().add(new HeaderPanel(TITLE, DESCRIPTION, BANNER), BorderLayout.NORTH);
getContentPane().add(scrollpane, BorderLayout.CENTER);
Deleted: trunk/rvsn00p/src/rvsnoop/Connections.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/Connections.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/Connections.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -1,551 +0,0 @@
-/*
- * Class: Connections
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package rvsnoop;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.text.Collator;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.EventListener;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import ca.odell.glazedlists.BasicEventList;
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.ObservableElementList;
-import ca.odell.glazedlists.SortedList;
-import ca.odell.glazedlists.event.ListEventListener;
-import ca.odell.glazedlists.event.ListEventPublisher;
-import ca.odell.glazedlists.util.concurrent.Lock;
-import ca.odell.glazedlists.util.concurrent.ReadWriteLock;
-
-/**
- * A list of connections.
- * <p>
- * The list of connections is responsible for ensuring that no duplicate
- * connections are added to the list and then whenever a connection is removed
- * from the list it is stopped first.
- * <p>
- * Also, whenever a connection is added to the list it is 'activated' by calling
- * the protected method {@link RvConnection#setParentList(Connections)}.
- * <p>
- * This class wraps a sorted event list to which calls are delegated, the
- * wrapper methods handle ensuring no duplicates are added to the list and also
- * all synchronization using the Glazed Lists locking idiom.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.6
- */
-public final class Connections implements EventList {
-
- private static class DescriptionComparator implements Comparator {
- private final Collator collator = Collator.getInstance();
- public DescriptionComparator() {
- super();
- }
- public int compare(Object o1, Object o2) {
- final String d1 = ((RvConnection) o1).getDescription();
- final String d2 = ((RvConnection) o2).getDescription();
- return collator.compare(d1, d2);
- }
- }
-
- private static class Observer implements ObservableElementList.Connector, PropertyChangeListener {
- private ObservableElementList list;
- Observer() {
- super();
- }
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.ObservableElementList.Connector#installListener(java.lang.Object)
- */
- public EventListener installListener(Object element) {
- ((RvConnection) element).addPropertyChangeListener(this);
- return this;
- }
- /* (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- list.elementChanged(evt.getSource());
- }
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.ObservableElementList.Connector#setObservableElementList(ca.odell.glazedlists.ObservableElementList)
- */
- public void setObservableElementList(ObservableElementList list) {
- this.list = list;
- }
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.ObservableElementList.Connector#uninstallListener(java.lang.Object, java.util.EventListener)
- */
- public void uninstallListener(Object element, EventListener listener) {
- ((RvConnection) element).removePropertyChangeListener(this);
- }
- }
-
- private static Connections instance;
-
- private static final Log log = LogFactory.getLog(Connections.class);
-
- public static synchronized Connections getInstance() {
- if (instance == null) instance = new Connections();
- return instance;
- }
-
- private final ObservableElementList list = new ObservableElementList(
- new SortedList(new BasicEventList(), new DescriptionComparator()),
- new Observer());
-
- private Connections() {
- super();
- }
-
- /**
- * As allowed by the contract for {@link java.util.List#add(int, Object)}
- * this method will not add duplicates to the list. Note that unlike a
- * call to the un-indexed add method this will throw an
- * <code>IllegalStateException</code> if the element is not added.
- *
- * @param index The index to add the connection at.
- * @param element The connection to add.
- * @see java.util.List#add(int, java.lang.Object)
- */
- public void add(int index, Object element) {
- if (!add(element)) throw new IllegalStateException("Duplicate element not added.");
- }
-
- /**
- * As allowed by the contract for {@link java.util.Collection#add(Object)}
- * this method will not add duplicates to the list.
- *
- * @param o The connection to add.
- * @return <code>true</code> if the argument was added, <code>false</code> otherwise.
- * @see java.util.List#add(java.lang.Object)
- */
- public boolean add(Object o) {
- list.getReadWriteLock().writeLock().lock();
- try {
- return internalAdd((RvConnection) o);
- } finally {
- list.getReadWriteLock().writeLock().unlock();
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.List#addAll(java.util.Collection)
- */
- public boolean addAll(Collection c) {
- list.getReadWriteLock().writeLock().lock();
- boolean added = false;
- try {
- for (final Iterator i = c.iterator(); i.hasNext();)
- added = internalAdd((RvConnection) i.next()) || added;
- } finally {
- list.getReadWriteLock().writeLock().unlock();
- }
- return added;
- }
-
- /* (non-Javadoc)
- * @see java.util.List#addAll(int, java.util.Collection)
- */
- public boolean addAll(int index, Collection c) {
- return addAll(c);
- }
-
- /**
- * @param listChangeListener
- * @see ca.odell.glazedlists.EventList#addListEventListener(ca.odell.glazedlists.event.ListEventListener)
- */
- public void addListEventListener(ListEventListener listChangeListener) {
- list.addListEventListener(listChangeListener);
- }
-
- /**
- * @see java.util.List#clear()
- */
- public void clear() {
- list.getReadWriteLock().writeLock().lock();
- try {
- while (list.size() > 0)
- internalRemove(0);
- } finally {
- list.getReadWriteLock().writeLock().unlock();
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.List#contains(java.lang.Object)
- */
- public boolean contains(Object o) {
- list.getReadWriteLock().readLock().lock();
- try {
- return list.contains(o);
- } finally {
- list.getReadWriteLock().readLock().unlock();
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.List#containsAll(java.util.Collection)
- */
- public boolean containsAll(Collection c) {
- list.getReadWriteLock().readLock().lock();
- try {
- return list.containsAll(c);
- } finally {
- list.getReadWriteLock().readLock().unlock();
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.equals(o);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @param index The index of the connection to return.
- * @return The connection at the specified position in this list.
- * @throws IndexOutOfBoundsException if the index is out of range (index
- * < 0 || index >= size()).
- * @see java.util.List#get(int)
- */
- public Object get(int index) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.get(index);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Get an existing connection.
- *
- * @param service The Rendezvous service parameter.
- * @param network The Rendezvous network parameter.
- * @param daemon The Rendezvous daemon parameter.
- * @return The existing connection, or <code>null</code> if it does not exist.
- */
- public RvConnection get(String service, String network, String daemon) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- for (final Iterator i = list.iterator(); i.hasNext();) {
- final RvConnection c = (RvConnection) i.next();
- if (c.getService().equals(service) &&
- c.getDaemon().equals(daemon) &&
- c.getNetwork().equals(network))
- return c;
- }
- return null;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @return The publisher used to distribute {@link ListEvent}s.
- * @see ca.odell.glazedlists.EventList#getPublisher()
- */
- public ListEventPublisher getPublisher() {
- return list.getPublisher();
- }
-
- /**
- * @return A re-entrant {@link ReadWriteLock} that guarantees thread safe
- * access to this list.
- * @see ca.odell.glazedlists.EventList#getReadWriteLock()
- */
- public ReadWriteLock getReadWriteLock() {
- return list.getReadWriteLock();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return list.hashCode();
- }
-
- /**
- * @param o The connection to search for.
- * @return The index in of the first occurrence of the specified
- * connection, or -1 if this list does not contain this connection.
- * @see java.util.List#indexOf(java.lang.Object)
- */
- public int indexOf(Object o) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.indexOf(o);
- } finally {
- lock.unlock();
- }
- }
-
- private boolean internalAdd(RvConnection connection) {
- if (list.contains(connection)) {
- if (log.isInfoEnabled()) {
- log.info("Ignoring attempt to add duplicate connection: " + connection);
- }
- return false;
- }
- if (log.isInfoEnabled()) {
- log.info("Adding connection: " + connection);
- }
- connection.setParentList(this);
- list.add(connection);
- return true;
- }
-
- private RvConnection internalRemove(int index) {
- final RvConnection connection = (RvConnection) list.get(index);
- if (log.isInfoEnabled()) {
- log.info("Removing connection: " + connection);
- }
- connection.stop();
- connection.setParentList(null);
- list.remove(index);
- return connection;
- }
-
- private boolean internalRemove(RvConnection connection) {
- if (!list.contains(connection)) { return false; }
- if (log.isInfoEnabled()) {
- log.info("Removing connection: " + connection);
- }
- connection.stop();
- connection.setParentList(null);
- list.remove(connection);
- return true;
- }
-
- /**
- * @return <code>true</code> if there are no connections, <code>false</code>
- * otherwise.
- * @see java.util.List#isEmpty()
- */
- public boolean isEmpty() {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.isEmpty();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @return An iterator over all of the connections.
- * @see java.util.List#iterator()
- */
- public Iterator iterator() {
- return list.iterator();
- }
-
- /**
- * @param o The connection to search for.
- * @return The index in this list of the last occurrence of the specified
- * connection, or -1 if this list does not contain this connection.
- * @see java.util.List#lastIndexOf(java.lang.Object)
- */
- public int lastIndexOf(Object o) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.lastIndexOf(o);
- } finally {
- lock.unlock();
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.List#listIterator()
- */
- public ListIterator listIterator() {
- return list.listIterator();
- }
-
- /* (non-Javadoc)
- * @see java.util.List#listIterator(int)
- */
- public ListIterator listIterator(int index) {
- return list.listIterator(index);
- }
-
- /**
- * @param index The connection index to remove.
- * @return <code>true</code> if a connection was removed,
- * <code>false</code> otherwise.
- * @see java.util.List#remove(int)
- */
- public Object remove(int index) {
- final Lock lock = list.getReadWriteLock().writeLock();
- lock.lock();
- try {
- return internalRemove(index);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @param o The connection to remove.
- * @return <code>true</code> if a connection was removed,
- * <code>false</code> otherwise.
- * @see java.util.List#remove(java.lang.Object)
- */
- public boolean remove(Object o) {
- final Lock lock = list.getReadWriteLock().writeLock();
- lock.lock();
- try {
- return internalRemove((RvConnection) o);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @param c The connections to remove.
- * @return <code>true</code> if any connections were removed,
- * <code>false</code> otherwise.
- * @see java.util.List#removeAll(java.util.Collection)
- */
- public boolean removeAll(Collection c) {
- final Lock lock = list.getReadWriteLock().writeLock();
- lock.lock();
- boolean removed = false;
- try {
- for (final Iterator i = c.iterator(); i.hasNext();)
- removed = internalRemove((RvConnection) i.next()) || removed;
- } finally {
- lock.unlock();
- }
- return removed;
- }
-
- /**
- * @param listChangeListener
- * @see ca.odell.glazedlists.EventList#removeListEventListener(ca.odell.glazedlists.event.ListEventListener)
- */
- public void removeListEventListener(ListEventListener listChangeListener) {
- list.removeListEventListener(listChangeListener);
- }
-
- /**
- * This operation is not supported.
- *
- * @param c Ignored.
- * @return The method never returns.
- * @see java.util.List#retainAll(java.util.Collection)
- * @throws UnsupportedOperationException Always.
- */
- public boolean retainAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * This may be used to update elements in place but must not be used to set
- * arbitrary elements.
- *
- * @param index The index to update.
- * @param element The element already at the index.
- * @return The <code>element</code> argument (actually the element at
- * <code>index</code>, but they are guaranteed to be equal, even if not
- * identical).
- * @throws IllegalArgumentException if the element at <code>index</code> is
- * not equal to the <code>element</code> argument.
- * @see java.util.List#set(int, java.lang.Object)
- */
- public Object set(int index, Object element) {
- final Lock lock = list.getReadWriteLock().writeLock();
- lock.lock();
- try {
- final RvConnection connection = (RvConnection) list.get(index);
- if (!(connection.equals(element)))
- throw new IllegalArgumentException("Elements don't match! " + connection + " and " + element);
- return list.set(index, element);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @return The number of connections.
- * @see java.util.List#size()
- */
- public int size() {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.size();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * This operation is not supported.
- *
- * @param fromIndex Ignored.
- * @param toIndex Ignored.
- * @return The method never returns.
- * @see java.util.List#subList(int, int)
- * @throws UnsupportedOperationException Always.
- */
- public List subList(int fromIndex, int toIndex) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return An array containing all of the connections. The contents may be
- * safely cast to <code>RvConnection[]</code>.
- * @see java.util.List#toArray()
- */
- public Object[] toArray() {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.toArray(new RvConnection[list.size()]);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @param a The array to copy the connections into.
- * @return An array containing all of the connections. The contents may be
- * safely cast to <code>RvConnection[]</code>.
- * @see java.util.List#toArray(java.lang.Object[])
- */
- public Object[] toArray(Object[] a) {
- final Lock lock = list.getReadWriteLock().readLock();
- lock.lock();
- try {
- return list.toArray(a);
- } finally {
- lock.unlock();
- }
- }
-
-}
Modified: trunk/rvsn00p/src/rvsnoop/Project.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/Project.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/Project.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -14,6 +14,8 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
+import org.rvsnoop.Connections;
+
import nu.xom.Attribute;
import nu.xom.Document;
import nu.xom.Element;
@@ -163,7 +165,7 @@
}
public static void storeConnections(Element parent) {
- final RvConnection[] connections = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] connections = Connections.getInstance().toArray();
for (int i = 0, imax = connections.length; i < imax; ++i)
parent.appendChild(connections[i].toXml());
}
Modified: trunk/rvsn00p/src/rvsnoop/RecentConnections.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/RecentConnections.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/RecentConnections.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -7,40 +7,31 @@
*/
package rvsnoop;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.event.MenuEvent;
-import javax.swing.event.MenuListener;
+import nu.xom.Builder;
+import nu.xom.Document;
+import nu.xom.Elements;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.Connections;
+import org.rvsnoop.XMLBuilder;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.event.ListEvent;
import ca.odell.glazedlists.event.ListEventListener;
-import nu.xom.Builder;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.Elements;
-import nu.xom.Serializer;
-
/**
* Provides access to a list of recently used connections.
* <p>
@@ -54,54 +45,8 @@
*/
public final class RecentConnections implements ListEventListener {
- private class AddRecentConnection extends AbstractAction {
- private static final long serialVersionUID = -8554698925345247337L;
- private final RvConnection connection;
- AddRecentConnection(int index, RvConnection connection) {
- super(index + " Add " + connection.getDescription());
- putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_0 + index));
- this.connection = connection;
- }
-
- public void actionPerformed(ActionEvent e) {
- Connections.getInstance().add(connection);
- connection.start();
- }
-
- }
-
- /**
- * A class that can populate a menu with recent connections.
- */
- public class MenuManager implements MenuListener {
- public MenuManager() {
- super();
- }
- public void menuCanceled(MenuEvent e) {
- ((JMenu) e.getSource()).removeAll();
- }
- public void menuDeselected(MenuEvent e) {
- // Do nothing.
- }
- public void menuSelected(MenuEvent e) {
- final JMenu menu = (JMenu) e.getSource();
- menu.removeAll();
- if (connections.size() == 0) {
- final JMenuItem item = menu.add("No Recent Connections");
- item.setEnabled(false);
- } else {
- int index = 0;
- for (final Iterator i = connections.iterator(); i.hasNext(); )
- menu.add(new AddRecentConnection(index++, (RvConnection) i.next()));
- }
- }
- }
-
private static final int DEFAULT_MAX_SIZE = 10;
- private static final String XML_ELEMENT = "connections";
- private static final String XML_NS = "http://rvsnoop.org/ns/connections/1";
-
public static RecentConnections instance;
private static final Log log = LogFactory.getLog(RecentConnections.class);
@@ -215,15 +160,14 @@
}
OutputStream stream = null;
try {
- final Element root = new Element(XML_ELEMENT, XML_NS);
- for (final Iterator i = Connections.getInstance().iterator(); i.hasNext(); )
- root.appendChild(((RvConnection) i.next()).toXml());
- stream = new BufferedOutputStream(new FileOutputStream(file));
- final Serializer ser = new Serializer(stream);
- ser.setIndent(2);
- ser.setLineSeparator(IOUtils.LINE_SEPARATOR);
- ser.write(new Document(root));
- ser.flush();
+ stream = new FileOutputStream(file);
+ String namespace = Connections.NAMESPACE;
+ Map namespaces = ArrayUtils.toMap(new String[][] {
+ { Connections.NAMESPACE, "c" },
+ { RvConnection.XML_NS, "rv" } } );
+ XMLBuilder builder = new XMLBuilder(stream, namespace, namespaces);
+ new Connections(connections, false).toXML(builder);
+ builder.close();
} finally {
IOUtils.closeQuietly(stream);
}
Modified: trunk/rvsn00p/src/rvsnoop/RecordSelection.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/RecordSelection.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/RecordSelection.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -28,6 +28,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.rvsnoop.CausedIOException;
+import org.rvsnoop.Connections;
import com.tibco.tibrv.TibrvException;
import com.tibco.tibrv.TibrvMsg;
Modified: trunk/rvsn00p/src/rvsnoop/RvConnection.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/RvConnection.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/RvConnection.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -10,6 +10,7 @@
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -27,6 +28,8 @@
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.Connections;
+import org.rvsnoop.XMLBuilder;
import org.rvsnoop.actions.PauseConnection;
import org.rvsnoop.actions.StartConnection;
import org.rvsnoop.actions.StopConnection;
@@ -88,7 +91,7 @@
private void invalidateListener(TibrvListener listener) {
final String listenerSubject = listener.getSubject();
final List toRemove = new ArrayList();
- final RvConnection[] conns = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] conns = Connections.getInstance().toArray();
for (int i = 0, imax = conns.length; i < imax; ++i) {
final RvConnection conn = conns[i];
for (final Iterator j = conn.subjects.keySet().iterator(); j.hasNext();) {
@@ -103,7 +106,7 @@
}
private void invalidateTransport(TibrvRvaTransport transport) {
- final RvConnection[] conns = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] conns = Connections.getInstance().toArray();
for (int i = 0, imax = conns.length; i < imax; ++i) {
if (transport.equals(conns[i].transport)) {
conns[i].stop();
@@ -263,7 +266,7 @@
queueLimitListener = new TibrvListener(queue, new NullCallback(), Tibrv.processTransport(), "_RV.WARN.SYSTEM.QUEUE.LIMIT_EXCEEDED", null);
queue.setLimitPolicy(TibrvQueue.DISCARD_NEW, 1, 1);
}
- final RvConnection[] conns = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] conns = Connections.getInstance().toArray();
for (int i = 0, imax = conns.length; i < imax; ++i) {
if (conns[i].getState() == State.STARTED)
conns[i].pause();
@@ -286,7 +289,7 @@
queueLimitListener = null;
}
}
- final RvConnection[] conns = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] conns = Connections.getInstance().toArray();
for (int i = 0, imax = conns.length; i < imax; ++i) {
if (conns[i].getState() == State.PAUSED)
conns[i].start();
@@ -295,7 +298,7 @@
public static synchronized void shutdown() {
if (queue == null) return;
- final RvConnection[] conns = (RvConnection[]) Connections.getInstance().toArray();
+ final RvConnection[] conns = Connections.getInstance().toArray();
for (int i = 0, imax = conns.length; i < imax; ++i)
conns[i].stop();
try {
@@ -607,7 +610,8 @@
*
* @param connection The connection list.
*/
- protected void setParentList(Connections connection) {
+ public void setParentList(Connections connection) {
+ // FIXME reduce visibility to package
if (connection == null && state != State.STOPPED)
throw new IllegalStateException("Connection not stopped!");
parentList = connection;
@@ -687,4 +691,16 @@
return element;
}
+ public void toXML(XMLBuilder builder) throws IOException {
+ builder.startTag("connection", XML_NS)
+ .attribute("description", description)
+ .attribute("service", service)
+ .attribute("network", network)
+ .attribute("daemon", daemon);
+ for (Iterator i = getSubjects().iterator(); i.hasNext(); ) {
+ builder.startTag("subject").pcdata(i.next().toString()).endTag();
+ }
+ builder.endTag();
+ }
+
}
Modified: trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/ui/UIManager.java 2007-01-18 09:42:50 UTC (rev 389)
+++ trunk/rvsn00p/src/rvsnoop/ui/UIManager.java 2007-01-18 12:39:10 UTC (rev 390)
@@ -51,33 +51,33 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rvsnoop.Application;
+import org.rvsnoop.Connections;
import org.rvsnoop.RecordLedger;
-import org.rvsnoop.actions.DisplayAbout;
-import org.rvsnoop.actions.FilterBySelection;
-import org.rvsnoop.actions.NewRvConnection;
import org.rvsnoop.actions.ClearLedger;
import org.rvsnoop.actions.Copy;
import org.rvsnoop.actions.Cut;
import org.rvsnoop.actions.Delete;
+import org.rvsnoop.actions.DisplayAbout;
import org.rvsnoop.actions.EditRecordTypes;
import org.rvsnoop.actions.Filter;
+import org.rvsnoop.actions.FilterBySelection;
+import org.rvsnoop.actions.NewRvConnection;
import org.rvsnoop.actions.OpenProject;
import org.rvsnoop.actions.Paste;
import org.rvsnoop.actions.Quit;
import org.rvsnoop.actions.Republish;
+import org.rvsnoop.actions.SaveProject;
import org.rvsnoop.actions.SaveProjectAs;
-import org.rvsnoop.actions.SaveProject;
import org.rvsnoop.actions.Search;
import org.rvsnoop.actions.SearchBySelection;
import org.rvsnoop.ui.ConnectionList;
import org.rvsnoop.ui.ImageFactory;
+import org.rvsnoop.ui.RecentConnectionsMenuManager;
import org.rvsnoop.ui.RecordLedgerTable;
import org.rvsnoop.ui.RecordTypesMenuManager;
import org.rvsnoop.ui.VisibleColumnsMenuManager;
-import rvsnoop.Connections;
import rvsnoop.PreferencesManager;
-import rvsnoop.RecentConnections;
import rvsnoop.RecentProjects;
import rvsnoop.Record;
import rvsnoop.SubjectHierarchy;
@@ -301,7 +301,7 @@
file.add(factory.getAction(NewRvConnection.COMMAND));
final JMenu connRecent = new JMenu("Recent Connections");
connRecent.setIcon(Icons.ADD_CONNECTION);
- connRecent.addMenuListener(RecentConnections.getInstance().new MenuManager());
+ connRecent.addMenuListener(new RecentConnectionsMenuManager());
file.add(connRecent);
file.addSeparator();
file.add(factory.getAction(Quit.COMMAND));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2007-01-18 09:42:51
|
Revision: 389
http://svn.sourceforge.net/rvsn00p/?rev=389&view=rev
Author: ianp
Date: 2007-01-18 01:42:50 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Added in some missing resources.
Fixed some display problems in the search results window.
Modified Paths:
--------------
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties
Added Paths:
-----------
trunk/rvsn00p/src/resources/banners/search.png
trunk/rvsn00p/src/resources/banners/searchBySelection.png
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java 2007-01-18 09:14:09 UTC (rev 388)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java 2007-01-18 09:42:50 UTC (rev 389)
@@ -61,7 +61,7 @@
}
public int hashCode() {
int result = 1;
- result = PRIME * result + name != null ? name.hashCode() : 0;
+ result = PRIME * result + (name != null ? name.hashCode() : 0);
result = PRIME * result + w;
result = PRIME * result + h;
return result;
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java 2007-01-18 09:14:09 UTC (rev 388)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java 2007-01-18 09:42:50 UTC (rev 389)
@@ -42,7 +42,8 @@
private final class FreezeAction extends AbstractAction {
private static final long serialVersionUID = 2493033730732619900L;
private boolean freeze = true;
- public FreezeAction() {
+ FreezeAction() {
+ super(BUTTON_FREEZE);
setEnabled(false);
}
public synchronized void actionPerformed(ActionEvent e) {
@@ -54,6 +55,9 @@
private final class OKAction extends AbstractAction {
private static final long serialVersionUID = 7702235052544107033L;
+ public OKAction() {
+ super(BUTTON_OK);
+ }
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties 2007-01-18 09:14:09 UTC (rev 388)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties 2007-01-18 09:42:50 UTC (rev 389)
@@ -2,6 +2,6 @@
BUTTON_OK=Close
BUTTON_UNFREEZE=Unfreeze
DIALOG_TITLE=Search Results Window
-DESCRIPTION=The results of your search will be displayed and updated in real-time. To pause this behaviour press the \u201a\u00c4\u00f2freeze\u201a\u00c4\u00f4 button.
+DESCRIPTION=The results of your search will be displayed and updated in real-time. To pause this behaviour press the \u2018freeze\u2019 button.
TITLE=Live Search Results
TOOLTIP_VISIBLE_COLUMNS=Show or hide columns in the ledger
\ No newline at end of file
Added: trunk/rvsn00p/src/resources/banners/search.png
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/src/resources/banners/search.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/rvsn00p/src/resources/banners/searchBySelection.png
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/src/resources/banners/searchBySelection.png
___________________________________________________________________
Name: svn:executable
+ *
Name: 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: <ia...@us...> - 2007-01-18 09:14:12
|
Revision: 388
http://svn.sourceforge.net/rvsn00p/?rev=388&view=rev
Author: ianp
Date: 2007-01-18 01:14:09 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Added search by selection using new search framework.
Modified Paths:
--------------
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/org/rvsnoop/Application.java
trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Search.java
trunk/rvsn00p/src/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
trunk/rvsn00p/tests/org/rvsnoop/FilteredLedgerViewTest.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/actions/Search.properties
trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java
trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.properties
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties
trunk/rvsn00p/src/resources/banners/searchResults.png
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Modified: trunk/rvsn00p/src/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -90,7 +90,7 @@
*/
public synchronized FilteredLedgerView getFilteredLedger() {
if (filteredLedger == null) {
- filteredLedger = new FilteredLedgerView(getLedger());
+ filteredLedger = FilteredLedgerView.newInstance(getLedger(), false);
}
return filteredLedger;
}
@@ -149,7 +149,7 @@
this.project = project;
// TODO configure the ledger from data in the project file.
ledger = new InMemoryLedger();
- filteredLedger = new FilteredLedgerView(ledger);
+ filteredLedger = FilteredLedgerView.newInstance(ledger, false);
}
/**
Modified: trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -11,6 +11,7 @@
import rvsnoop.SubjectHierarchy;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
+import ca.odell.glazedlists.FreezableList;
import ca.odell.glazedlists.matchers.CompositeMatcherEditor;
import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.matchers.MatcherEditor;
@@ -39,21 +40,30 @@
}
+ public static FilteredLedgerView newInstance(RecordLedger ledger, boolean freezable) {
+ if (freezable) {
+ final FreezableList freezableList = new FreezableList(ledger.getEventList());
+ final FilterList filter = new FilterList(freezableList);
+ final FilteredLedgerView view = new FilteredLedgerView(filter);
+ view.freezableList = freezableList;
+ return view;
+ } else {
+ return new FilteredLedgerView(new FilterList(ledger.getEventList()));
+ }
+ }
+
private final CompositeMatcherEditor filters = new CompositeMatcherEditor();
+ private FreezableList freezableList;
+
private MatcherEditor subjectFilter;
private MatcherEditor typeFilter;
- /**
- * Create a new <code>FilteredLedgerView</code>.
- *
- * @param ledger The base ledger to display records from.
- * @param feezable Can this view be frozen.
- */
- public FilteredLedgerView(RecordLedger ledger) {
- super(new FilterList(ledger.getEventList()));
- ((FilterList) getEventList()).setMatcherEditor(filters);
+ /** Create a new <code>FilteredLedgerView</code>. */
+ protected FilteredLedgerView(FilterList list) {
+ super(list);
+ list.setMatcherEditor(filters);
filters.setMode(CompositeMatcherEditor.AND);
setFilteringOnSubject(true);
setFilteringOnType(true);
@@ -107,9 +117,13 @@
public synchronized boolean isFilteringOnType() {
return typeFilter != null;
}
+
+ public boolean isFreezable() {
+ return freezableList != null && !freezableList.isFrozen();
+ }
public synchronized boolean isFrozen() {
- return false;
+ return freezableList != null && freezableList.isFrozen();
}
/**
@@ -177,4 +191,12 @@
}
}
+ public void setFrozen(boolean frozen) {
+ if (frozen) {
+ freezableList.freeze();
+ } else {
+ freezableList.thaw();
+ }
+ }
+
}
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -18,6 +18,7 @@
import org.apache.commons.lang.text.StrBuilder;
import org.rvsnoop.Application;
import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.RecordLedger;
import org.rvsnoop.matchers.DataAccessorFactory;
import org.rvsnoop.matchers.PredicateFactory;
import org.rvsnoop.matchers.RvSnoopMatcherEditor;
@@ -59,8 +60,6 @@
final EventList newMatchers = dialog.getCopyOfEditors();
if (newMatchers == null) { return; } // User cancelled dialog.
- // TODO add equals methods to the matcher editors so that this works as
- // expected. The equals methods will need to use non-final fields.
final List added = new ArrayList(newMatchers);
added.removeAll(oldMatchers);
final List removed = new ArrayList(oldMatchers);
@@ -73,6 +72,8 @@
for (Iterator i = removed.iterator(); i.hasNext(); ) {
ledger.removeFilter((MatcherEditor) i.next());
}
+
+ displayResults(ledger);
}
/**
@@ -109,6 +110,7 @@
}
}
+
/**
* Configure the matchers based on multiple records.
*
@@ -155,6 +157,15 @@
}
}
+ /**
+ * Hook to notify subclasses that the results need displaying.
+ *
+ * @param ledger The results to display.
+ */
+ protected void displayResults(RecordLedger ledger) {
+ // Do nothing by default, assume that the results are already displayed.
+ }
+
private final String findLongestCommonSubstring(String[] strings) {
final StrBuilder builder = new StrBuilder();
int pos = 0;
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -36,7 +36,7 @@
private static final long serialVersionUID = -5949027962663244889L;
public static final String COMMAND = "filterBySelection";
- static String ACCELERATOR, DESCRIPTION, MNEMONIC, NAME, TITLE, TOOLTIP;
+ static String DESCRIPTION, NAME, TITLE, TOOLTIP;
private transient Record[] currentSelection;
@@ -45,8 +45,6 @@
putValue(Action.ACTION_COMMAND_KEY, COMMAND);
putSmallIconValue(COMMAND);
putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putMnemonicValue(MNEMONIC);
- putAcceleratorValue(ACCELERATOR);
}
/* (non-Javadoc)
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties 2007-01-18 09:14:09 UTC (rev 388)
@@ -1,8 +1,5 @@
-# 0x53 == KeyEvent.VK_S
-ACCELERATOR=ALT+SHIFT+0x53
DESCRIPTION=Select the criteria you wish to include in the visible ledger.\
You can use Java regular expressions for more fine grained control.
-MNEMONIC=0x53
NAME=Filter By Selection
TITLE=Filter Record Ledger
TOOLTIP=Filter the contents of the ledger
\ No newline at end of file
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Search.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Search.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Search.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -7,203 +7,86 @@
*/
package org.rvsnoop.actions;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
+import java.awt.Image;
-import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.JOptionPane;
-import javax.swing.KeyStroke;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.Application;
+import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.RecordLedger;
+import org.rvsnoop.ui.ImageFactory;
+import org.rvsnoop.ui.SearchResultsDialog;
-import rvsnoop.MessageLedger;
-import rvsnoop.Record;
-import rvsnoop.ui.Icons;
-import rvsnoop.ui.SearchDialog;
-import rvsnoop.ui.UIManager;
-import ca.odell.glazedlists.matchers.Matcher;
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
-import com.tibco.tibrv.TibrvException;
-import com.tibco.tibrv.TibrvMsg;
-import com.tibco.tibrv.TibrvMsgField;
-import com.tibco.tibrv.TibrvXml;
-
/**
- * Search for text in the message bodies.
+ * Start a new live search in the ledger contents.
*
* @author <a href="mailto:ia...@ia...">Ian Phillips</a>
* @version $Revision$, $Date$
* @since 1.4
*/
-public final class Search extends AbstractAction {
+public final class Search extends AbstractSearchAction {
- private class Searcher implements Matcher {
- private final boolean fieldData;
- private final boolean fieldNames;
- private final boolean replySubject;
- private final boolean sendSubject;
- private final boolean trackingId;
- private final String searchText;
- Searcher(boolean fieldData, boolean fieldNames, boolean replySubject,
- boolean sendSubject, boolean trackingId, String searchText) {
- this.fieldData = fieldData;
- this.fieldNames = fieldNames;
- this.replySubject = replySubject;
- this.sendSubject = sendSubject;
- this.trackingId = trackingId;
- this.searchText = searchText;
- }
+ static { NLSUtils.internationalize(Search.class); }
- private boolean isTextInFieldData(String text, TibrvMsgField field) throws TibrvException {
- if (fieldNames && field.name.indexOf(text) >= 0) return true;
- switch (field.type) {
- case TibrvMsg.MSG:
- return isTextInMessageData(text, (TibrvMsg) field.data);
- case TibrvMsg.STRING:
- return ((String) field.data).indexOf(text) >= 0;
- case TibrvMsg.XML:
- // XXX: Should we do something here to sniff the correct encoding from the bytes?
- return isTextInXmlData(text.getBytes(), ((TibrvXml) field.data).getBytes());
- default:
- return false;
- }
- }
+ private static final long serialVersionUID = 1861453185869256202L;
- /**
- * Search all of the text in a message for a given string.
- * <p>
- * This will search all fields which contain strings, and recursively search
- * all nested messages.
- *
- * @param text The text to search for.
- * @param message The message to search.
- * @return <code>true</code> if the text was matched, <code>false</code>
- * otherwise.
- * @throws TibrvException
- */
- private boolean isTextInMessageData(String text, TibrvMsg message) throws TibrvException {
- for (int i = 0, imax = message.getNumFields(); i < imax; ++i)
- if (isTextInFieldData(text, message.getFieldByIndex(i)))
- return true;
- return false;
- }
+ static String ACCELERATOR, DESCRIPTION, MNEMONIC, NAME, TITLE, TOOLTIP;
- private boolean isTextInXmlData(byte[] text, byte[] xml) {
- final byte firstByte = text[0];
- SCAN_XML:
- for (int i = 0, imax = xml.length; i < imax; ++i) {
- if (xml[i] != firstByte) continue;
- if (text.length == 1) return true; // Guard for single byte text.
- if (++i == xml.length) return false; // Guard for end of XML.
- // OK, now look for the rest of the text...
- for (int j = 1, jmax = text.length; j < jmax; ) {
- if (xml[i] != text[j]) continue SCAN_XML;
- if (++i == xml.length) return false; // Guard for end of XML.
- if (++j == text.length) return true;
- }
- }
- return false;
- }
+ public static final String COMMAND = "search";
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.matchers.Matcher#matches(java.lang.Object)
- */
- public boolean matches(Object item) {
- if (!(item instanceof Record)) { return false; }
- final Record record = (Record) item;
- if ((fieldData || fieldNames) && matchMessage(record)) return true;
- if (sendSubject && matchSendSubject(record)) return true;
- if (replySubject && matchReplySubject(record)) return true;
- return trackingId && matchTrackingId(record);
- }
+ public Search(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
- private boolean matchMessage(Record record) {
- try {
- return isTextInMessageData(searchText, record.getMessage());
- } catch (TibrvException e) {
- if (log.isErrorEnabled()) {
- log.error("Error reading message field.", e);
- }
- return false;
- }
- }
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#displayResults(org.rvsnoop.RecordLedger)
+ */
+ protected void displayResults(RecordLedger ledger) {
+ new SearchResultsDialog(application.getFrame().getFrame(), ledger).setVisible(true);
+ }
- private boolean matchReplySubject(Record record) {
- final String replySubject = record.getReplySubject();
- return replySubject != null && replySubject.indexOf(searchText) >= 0;
- }
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getDescription()
+ */
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
- private boolean matchSendSubject(Record record) {
- final String sendSubject = record.getSendSubject();
- return sendSubject != null && sendSubject.indexOf(searchText) >= 0;
- }
-
- private boolean matchTrackingId(Record record) {
- final String trackingId = record.getTrackingId();
- return trackingId != null && trackingId.indexOf(searchText) >= 0;
- }
-
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getImage()
+ */
+ protected Image getImage() {
+ return ImageFactory.getInstance().getBannerImage(COMMAND);
}
- private static final Log log = LogFactory.getLog(Search.class);
-
- public static final String SEARCH = "search";
-
- public static final String SEARCH_AGAIN = "searchAgain";
-
- private static final long serialVersionUID = -5833838900255559506L;
-
- private String searchText = "Enter your search text here";
-
- private boolean trackingId;
- private boolean fieldData = true;
- private boolean fieldNames;
- private boolean sendSubject;
- private boolean replySubject;
-
- public Search(String id, String name, String tooltip, int accel) {
- super(name);
- putValue(Action.ACTION_COMMAND_KEY, id);
- if (SEARCH.equals(id))
- putValue(Action.SMALL_ICON, Icons.SEARCH);
- else if (SEARCH_AGAIN.equals(id))
- putValue(Action.SMALL_ICON, Icons.SEARCH_AGAIN);
- if (accel != 0) {
- final int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
- putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(accel, mask));
- }
- putValue(Action.SHORT_DESCRIPTION, tooltip);
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getLedger()
+ */
+ protected FilteredLedgerView getLedger() {
+ return FilteredLedgerView.newInstance(application.getLedger(), true);
}
/* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getMatcherEditors()
*/
- public void actionPerformed(ActionEvent event) {
- if (SEARCH.equals(event.getActionCommand()) && !showDialog()) return;
- if (searchText == null || (searchText = searchText.trim()).length() == 0) return;
- final Searcher searcher = new Searcher(fieldData, fieldNames,
- replySubject, sendSubject, trackingId, searchText);
- final int[] indices = MessageLedger.FILTERED_VIEW.findAllIndices(searcher);
- if (indices.length == 0) {
- JOptionPane.showMessageDialog(UIManager.INSTANCE.getFrame(), "Nothing matched.");
- } else {
- // TODO: Display SearchResultsWindow
- }
+ protected EventList getMatcherEditors() {
+ return new BasicEventList();
}
- private boolean showDialog() {
- final SearchDialog dialog = new SearchDialog(searchText, fieldData, fieldNames, sendSubject, replySubject, trackingId);
- dialog.setVisible(true);
- if (dialog.isCancelled()) return false;
- searchText = dialog.getSearchText();
- fieldData = dialog.isFieldDataSelected();
- fieldNames = dialog.isFieldNamesSelected();
- sendSubject = dialog.isSendSubjectSelected();
- replySubject = dialog.isReplySubjectSelected();
- trackingId = dialog.isTrackingIdSelected();
- return true;
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getTitle()
+ */
+ protected String getTitle() {
+ return TITLE;
}
}
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Search.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Search.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Search.properties 2007-01-18 09:14:09 UTC (rev 388)
@@ -0,0 +1,7 @@
+# 0x53 == KeyEvent.VK_S
+ACCELERATOR=ALT+SHIFT+0x53
+DESCRIPTION=Select the criteria you wish to include in the search results.\nYou can use Java regular expressions for more fine grained control.
+MNEMONIC=0x53
+NAME=Search
+TITLE=Search Record Ledger
+TOOLTIP=Start a new live search on the ledger
\ No newline at end of file
Added: trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -0,0 +1,108 @@
+/*
+ * Class: SearchBySelection
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Image;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.RecordLedger;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+import org.rvsnoop.ui.ImageFactory;
+import org.rvsnoop.ui.SearchResultsDialog;
+
+import rvsnoop.Record;
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
+
+/**
+ * Start a new live search based on the current selection.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.7
+ */
+public final class SearchBySelection extends AbstractSearchAction implements RecordLedgerSelectionListener {
+
+ static { NLSUtils.internationalize(SearchBySelection.class); }
+
+ private static final long serialVersionUID = -4624032296697618690L;
+
+ public static final String COMMAND = "searchBySelection";
+ static String DESCRIPTION, NAME, TITLE, TOOLTIP;
+
+ private transient Record[] currentSelection;
+
+ public SearchBySelection(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#displayResults(org.rvsnoop.RecordLedger)
+ */
+ protected void displayResults(RecordLedger ledger) {
+ new SearchResultsDialog(application.getFrame().getFrame(), ledger).setVisible(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getDescription()
+ */
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getImage()
+ */
+ protected Image getImage() {
+ return ImageFactory.getInstance().getBannerImage(COMMAND);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getLedger()
+ */
+ protected FilteredLedgerView getLedger() {
+ return application.getFilteredLedger();
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getMatcherEditors()
+ */
+ protected EventList getMatcherEditors() {
+ final EventList matchers = new BasicEventList();
+ if (currentSelection.length == 1) {
+ configureMatchers(matchers, currentSelection[0]);
+ } else {
+ configureMatchers(matchers, currentSelection);
+ }
+ return matchers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getTitle()
+ */
+ protected String getTitle() {
+ return TITLE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ currentSelection = event.getSelectedRecords();
+ setEnabled(currentSelection.length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/SearchBySelection.properties 2007-01-18 09:14:09 UTC (rev 388)
@@ -0,0 +1,4 @@
+DESCRIPTION=Select the criteria you wish to include in the search results.\nYou can use Java regular expressions for more fine grained control.
+NAME=Search By Selection
+TITLE=Search Record Ledger
+TOOLTIP=Start a new live search on the ledger
\ No newline at end of file
Added: trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -0,0 +1,111 @@
+/*
+ * Class: SearchResultsDialog
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.ScrollPaneConstants;
+
+import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.RecordLedger;
+
+import rvsnoop.ui.Icons;
+import rvsnoop.ui.TrackingAdjustmentListener;
+import rvsnoop.ui.UIUtils;
+
+/**
+ * A dialog for displaying search results.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class SearchResultsDialog extends JDialog {
+
+ private final class FreezeAction extends AbstractAction {
+ private static final long serialVersionUID = 2493033730732619900L;
+ private boolean freeze = true;
+ public FreezeAction() {
+ setEnabled(false);
+ }
+ public synchronized void actionPerformed(ActionEvent e) {
+ putValue(Action.NAME, freeze ? BUTTON_UNFREEZE : BUTTON_FREEZE);
+ results.setFrozen(freeze);
+ freeze = !freeze;
+ }
+ }
+
+ private final class OKAction extends AbstractAction {
+ private static final long serialVersionUID = 7702235052544107033L;
+ public void actionPerformed(ActionEvent e) {
+ setVisible(false);
+ dispose();
+ }
+ }
+
+ static { NLSUtils.internationalize(SearchResultsDialog.class); }
+
+ private static final long serialVersionUID = 5216848181389646587L;
+
+ private static final Image BANNER =
+ ImageFactory.getInstance().getBannerImage("searchResults");
+
+ static String BUTTON_FREEZE, BUTTON_OK, BUTTON_UNFREEZE;
+ static String DIALOG_TITLE, TITLE, DESCRIPTION, TOOLTIP_VISIBLE_COLUMNS;
+
+ private final JPopupMenu columnsPopup = new JPopupMenu();
+
+ private final FilteredLedgerView results;
+
+ public SearchResultsDialog(Frame parent, RecordLedger results) {
+ super(parent, DIALOG_TITLE, false); // false == non-modal
+ if (results instanceof FilteredLedgerView) {
+ this.results = (FilteredLedgerView) results;
+ } else {
+ this.results = FilteredLedgerView.newInstance(results, true);
+ }
+
+ final RecordLedgerTable table = new RecordLedgerTable(results);
+ columnsPopup.addPopupMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
+ final JScrollPane scrollpane = new JScrollPane(table);
+ scrollpane.setBorder(BorderFactory.createEmptyBorder());
+ scrollpane.getVerticalScrollBar().addAdjustmentListener(new TrackingAdjustmentListener());
+ scrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ final JButton colsButton = UIUtils.createSmallButton(Icons.COLUMNS_CORNER, TOOLTIP_VISIBLE_COLUMNS, null);
+ colsButton.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ columnsPopup.show(colsButton, e.getX(), e.getY());
+ }
+ });
+ colsButton.setBorderPainted(false);
+ scrollpane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, colsButton);
+
+ final FreezeAction freeze = new FreezeAction();
+ final OKAction ok = new OKAction();
+
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(new HeaderPanel(TITLE, DESCRIPTION, BANNER), BorderLayout.NORTH);
+ getContentPane().add(scrollpane, BorderLayout.CENTER);
+ getContentPane().add(new FooterPanel(ok, null, new Action[] { freeze }), BorderLayout.SOUTH);
+ pack();
+ setLocationRelativeTo(parent);
+ }
+
+}
Added: trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/SearchResultsDialog.properties 2007-01-18 09:14:09 UTC (rev 388)
@@ -0,0 +1,7 @@
+BUTTON_FREEZE=Freeze
+BUTTON_OK=Close
+BUTTON_UNFREEZE=Unfreeze
+DIALOG_TITLE=Search Results Window
+DESCRIPTION=The results of your search will be displayed and updated in real-time. To pause this behaviour press the \u201a\u00c4\u00f2freeze\u201a\u00c4\u00f4 button.
+TITLE=Live Search Results
+TOOLTIP_VISIBLE_COLUMNS=Show or hide columns in the ledger
\ No newline at end of file
Added: trunk/rvsn00p/src/resources/banners/searchResults.png
===================================================================
(Binary files differ)
Property changes on: trunk/rvsn00p/src/resources/banners/searchResults.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/rvsn00p/src/rvsnoop/actions/Actions.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/actions/Actions.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/rvsnoop/actions/Actions.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -41,6 +41,7 @@
import org.rvsnoop.actions.SaveProjectAs;
import org.rvsnoop.actions.SaveProject;
import org.rvsnoop.actions.Search;
+import org.rvsnoop.actions.SearchBySelection;
import org.rvsnoop.event.RecordLedgerSelectionListener;
import org.rvsnoop.ui.RecordLedgerTable;
@@ -109,10 +110,6 @@
public static final Action REPORT_BUG = add(new ReportBug());
- public static final Action SEARCH = add(new Search(Search.SEARCH, "Find...", "Search for text in the messages", KeyEvent.VK_F));
-
- public static final Action SEARCH_AGAIN = add(new Search(Search.SEARCH_AGAIN, "Find Next", "Repeat the last search", KeyEvent.VK_G));
-
public static final Action SELECT_ALL_MESSAGES = add(new SelectAllMessages());
public static final Action SHOW_ALL_COLUMNS = add(new ShowAllColumns());
@@ -170,6 +167,8 @@
addAction(new Republish(application));
addAction(new SaveProject(application));
addAction(new SaveProjectAs(application));
+ addAction(new Search(application));
+ addAction(new SearchBySelection(application));
addAction(new Quit(application));
}
Modified: trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
===================================================================
--- trunk/rvsn00p/src/rvsnoop/ui/UIManager.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/src/rvsnoop/ui/UIManager.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -67,6 +67,8 @@
import org.rvsnoop.actions.Republish;
import org.rvsnoop.actions.SaveProjectAs;
import org.rvsnoop.actions.SaveProject;
+import org.rvsnoop.actions.Search;
+import org.rvsnoop.actions.SearchBySelection;
import org.rvsnoop.ui.ConnectionList;
import org.rvsnoop.ui.ImageFactory;
import org.rvsnoop.ui.RecordLedgerTable;
@@ -261,8 +263,8 @@
edit.add(factory.getAction(Copy.COMMAND));
edit.add(factory.getAction(Paste.COMMAND));
edit.addSeparator();
- edit.add(Actions.SEARCH);
- edit.add(Actions.SEARCH_AGAIN);
+ edit.add(factory.getAction(Search.COMMAND));
+ edit.add(factory.getAction(SearchBySelection.COMMAND));
edit.addSeparator();
edit.add(factory.getAction(Republish.COMMAND));
edit.addSeparator();
Modified: trunk/rvsn00p/tests/org/rvsnoop/FilteredLedgerViewTest.java
===================================================================
--- trunk/rvsn00p/tests/org/rvsnoop/FilteredLedgerViewTest.java 2007-01-17 14:48:22 UTC (rev 387)
+++ trunk/rvsn00p/tests/org/rvsnoop/FilteredLedgerViewTest.java 2007-01-18 09:14:09 UTC (rev 388)
@@ -20,7 +20,7 @@
* @see org.rvsnoop.RecordLedgerTest#createRecordLedger()
*/
protected RecordLedger createRecordLedger() {
- return new FilteredLedgerView(new InMemoryLedger());
+ return FilteredLedgerView.newInstance(new InMemoryLedger(), false);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2007-01-17 14:48:23
|
Revision: 387
http://svn.sourceforge.net/rvsn00p/?rev=387&view=rev
Author: ianp
Date: 2007-01-17 06:48:22 -0800 (Wed, 17 Jan 2007)
Log Message:
-----------
Moved FilterBySelection to use new matcher framework.
Made initial filters smarter when selecting multiple records.
Modified Paths:
--------------
trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.java
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-17 14:21:43 UTC (rev 386)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-17 14:48:22 UTC (rev 387)
@@ -15,13 +15,20 @@
import javax.swing.JFrame;
+import org.apache.commons.lang.text.StrBuilder;
import org.rvsnoop.Application;
import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.matchers.DataAccessorFactory;
+import org.rvsnoop.matchers.PredicateFactory;
+import org.rvsnoop.matchers.RvSnoopMatcherEditor;
import org.rvsnoop.ui.MatcherEditorListDialog;
+import rvsnoop.Record;
+
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.matchers.MatcherEditor;
+import ca.odell.glazedlists.util.concurrent.Lock;
/**
* Base class for actions which act on filtered ledger views.
@@ -68,13 +75,108 @@
}
}
+ /**
+ * Configure the matchers based on a single record.
+ *
+ * @param record
+ */
+ protected final void configureMatchers(EventList matchers, Record record) {
+ final DataAccessorFactory daf = DataAccessorFactory.getInstance();
+ final PredicateFactory pf = PredicateFactory.getInstance();
+ final Lock lock = matchers.getReadWriteLock().writeLock();
+ lock.lock();
+ try {
+ final String sendSubject = record.getSendSubject();
+ if (sendSubject != null && sendSubject.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createSendSubjectAccessor(),
+ pf.createStringStartsWithPredicate(sendSubject, false)));
+ }
+ final String replySubject = record.getReplySubject();
+ if (replySubject != null && replySubject.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createReplySubjectAccessor(),
+ pf.createStringStartsWithPredicate(replySubject, false)));
+ }
+ final String trackingId = record.getTrackingId();
+ if (trackingId != null && trackingId.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createTrackingIdAccessor(),
+ pf.createStringStartsWithPredicate(trackingId, false)));
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * Configure the matchers based on multiple records.
+ *
+ * @param record
+ */
+ protected final void configureMatchers(EventList matchers, Record[] records) {
+ final DataAccessorFactory daf = DataAccessorFactory.getInstance();
+ final PredicateFactory pf = PredicateFactory.getInstance();
+ final String[] strings = new String[records.length];
+ final Lock lock = matchers.getReadWriteLock().writeLock();
+ lock.lock();
+ try {
+ for (int i = 0, imax = records.length; i < imax; ++i) {
+ strings[i] = records[i].getSendSubject();
+ }
+ final String sendSubject = findLongestCommonSubstring(strings);
+ if (sendSubject != null && sendSubject.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createSendSubjectAccessor(),
+ pf.createStringStartsWithPredicate(sendSubject, false)));
+ }
+
+ for (int i = 0, imax = records.length; i < imax; ++i) {
+ strings[i] = records[i].getReplySubject();
+ }
+ final String replySubject = findLongestCommonSubstring(strings);
+ if (replySubject != null && replySubject.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createReplySubjectAccessor(),
+ pf.createStringStartsWithPredicate(replySubject, false)));
+ }
+
+ for (int i = 0, imax = records.length; i < imax; ++i) {
+ strings[i] = records[i].getTrackingId();
+ }
+ final String trackingId = findLongestCommonSubstring(strings);
+ if (trackingId != null && trackingId.length() > 0) {
+ matchers.add(new RvSnoopMatcherEditor(
+ daf.createTrackingIdAccessor(),
+ pf.createStringStartsWithPredicate(trackingId, false)));
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private final String findLongestCommonSubstring(String[] strings) {
+ final StrBuilder builder = new StrBuilder();
+ int pos = 0;
+ while (true) {
+ if (pos == strings[0].length()) { return builder.toString(); }
+ char c = strings[0].charAt(pos);
+ for (int i = 0, imax = strings.length; i < imax; ++i) {
+ if (pos == strings[i].length() || c != strings[i].charAt(pos)) {
+ return builder.toString();
+ }
+ }
+ builder.append(c);
+ }
+ }
+ protected abstract String getDescription();
+ protected abstract Image getImage();
+
+ protected abstract FilteredLedgerView getLedger();
+
protected EventList getMatcherEditors() {
return new BasicEventList();
}
- protected abstract FilteredLedgerView getLedger();
-
protected abstract String getTitle();
- protected abstract String getDescription();
- protected abstract Image getImage();
}
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java 2007-01-17 14:21:43 UTC (rev 386)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java 2007-01-17 14:48:22 UTC (rev 387)
@@ -16,9 +16,6 @@
import org.rvsnoop.NLSUtils;
import org.rvsnoop.event.RecordLedgerSelectionEvent;
import org.rvsnoop.event.RecordLedgerSelectionListener;
-import org.rvsnoop.matchers.DataAccessorFactory;
-import org.rvsnoop.matchers.PredicateFactory;
-import org.rvsnoop.matchers.RvSnoopMatcherEditor;
import org.rvsnoop.ui.ImageFactory;
import rvsnoop.Record;
@@ -86,30 +83,6 @@
return matchers;
}
- /**
- * Configure the matchers based on a single record.
- *
- * @param record
- */
- private void configureMatchers(EventList matchers, Record record) {
- // TODO use more matchers
- DataAccessorFactory daf = DataAccessorFactory.getInstance();
- PredicateFactory pf = PredicateFactory.getInstance();
- new RvSnoopMatcherEditor(
- daf.createSendSubjectAccessor(),
- pf.createStringStartsWithPredicate(record.getSendSubject(), false));
- }
-
- /**
- * Configure the matchers based on multiple records.
- *
- * @param record
- */
- private void configureMatchers(EventList matchers, Record[] records) {
- // TODO use all of the records instead of just the first
- configureMatchers(matchers, records[0]);
- }
-
/* (non-Javadoc)
* @see org.rvsnoop.actions.AbstractSearchAction#getTitle()
*/
Modified: trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.java 2007-01-17 14:21:43 UTC (rev 386)
+++ trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.java 2007-01-17 14:48:22 UTC (rev 387)
@@ -51,10 +51,26 @@
namesToAccessorsMap.put(DataAccessor.TRACKING_ID, DataAccessor.TrackingId.class);
}
+ public DataAccessor createFieldContentsAccessor() {
+ return new DataAccessor.FieldContents();
+ }
+
+ public DataAccessor createFieldNamesAccessor() {
+ return new DataAccessor.FieldNames();
+ }
+
+ public DataAccessor createReplySubjectAccessor() {
+ return new DataAccessor.ReplySubject();
+ }
+
public DataAccessor createSendSubjectAccessor() {
return new DataAccessor.SendSubject();
}
+ public DataAccessor createTrackingIdAccessor() {
+ return new DataAccessor.TrackingId();
+ }
+
public DataAccessor createFromDisplayName(String name) {
return createFromString(namesToAccessorsMap, name, ERROR_BAD_NAME);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2007-01-17 14:21:48
|
Revision: 386
http://svn.sourceforge.net/rvsn00p/?rev=386&view=rev
Author: ianp
Date: 2007-01-17 06:21:43 -0800 (Wed, 17 Jan 2007)
Log Message:
-----------
Added 500ms delay before dragging list items.
Fixed co-ordinate rewriting so that ghost image appears at correct location.
Modified Paths:
--------------
trunk/rvsn00p/src/org/rvsnoop/ui/ReorderableList.java
Modified: trunk/rvsn00p/src/org/rvsnoop/ui/ReorderableList.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/ui/ReorderableList.java 2007-01-17 09:19:29 UTC (rev 385)
+++ trunk/rvsn00p/src/org/rvsnoop/ui/ReorderableList.java 2007-01-17 14:21:43 UTC (rev 386)
@@ -12,6 +12,8 @@
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Transparency;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
@@ -21,6 +23,7 @@
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
+import javax.swing.Timer;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.MatteBorder;
@@ -76,31 +79,46 @@
}
}
- private final class ItemImageGrabber extends MouseAdapter {
-
- public ItemImageGrabber() {
- super();
+ private final class ImageGrabTimer implements ActionListener {
+ private final Component component;
+ private final Point point;
+ public ImageGrabTimer(Component component, Point point) {
+ this.component = component;
+ this.point = point;
}
-
- public void mousePressed(MouseEvent e) {
- // TODO use a timer to delay ~500ms before activating this behaviour
- final Point point = (Point) e.getPoint().clone();
+ public void actionPerformed(ActionEvent e) {
+ if (!mouseDown) { return; }
dragSource = locationToIndex(point);
if (dragSource < 0) { return; }
- final Component c = e.getComponent();
final int w = getFixedCellWidth(), h = getFixedCellHeight();
final BufferedImage image = getGraphicsConfiguration().
createCompatibleImage(w, h, Transparency.TRANSLUCENT);
Graphics g = image.getGraphics();
- c.paint(g);
+ component.paint(g);
g.dispose();
- SwingUtilities.convertPoint(c, point, glasspane);
+ SwingUtilities.convertPointToScreen(point, component);
+ SwingUtilities.convertPointFromScreen(point, glasspane);
glasspane.setLocation(point);
glasspane.setImage(image);
glasspane.setVisible(true);
}
+ }
+ private final class ItemImageGrabber extends MouseAdapter {
+
+ public ItemImageGrabber() {
+ super();
+ }
+
+ public void mousePressed(MouseEvent e) {
+ mouseDown = true;
+ final Point p = (Point) e.getPoint().clone();
+ final Component c = e.getComponent();
+ new Timer(DRAG_DELAY_MILLIS, new ImageGrabTimer(c, p)).start();
+ }
+
public void mouseReleased(MouseEvent e) {
+ mouseDown = false;
if (dragSource < 0) { return; }
final Point point = (Point) e.getPoint().clone();
dropTarget = locationToIndex(point);
@@ -128,7 +146,8 @@
if (point.y > lastBottom) { dropTarget = list.size(); }
final Component c = e.getComponent();
- SwingUtilities.convertPoint(c, point, glasspane);
+ SwingUtilities.convertPointToScreen(point, c);
+ SwingUtilities.convertPointFromScreen(point, glasspane);
glasspane.setLocation(point);
glasspane.repaint();
@@ -144,6 +163,8 @@
private static final DecoratingBorder dropBeforeThisItemBorder =
new DecoratingBorder(new MatteBorder(2, 0, 0, 0, Color.BLACK));
+ private static final int DRAG_DELAY_MILLIS = 500;
+
/** The source item which will be moved. */
private int dragSource = -1;
@@ -162,6 +183,8 @@
private final EventList list;
+ private boolean mouseDown;
+
/**
* Create a new <code>ReorederableList</code>.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ia...@us...> - 2007-01-17 09:19:35
|
Revision: 385
http://svn.sourceforge.net/rvsn00p/?rev=385&view=rev
Author: ianp
Date: 2007-01-17 01:19:29 -0800 (Wed, 17 Jan 2007)
Log Message:
-----------
Added new matcher/matcher editor framework.
Rewrote filter function to use new framework.
Added swing-layout to the build for use in new UI components.
Modified Paths:
--------------
trunk/rvsn00p/build.properties
trunk/rvsn00p/build.xml
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/commons-logging.properties
trunk/rvsn00p/src/org/rvsnoop/Application.java
trunk/rvsn00p/src/org/rvsnoop/FastJdk14Logger.java
trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java
trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.java
trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/org/rvsnoop/ui/FooterPanel.java
trunk/rvsn00p/src/org/rvsnoop/ui/HeaderPanel.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordLedgerTable.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesMenuManager.java
trunk/rvsn00p/src/org/rvsnoop/ui/VisibleColumnsMenuManager.java
trunk/rvsn00p/src/resources/banners/editRecordTypes.png
trunk/rvsn00p/src/resources/icons/paste.png
trunk/rvsn00p/src/rvsnoop/MessageLedger.java
trunk/rvsn00p/src/rvsnoop/RecordSelection.java
trunk/rvsn00p/src/rvsnoop/SubjectElement.java
trunk/rvsn00p/src/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java
trunk/rvsn00p/src/rvsnoop/ui/SubjectExplorerEditor.java
trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTest.java
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTestTarget.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java
trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java
trunk/rvsn00p/src/org/rvsnoop/TibrvUtils.java
trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java
trunk/rvsn00p/src/org/rvsnoop/actions/Paste.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Search.java
trunk/rvsn00p/src/org/rvsnoop/matchers/
trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessor.java
trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessor.properties
trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.java
trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessorFactory.properties
trunk/rvsn00p/src/org/rvsnoop/matchers/Predicate.java
trunk/rvsn00p/src/org/rvsnoop/matchers/Predicate.properties
trunk/rvsn00p/src/org/rvsnoop/matchers/PredicateFactory.java
trunk/rvsn00p/src/org/rvsnoop/matchers/PredicateFactory.properties
trunk/rvsn00p/src/org/rvsnoop/matchers/RvSnoopMatcher.java
trunk/rvsn00p/src/org/rvsnoop/matchers/RvSnoopMatcherEditor.java
trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionListCellRenderer.java
trunk/rvsn00p/src/org/rvsnoop/ui/GhostGlassPane.java
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorDialog.properties
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListCellRenderer.java
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.java
trunk/rvsn00p/src/org/rvsnoop/ui/MatcherEditorListDialog.properties
trunk/rvsn00p/src/org/rvsnoop/ui/ReorderableList.java
trunk/rvsn00p/src/resources/banners/defaultMatcherEditor.png
trunk/rvsn00p/src/resources/banners/filter.png
trunk/rvsn00p/src/resources/banners/filterBySelection.png
Removed Paths:
-------------
trunk/rvsn00p/src/org/rvsnoop/RecordSubjectMatcher.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageBorder.java
trunk/rvsn00p/src/rvsnoop/CausedIOException.java
trunk/rvsn00p/src/rvsnoop/actions/Paste.java
trunk/rvsn00p/src/rvsnoop/actions/Search.java
Modified: trunk/rvsn00p/build.properties
===================================================================
--- trunk/rvsn00p/build.properties 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/build.properties 2007-01-17 09:19:29 UTC (rev 385)
@@ -20,6 +20,7 @@
lib.lang=/usr/local/share/java/commons-lang-2.2/commons-lang-2.2.jar
lib.logging=/usr/local/share/java/commons-logging-1.1/commons-logging-1.1.jar
lib.looks=/usr/local/share/java/looks-2.1.0/looks-2.1.0.jar
+lib.swinglayout=/usr/local/share/java/swing-layout-1.0.1/swing-layout-1.0.1.jar
lib.xmlenc=/usr/local/share/java/xmlenc-0.52/xmlenc.jar
lib.xom=/usr/local/share/java/xom-1.1/xom-1.1.jar
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/build.xml 2007-01-17 09:19:29 UTC (rev 385)
@@ -62,6 +62,7 @@
<pathelement location="${lib.lang}"/>
<pathelement location="${lib.logging}"/>
<pathelement location="${lib.looks}"/>
+ <pathelement location="${lib.swinglayout}"/>
<pathelement location="${lib.xmlenc}"/>
<pathelement location="${lib.xom}"/>
</path>
@@ -253,6 +254,7 @@
<fileset file="${lib.lang}"/>
<fileset file="${lib.logging}"/>
<fileset file="${lib.looks}"/>
+ <fileset file="${lib.swinglayout}"/>
<fileset file="${lib.xmlenc}"/>
<fileset file="${lib.xom}"/>
<fileset file="${dir.stage}/src/*.properties"/>
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Modified: trunk/rvsn00p/src/commons-logging.properties
===================================================================
--- trunk/rvsn00p/src/commons-logging.properties 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/commons-logging.properties 2007-01-17 09:19:29 UTC (rev 385)
@@ -18,4 +18,4 @@
#org.rvsnoop.FastFileHandler.filter=
org.rvsnoop.FastFileHandler.formatter=org.rvsnoop.FastFormatter
org.rvsnoop.FastFileHandler.encoding=UTF-8
-org.rvsnoop.FastFileHandler.compressOldFiles=false
\ No newline at end of file
+org.rvsnoop.FastFileHandler.compressOldFiles=false
Modified: trunk/rvsn00p/src/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -34,9 +34,9 @@
public final class Application {
static { NLSUtils.internationalize(Application.class); }
-
+
private static final Log log = LogFactory.getLog(Application.class);
-
+
static String ERROR_SHUTDOWN;
private Actions actionFactory;
@@ -165,7 +165,7 @@
/**
* Get all of the known record types.
- *
+ *
* @return The record types.
*/
public synchronized RecordTypes getRecordTypes() {
Copied: trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java (from rev 383, trunk/rvsn00p/src/rvsnoop/CausedIOException.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,44 @@
+/*
+ * Class: CausedIOException
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.io.IOException;
+
+/**
+ * An IOException with an underlying cause.
+ * <p>
+ * The standard {@linkplain IOException} class does not provide a constructor to
+ * allow the cause to be set, this class overrides the {@linkplain #getCause()}
+ * method to allow a cause to be accessed.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class CausedIOException extends IOException {
+
+ static final long serialVersionUID = -4467829647590753023L;
+
+ private final Throwable cause;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CausedIOException(String message, Throwable cause) {
+ super(message);
+ this.cause = cause;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#getCause()
+ */
+ public Throwable getCause() {
+ return cause;
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/CausedIOException.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,43 @@
+/*
+ * Class: CausedIllegalArgumentException
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+
+/**
+ * An IllegalArgumentException with an underlying cause.
+ * <p>
+ * The standard {@link IllegalArgumentException} class does not provide a
+ * constructor to allow the cause to be set, this class overrides the
+ * {@link #getCause()} method to allow a cause to be accessed.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class CausedIllegalArgumentException extends IllegalArgumentException {
+
+ private static final long serialVersionUID = -2232264521304477496L;
+
+ private final Throwable cause;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CausedIllegalArgumentException(String message, Throwable cause) {
+ super(message);
+ this.cause = cause;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#getCause()
+ */
+ public Throwable getCause() {
+ return cause;
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/CausedIllegalArgumentException.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: trunk/rvsn00p/src/org/rvsnoop/FastJdk14Logger.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FastJdk14Logger.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/FastJdk14Logger.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -12,7 +12,6 @@
import java.util.logging.LogManager;
import java.util.logging.Logger;
-import org.apache.commons.lang.ClassUtils;
import org.apache.commons.logging.Log;
/**
@@ -53,7 +52,7 @@
* @param name Name of the logger to be constructed
*/
public FastJdk14Logger(String name) {
- this.name = name != null ? ClassUtils.getShortClassName(name) : "";
+ this.name = name != null ? name : "";
}
/** Create a new anonymous logger. */
Modified: trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/FilteredLedgerView.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -12,6 +12,7 @@
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
import ca.odell.glazedlists.matchers.CompositeMatcherEditor;
+import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.matchers.MatcherEditor;
import ca.odell.glazedlists.util.concurrent.Lock;
@@ -25,6 +26,19 @@
*/
public class FilteredLedgerView extends RecordLedger {
+ private final class MatcherHider implements Matcher {
+ public boolean matches(Object item) {
+ if (subjectFilter != null && subjectFilter.equals(item)) {
+ return false;
+ }
+ if (typeFilter != null && typeFilter.equals(item)) {
+ return false;
+ }
+ return true;
+ }
+
+ }
+
private final CompositeMatcherEditor filters = new CompositeMatcherEditor();
private MatcherEditor subjectFilter;
@@ -62,6 +76,19 @@
}
/**
+ * Return a list of all of the user supplied filters currently in place.
+ * <p>
+ * Note that the list returned by this method is live, that is, changes to
+ * it will be applied to the view immediately. Also, the subject and type
+ * matchers will not be visible in the list.
+ *
+ * @return The user supplied filters.
+ */
+ public EventList getMatchers() {
+ return new FilterList(filters.getMatcherEditors(), new MatcherHider());
+ }
+
+ /**
* Is this view currently filtering records based on the subject hierarchy.
*
* @return <code>true</code> if subject filtering is turned on,
Modified: trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -55,7 +55,7 @@
return null;
}
}
-
+
/**
* Class which sub-classes java.util.Properties and uses the #put method to
* set field values rather than storing the values in the table.
@@ -204,12 +204,18 @@
* @return The resource, or <code>null</code> if it could not be found.
*/
public static InputStream findNLSResource(String resourcePath, Class clazz) {
+ if (log.isDebugEnabled()) {
+ log.debug("Loading NLS resource from path: " + resourcePath);
+ }
final int lastIndex = resourcePath.lastIndexOf(".");
final String basePath = resourcePath.substring(0, lastIndex);
final String suffix = resourcePath.substring(lastIndex);
final String[] variants = buildVariants(basePath, suffix);
for (int i = 0, imax = variants.length; i < imax; ++i) {
- final InputStream stream = clazz.getResourceAsStream(variants[i]);
+ if (log.isTraceEnabled()) {
+ log.trace("Trying variant: " + variants[i]);
+ }
+ InputStream stream = clazz.getResourceAsStream(variants[i]);
if (stream != null) { return stream; }
}
return null;
Modified: trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -177,9 +177,9 @@
* @param column The column to add.
*/
public void add(ColumnFormat column) {
- if (!columns.contains(column) && columns.add(column) && model != null) {
- model.setTableFormat(this);
- }
+ if (columns.contains(column)) { return; }
+ columns.add(column);
+ if (model != null) { model.setTableFormat(this); }
}
/**
@@ -243,9 +243,8 @@
* @param column The column to remove.
*/
public void remove(ColumnFormat column) {
- if (columns.remove(column) && model != null) {
- model.setTableFormat(this);
- }
+ columns.remove(column);
+ if (model != null) { model.setTableFormat(this); }
}
/**
Deleted: trunk/rvsn00p/src/org/rvsnoop/RecordSubjectMatcher.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordSubjectMatcher.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordSubjectMatcher.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -1,41 +0,0 @@
-/*
- * Class: RecordSubjectMatcher
- * Version: $Revision$
- * Date: $Date$
- * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
- * License: Apache Software License (Version 2.0)
- */
-package org.rvsnoop;
-
-import rvsnoop.Record;
-import rvsnoop.SubjectElement;
-import ca.odell.glazedlists.matchers.Matcher;
-
-/**
- * A matcher for records with a specific subject.
- *
- * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
- * @version $Revision$, $Date$
- * @since 1.7
- */
-public final class RecordSubjectMatcher implements Matcher {
-
- private final SubjectElement subject;
-
- private final boolean descendants;
-
- public RecordSubjectMatcher(SubjectElement subject, boolean descendants) {
- this.descendants = descendants;
- this.subject = subject;
- }
-
- /* (non-Javadoc)
- * @see ca.odell.glazedlists.matchers.Matcher#matches(java.lang.Object)
- */
- public boolean matches(Object item) {
- if (!(item instanceof Record)) { return false; }
- final SubjectElement s = ((Record) item).getSubject();
- return descendants ? subject.isNodeDescendant(s) : subject.equals(s);
- }
-
-}
Added: trunk/rvsn00p/src/org/rvsnoop/TibrvUtils.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/TibrvUtils.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/TibrvUtils.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,96 @@
+/*
+ * Class: TibrvUtils
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import com.tibco.tibrv.TibrvException;
+import com.tibco.tibrv.TibrvMsg;
+import com.tibco.tibrv.TibrvMsgField;
+
+/**
+ * A collection of static utility methods for working with Rendezvous.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class TibrvUtils {
+
+ /**
+ * Returns an iterator that traverses all of the fields in a message in a depth first order.
+ * <p>
+ * Elements in the iterator mat safely be cast to {@link TibrvMsgField}.
+ *
+ * @param message The message to traverse.
+ * @return The iterator.
+ */
+ public static Iterator depthFirstFieldIterator(TibrvMsg message) {
+ return new DepthFirstFieldIterator(message);
+ }
+
+ private TibrvUtils() { throw new UnsupportedOperationException(); }
+
+}
+
+/** Used to hold a stack frame in the iterator. */
+final class StackElement {
+ final TibrvMsg message;
+ final int position;
+ StackElement(TibrvMsg message, int position) {
+ this.message = message;
+ this.position = position;
+ }
+}
+
+/** Traverse the fields in a message in depth first order. */
+final class DepthFirstFieldIterator implements Iterator {
+ private final List stack = new ArrayList(1);
+ private boolean hasNext;
+ private TibrvMsg message;
+ private int numFields;
+ private int position;
+ DepthFirstFieldIterator(TibrvMsg message) {
+ this.message = message;
+ numFields = message.getNumFields();
+ hasNext = numFields > 0;
+ }
+ public boolean hasNext() {
+ return hasNext;
+ }
+ public Object next() {
+ if (!hasNext) { throw new NoSuchElementException(); }
+ try {
+ final TibrvMsgField next = message.getField(position++);
+ if (next.type == TibrvMsg.MSG && ((TibrvMsg) next.data).getNumFields() > 0) {
+ stack.add(new StackElement(message, position));
+ message = (TibrvMsg) next.data;
+ position = 0;
+ numFields = message.getNumFields();
+ }
+ if (position == numFields) {
+ if (stack.size() > 0) {
+ StackElement elt = (StackElement) stack.remove(stack.size() - 1);
+ message = elt.message;
+ position = elt.position;
+ numFields = message.getNumFields();
+ } else {
+ hasNext = false;
+ }
+ }
+ return next;
+ } catch (TibrvException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
Property changes on: trunk/rvsn00p/src/org/rvsnoop/TibrvUtils.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,80 @@
+/*
+ * Class: AbstractSearchAction
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.JFrame;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.ui.MatcherEditorListDialog;
+
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.matchers.MatcherEditor;
+
+/**
+ * Base class for actions which act on filtered ledger views.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public abstract class AbstractSearchAction extends RvSnoopAction {
+
+ /**
+ * @param name
+ * @param application
+ */
+ protected AbstractSearchAction(String name, Application application) {
+ super(name, application);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.RvSnoopAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public final void actionPerformed(ActionEvent e) {
+ final EventList oldMatchers = getMatcherEditors();
+ final JFrame frame = application.getFrame().getFrame();
+ final MatcherEditorListDialog dialog = new MatcherEditorListDialog(
+ frame, getTitle(), getDescription(), getImage(), oldMatchers);
+
+ dialog.setVisible(true);
+ final EventList newMatchers = dialog.getCopyOfEditors();
+ if (newMatchers == null) { return; } // User cancelled dialog.
+
+ // TODO add equals methods to the matcher editors so that this works as
+ // expected. The equals methods will need to use non-final fields.
+ final List added = new ArrayList(newMatchers);
+ added.removeAll(oldMatchers);
+ final List removed = new ArrayList(oldMatchers);
+ removed.removeAll(newMatchers);
+
+ final FilteredLedgerView ledger = getLedger();
+ for (Iterator i = added.iterator(); i.hasNext(); ) {
+ ledger.addFilter((MatcherEditor) i.next());
+ }
+ for (Iterator i = removed.iterator(); i.hasNext(); ) {
+ ledger.removeFilter((MatcherEditor) i.next());
+ }
+ }
+
+ protected EventList getMatcherEditors() {
+ return new BasicEventList();
+ }
+
+ protected abstract FilteredLedgerView getLedger();
+
+ protected abstract String getTitle();
+ protected abstract String getDescription();
+ protected abstract Image getImage();
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/AbstractSearchAction.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -7,21 +7,16 @@
*/
package org.rvsnoop.actions;
-import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
-import ca.odell.glazedlists.matchers.Matcher;
+import java.awt.Image;
-import java.awt.event.ActionEvent;
-
import javax.swing.Action;
-import org.apache.commons.lang.text.StrBuilder;
import org.rvsnoop.Application;
+import org.rvsnoop.FilteredLedgerView;
import org.rvsnoop.NLSUtils;
-import org.rvsnoop.event.RecordLedgerSelectionEvent;
-import org.rvsnoop.event.RecordLedgerSelectionListener;
+import org.rvsnoop.ui.ImageFactory;
-import rvsnoop.Record;
-import rvsnoop.ui.FilterDialog;
+import ca.odell.glazedlists.EventList;
/**
* Filter the messages visible in the ledger.
@@ -30,122 +25,57 @@
* @version $Revision$, $Date$
* @since 1.5
*/
-public final class Filter extends RvSnoopAction implements RecordLedgerSelectionListener {
+public final class Filter extends AbstractSearchAction {
- private static class FilterMatcher implements Matcher {
- private String sendSubject;
- private String trackingId;
+ static { NLSUtils.internationalize(Filter.class); }
- private boolean sendSubjectEnabled;
- private boolean trackingIdEnabled;
+ private static final long serialVersionUID = 7395491526593830048L;
- FilterMatcher(String sendSubject, String trackingId, boolean sendSubjectEnabled, boolean trackingIdEnabled) {
- super();
- this.sendSubject = sendSubject;
- this.trackingId = trackingId;
- this.sendSubjectEnabled = sendSubjectEnabled;
- this.trackingIdEnabled = trackingIdEnabled;
- }
+ public static final String COMMAND = "filter";
+ static String ACCELERATOR, DESCRIPTION, MNEMONIC, NAME, TITLE, TOOLTIP;
- public boolean matches(Object item) {
- final Record record = (Record) item;
- if (sendSubjectEnabled && record.getSendSubject().indexOf(sendSubject) < 0) return false;
- if (trackingIdEnabled && record.getTrackingId().indexOf(trackingId) < 0) return false;
- return true;
- }
+ public Filter(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
}
- private static class FilterMatcherEditor extends AbstractMatcherEditor {
- // TODO: Make this more efficient by re-using the matcher and firing
- // constrained or relaxed instead of just changed each time.
- FilterMatcherEditor() {
- super();
- }
- void setMatcher(Matcher matcher) {
- currentMatcher = matcher;
- fireChanged(matcher);
- }
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getDescription()
+ */
+ protected String getDescription() {
+ return DESCRIPTION;
}
- static { NLSUtils.internationalize(Filter.class); }
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getImage()
+ */
+ protected Image getImage() {
+ return ImageFactory.getInstance().getBannerImage(COMMAND);
+ }
- private static final long serialVersionUID = 7395491526593830048L;
-
- public static final String FILTER_COMMAND = "filter";
- public static final String FILTER_BY_SELECTION_COMMAND = "filterBySelection";
-
- static String FILTER_ACCELERATOR, FILTER_MNEMONIC,
- FILTER_NAME, FILTER_TOOLTIP;
- static String FILTER_BY_SELECTION_ACCELERATOR, FILTER_BY_SELECTION_MNEMONIC,
- FILTER_BY_SELECTION_NAME, FILTER_BY_SELECTION_TOOLTIP;
-
- private final boolean bySelection;
-
- private String sendSubject;
- private String trackingId;
-
- private boolean sendSubjectEnabled;
- private boolean trackingIdEnabled;
-
- private FilterMatcherEditor matcherEditor;
-
- private transient Record[] currentSelection;
-
- public Filter(Application application, boolean bySelection) {
- super(bySelection ? FILTER_BY_SELECTION_NAME : FILTER_NAME, application);
- this.bySelection = bySelection;
- if (bySelection) {
- putValue(Action.ACTION_COMMAND_KEY, FILTER_BY_SELECTION_COMMAND);
- putSmallIconValue(FILTER_BY_SELECTION_COMMAND);
- putValue(Action.SHORT_DESCRIPTION, FILTER_BY_SELECTION_TOOLTIP);
- putMnemonicValue(FILTER_BY_SELECTION_MNEMONIC);
- putAcceleratorValue(FILTER_BY_SELECTION_ACCELERATOR);
- } else {
- putValue(Action.ACTION_COMMAND_KEY, FILTER_COMMAND);
- putSmallIconValue(FILTER_COMMAND);
- putValue(Action.SHORT_DESCRIPTION, FILTER_TOOLTIP);
- putMnemonicValue(FILTER_MNEMONIC);
- putAcceleratorValue(FILTER_ACCELERATOR);
- }
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getLedger()
+ */
+ protected FilteredLedgerView getLedger() {
+ return application.getFilteredLedger();
}
/* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getMatcherEditors()
*/
- public void actionPerformed(ActionEvent event) {
- if (bySelection) {
- // TODO use all of the records when filtering by selection.
- final Record record = currentSelection[0];
- sendSubject = record.getSendSubject();
- trackingId = record.getTrackingId();
- }
- final FilterDialog dialog = new FilterDialog(sendSubject, trackingId, sendSubjectEnabled, trackingIdEnabled);
- dialog.setVisible(true);
- if (dialog.isCancelled()) { return; }
- sendSubject = dialog.getSendSubject();
- trackingId = dialog.getTrackingId();
- sendSubjectEnabled = dialog.isSendSubjectSelected();
- trackingIdEnabled = dialog.isTrackingIdSelected();
- synchronized (this) {
- if (matcherEditor == null) {
- matcherEditor = new FilterMatcherEditor();
- application.getFilteredLedger().addFilter(matcherEditor);
- }
- }
- matcherEditor.setMatcher(new FilterMatcher(sendSubject, trackingId, sendSubjectEnabled, trackingIdEnabled));
- final StrBuilder builder = new StrBuilder();
- if (sendSubjectEnabled) builder.append("Send Subject: ").append(sendSubject);
- if (sendSubjectEnabled && trackingIdEnabled) builder.append("\n");
- if (trackingIdEnabled) builder.append("Tracking ID: ").append(trackingId);
- application.getFrame().setStatusBarFilter(builder.toString());
+ protected EventList getMatcherEditors() {
+ return application.getFilteredLedger().getMatchers();
}
/* (non-Javadoc)
- * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getTitle()
*/
- public void valueChanged(RecordLedgerSelectionEvent event) {
- currentSelection = event.getSelectedRecords();
- setEnabled(!bySelection || currentSelection.length > 0);
+ protected String getTitle() {
+ return TITLE;
}
}
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties 2007-01-17 09:19:29 UTC (rev 385)
@@ -1,10 +1,7 @@
# 0x46 == KeyEvent.VK_F
-FILTER_ACCELERATOR=ALT+SHIFT+0x46
-FILTER_MNEMONIC=0x46
-FILTER_NAME=Filter
-FILTER_TOOLTIP=Filter the contents of the ledger
-# 0x53 == KeyEvent.VK_S
-FILTER_BY_SELECTION_ACCELERATOR=ALT+SHIFT+0x53
-FILTER_BY_SELECTION_MNEMONIC=0x53
-FILTER_BY_SELECTION_NAME=Filter By Selection
-FILTER_BY_SELECTION_TOOLTIP=Filter the contents of the ledger
\ No newline at end of file
+ACCELERATOR=ALT+SHIFT+0x46
+DESCRIPTION=Select the criteria you wish to include in the visible ledger.\nYou can use Java regular expressions for more fine grained control.
+MNEMONIC=0x46
+NAME=Filter
+TITLE=Filter Record Ledger
+TOOLTIP=Filter the contents of the ledger
Added: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,128 @@
+/*
+ * Class: FilterBySelection
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Image;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.FilteredLedgerView;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+import org.rvsnoop.matchers.DataAccessorFactory;
+import org.rvsnoop.matchers.PredicateFactory;
+import org.rvsnoop.matchers.RvSnoopMatcherEditor;
+import org.rvsnoop.ui.ImageFactory;
+
+import rvsnoop.Record;
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
+
+/**
+ * Filter the messages visible in the ledger.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.7
+ */
+public final class FilterBySelection extends AbstractSearchAction implements RecordLedgerSelectionListener {
+
+ static { NLSUtils.internationalize(FilterBySelection.class); }
+
+ private static final long serialVersionUID = -5949027962663244889L;
+
+ public static final String COMMAND = "filterBySelection";
+ static String ACCELERATOR, DESCRIPTION, MNEMONIC, NAME, TITLE, TOOLTIP;
+
+ private transient Record[] currentSelection;
+
+ public FilterBySelection(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getDescription()
+ */
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getImage()
+ */
+ protected Image getImage() {
+ return ImageFactory.getInstance().getBannerImage(COMMAND);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getLedger()
+ */
+ protected FilteredLedgerView getLedger() {
+ return application.getFilteredLedger();
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getMatcherEditors()
+ */
+ protected EventList getMatcherEditors() {
+ final EventList matchers = new BasicEventList();
+ if (currentSelection.length == 1) {
+ configureMatchers(matchers, currentSelection[0]);
+ } else {
+ configureMatchers(matchers, currentSelection);
+ }
+ return matchers;
+ }
+
+ /**
+ * Configure the matchers based on a single record.
+ *
+ * @param record
+ */
+ private void configureMatchers(EventList matchers, Record record) {
+ // TODO use more matchers
+ DataAccessorFactory daf = DataAccessorFactory.getInstance();
+ PredicateFactory pf = PredicateFactory.getInstance();
+ new RvSnoopMatcherEditor(
+ daf.createSendSubjectAccessor(),
+ pf.createStringStartsWithPredicate(record.getSendSubject(), false));
+ }
+
+ /**
+ * Configure the matchers based on multiple records.
+ *
+ * @param record
+ */
+ private void configureMatchers(EventList matchers, Record[] records) {
+ // TODO use all of the records instead of just the first
+ configureMatchers(matchers, records[0]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.AbstractSearchAction#getTitle()
+ */
+ protected String getTitle() {
+ return TITLE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ currentSelection = event.getSelectedRecords();
+ setEnabled(currentSelection.length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/FilterBySelection.properties 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,8 @@
+# 0x53 == KeyEvent.VK_S
+ACCELERATOR=ALT+SHIFT+0x53
+DESCRIPTION=Select the criteria you wish to include in the visible ledger.\
+You can use Java regular expressions for more fine grained control.
+MNEMONIC=0x53
+NAME=Filter By Selection
+TITLE=Filter Record Ledger
+TOOLTIP=Filter the contents of the ledger
\ No newline at end of file
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java (from rev 384, trunk/rvsn00p/src/rvsnoop/actions/Paste.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,89 @@
+/*
+ * Class: Paste
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import javax.swing.Action;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+
+import rvsnoop.Record;
+import rvsnoop.RecordSelection;
+import rvsnoop.RvConnection.AddRecordTask;
+
+import com.tibco.tibrv.TibrvException;
+
+/**
+ * Paste the contents of the system clipboard to the message ledger.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class Paste extends RvSnoopAction {
+
+ static { NLSUtils.internationalize(Paste.class); }
+
+ private static final long serialVersionUID = -8506730607421335573L;
+
+ private static final Log log = LogFactory.getLog(Paste.class);
+
+ public static final String COMMAND = "paste";
+ static String ACCELERATOR, MNEMONIC, NAME, TOOLTIP;
+ static String ERROR_CLIPBOARD_LOST, ERROR_IO, ERROR_RV, INFO_BAD_CLIP_DATA;
+
+ public Paste(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event) {
+ final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ final Transferable clipboardData = clipboard.getContents(this);
+ if (!clipboardData.isDataFlavorSupported(RecordSelection.BYTES_FLAVOUR)
+ && !clipboardData.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+ if (log.isWarnEnabled()) { log.warn(INFO_BAD_CLIP_DATA); }
+ return;
+ }
+ try {
+ final Record[] records = RecordSelection.read(clipboardData);
+ for (int i = 0, imax = records.length; i < imax; ++i) {
+ SwingUtilities.invokeLater(new AddRecordTask(records[i]));
+ }
+ } catch (TibrvException e) {
+ if (log.isErrorEnabled()) {
+ log.error(MessageFormat.format(ERROR_RV,
+ new Object[] { new Integer(e.error) }), e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) { log.error(ERROR_IO, e); }
+ } catch (UnsupportedFlavorException e) {
+ if (log.isErrorEnabled()) { log.error(ERROR_CLIPBOARD_LOST, e); }
+ }
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Paste.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Paste.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Paste.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Paste.properties 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,9 @@
+# 0x56 == KeyEvent.VK_V
+ACCELERATOR=0x56
+ERROR_CLIPBOARD_LOST=The Rendezvous message data was removed from the clipboard before it could be read.
+ERROR_IO=There was an I/O error whilst reading data from the clipboard.
+ERROR_RV=There was a Rendezvous error (error code {0}) whilst deserializing the messages.
+INFO_BAD_CLIP_DATA=The clipboard does not contain Rendezvous message data.
+MNEMONIC=0x56
+NAME=Paste
+TOOLTIP=Paste the contents of the clipboard to the message ledger
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -34,7 +34,7 @@
private static final long serialVersionUID = 4723433926433208758L;
public static final String COMMAND = "quit";
- static String ACCELERATOR, CONFIRM_QUESTION, CONFIRM_TITLE, MNEMONIC, NAME,
+ static String ACCELERATOR, CONFIRM_QUESTION, CONFIRM_TITLE, MNEMONIC, NAME,
TOOLTIP;
public Quit(Application application) {
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -40,7 +40,7 @@
private static final long serialVersionUID = -2102299383827763915L;
static { NLSUtils.internationalize(Republish.class); }
-
+
private static final Log log = LogFactory.getLog(Republish.class);
public static final String COMMAND = "republish";
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.java 2007-01-08 08:07:22 UTC (rev 384)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -35,9 +35,9 @@
* @version $Revision$, $Date$
*/
public abstract class RvSnoopAction extends AbstractAction {
-
+
static { NLSUtils.internationalize(RvSnoopAction.class); }
-
+
private static final Log log = LogFactory.getLog(RvSnoopAction.class);
static String DEBUG_ACCELERATOR;
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Search.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/Search.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Search.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Search.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,209 @@
+/*
+ * Class: Search
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import rvsnoop.MessageLedger;
+import rvsnoop.Record;
+import rvsnoop.ui.Icons;
+import rvsnoop.ui.SearchDialog;
+import rvsnoop.ui.UIManager;
+import ca.odell.glazedlists.matchers.Matcher;
+
+import com.tibco.tibrv.TibrvException;
+import com.tibco.tibrv.TibrvMsg;
+import com.tibco.tibrv.TibrvMsgField;
+import com.tibco.tibrv.TibrvXml;
+
+/**
+ * Search for text in the message bodies.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class Search extends AbstractAction {
+
+ private class Searcher implements Matcher {
+ private final boolean fieldData;
+ private final boolean fieldNames;
+ private final boolean replySubject;
+ private final boolean sendSubject;
+ private final boolean trackingId;
+ private final String searchText;
+ Searcher(boolean fieldData, boolean fieldNames, boolean replySubject,
+ boolean sendSubject, boolean trackingId, String searchText) {
+ this.fieldData = fieldData;
+ this.fieldNames = fieldNames;
+ this.replySubject = replySubject;
+ this.sendSubject = sendSubject;
+ this.trackingId = trackingId;
+ this.searchText = searchText;
+ }
+
+ private boolean isTextInFieldData(String text, TibrvMsgField field) throws TibrvException {
+ if (fieldNames && field.name.indexOf(text) >= 0) return true;
+ switch (field.type) {
+ case TibrvMsg.MSG:
+ return isTextInMessageData(text, (TibrvMsg) field.data);
+ case TibrvMsg.STRING:
+ return ((String) field.data).indexOf(text) >= 0;
+ case TibrvMsg.XML:
+ // XXX: Should we do something here to sniff the correct encoding from the bytes?
+ return isTextInXmlData(text.getBytes(), ((TibrvXml) field.data).getBytes());
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Search all of the text in a message for a given string.
+ * <p>
+ * This will search all fields which contain strings, and recursively search
+ * all nested messages.
+ *
+ * @param text The text to search for.
+ * @param message The message to search.
+ * @return <code>true</code> if the text was matched, <code>false</code>
+ * otherwise.
+ * @throws TibrvException
+ */
+ private boolean isTextInMessageData(String text, TibrvMsg message) throws TibrvException {
+ for (int i = 0, imax = message.getNumFields(); i < imax; ++i)
+ if (isTextInFieldData(text, message.getFieldByIndex(i)))
+ return true;
+ return false;
+ }
+
+ private boolean isTextInXmlData(byte[] text, byte[] xml) {
+ final byte firstByte = text[0];
+ SCAN_XML:
+ for (int i = 0, imax = xml.length; i < imax; ++i) {
+ if (xml[i] != firstByte) continue;
+ if (text.length == 1) return true; // Guard for single byte text.
+ if (++i == xml.length) return false; // Guard for end of XML.
+ // OK, now look for the rest of the text...
+ for (int j = 1, jmax = text.length; j < jmax; ) {
+ if (xml[i] != text[j]) continue SCAN_XML;
+ if (++i == xml.length) return false; // Guard for end of XML.
+ if (++j == text.length) return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see ca.odell.glazedlists.matchers.Matcher#matches(java.lang.Object)
+ */
+ public boolean matches(Object item) {
+ if (!(item instanceof Record)) { return false; }
+ final Record record = (Record) item;
+ if ((fieldData || fieldNames) && matchMessage(record)) return true;
+ if (sendSubject && matchSendSubject(record)) return true;
+ if (replySubject && matchReplySubject(record)) return true;
+ return trackingId && matchTrackingId(record);
+ }
+
+ private boolean matchMessage(Record record) {
+ try {
+ return isTextInMessageData(searchText, record.getMessage());
+ } catch (TibrvException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error reading message field.", e);
+ }
+ return false;
+ }
+ }
+
+ private boolean matchReplySubject(Record record) {
+ final String replySubject = record.getReplySubject();
+ return replySubject != null && replySubject.indexOf(searchText) >= 0;
+ }
+
+ private boolean matchSendSubject(Record record) {
+ final String sendSubject = record.getSendSubject();
+ return sendSubject != null && sendSubject.indexOf(searchText) >= 0;
+ }
+
+ private boolean matchTrackingId(Record record) {
+ final String trackingId = record.getTrackingId();
+ return trackingId != null && trackingId.indexOf(searchText) >= 0;
+ }
+
+ }
+
+ private static final Log log = LogFactory.getLog(Search.class);
+
+ public static final String SEARCH = "search";
+
+ public static final String SEARCH_AGAIN = "searchAgain";
+
+ private static final long serialVersionUID = -5833838900255559506L;
+
+ private String searchText = "Enter your search text here";
+
+ private boolean trackingId;
+ private boolean fieldData = true;
+ private boolean fieldNames;
+ private boolean sendSubject;
+ private boolean replySubject;
+
+ public Search(String id, String name, String tooltip, int accel) {
+ super(name);
+ putValue(Action.ACTION_COMMAND_KEY, id);
+ if (SEARCH.equals(id))
+ putValue(Action.SMALL_ICON, Icons.SEARCH);
+ else if (SEARCH_AGAIN.equals(id))
+ putValue(Action.SMALL_ICON, Icons.SEARCH_AGAIN);
+ if (accel != 0) {
+ final int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(accel, mask));
+ }
+ putValue(Action.SHORT_DESCRIPTION, tooltip);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event) {
+ if (SEARCH.equals(event.getActionCommand()) && !showDialog()) return;
+ if (searchText == null || (searchText = searchText.trim()).length() == 0) return;
+ final Searcher searcher = new Searcher(fieldData, fieldNames,
+ replySubject, sendSubject, trackingId, searchText);
+ final int[] indices = MessageLedger.FILTERED_VIEW.findAllIndices(searcher);
+ if (indices.length == 0) {
+ JOptionPane.showMessageDialog(UIManager.INSTANCE.getFrame(), "Nothing matched.");
+ } else {
+ // TODO: Display SearchResultsWindow
+ }
+ }
+
+ private boolean showDialog() {
+ final SearchDialog dialog = new SearchDialog(searchText, fieldData, fieldNames, sendSubject, replySubject, trackingId);
+ dialog.setVisible(true);
+ if (dialog.isCancelled()) return false;
+ searchText = dialog.getSearchText();
+ fieldData = dialog.isFieldDataSelected();
+ fieldNames = dialog.isFieldNamesSelected();
+ sendSubject = dialog.isSendSubjectSelected();
+ replySubject = dialog.isReplySubjectSelected();
+ trackingId = dialog.isTrackingIdSelected();
+ return true;
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Search.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessor.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessor.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/matchers/DataAccessor.java 2007-01-17 09:19:29 UTC (rev 385)
@@ -0,0 +1,216 @@
+/*
+ * Class: DataAccessor
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.matchers;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.TibrvUtils;
+
+import com.tibco.tibrv.TibrvMsg;
+import com.tibco.tibrv.TibrvMsgField;
+import com.tibco.tibrv.TibrvXml;
+
+import rvsnoop.Record;
+
+/**
+ * An base for classes capable of extracting data from records.
+ * <p>
+ * Normally this will be a single value, such as the send subject, but in some
+ * cases it may be multiple values, such as all field names.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public abstract class DataAccessor {
+
+ static final class FieldContents extends DataAccessor {
+ public static final String IDENTIFIER = "fieldContents";
+ public FieldContents() {
+ super(FIELD_CONTENTS, IDENTIFIER);
+ }
+ public Iterator getDataElement(Record record) {
+ return new FieldContentsIterator(TibrvUtils.depthFirstFieldIterator(record.getMessage()));
+ }
+ }
+
+ private static final class FieldContentsIterator implements Iterator {
+ private final Iterator iterator;
+ FieldContentsIterator(Iterator iterator) {
+ this.iterator = iterator;
+ }
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+ public Object next() {
+ TibrvMsgField field = (TibrvMsgField) iterator.next();
+ if (field.type == TibrvMsg.STRING) {
+ return field.data;
+ } else if (field.type == TibrvMsg.XML) {
+ try {
+ return new String(((TibrvXml) field.data).getBytes(), "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ // Never happens, UTF-8 is always supported in a Java VM.
+ }
+ }
+ return "";
+ }
+ public void remove() {
+ iterator.remove();
+ }
+ }
+
+ static final class FieldNames extends DataAccessor {
+ public static final String IDENTIFIER = "fieldNames";
+ public FieldNames() {
+ super(FIELD_NAMES, IDENTIFIER);
+ }
+ public Iterator getDataElement(Record record) {
+ return new FieldNamesIterator(TibrvUtils.depthFirstFieldIterator(record.getMessage()));
+ }
+ }
+
+ private static final class FieldNamesIterator implements Iterator {
+ private final Iterator iterator;
+ FieldNamesIterator(Iterator iterator) {
+ this.iterator = iterator;
+ }
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+ public Object next() {
+ return ((TibrvMsgField) iterator.next()).name;
+ }
+ public void remove() {
+ iterator.remove();
+ }
+ }
+
+ static final class ReplySubject extends DataAccessor {
+ public static final String IDENTIFIER = "replySubject";
+ private final SingleElementIterator iterator = new SingleElementIterator();
+ public ReplySubject() {
+ super(REPLY_SUBJECT, IDENTIFIER);
+ }
+ public Iterator getDataElement(Record record) {
+ iterator.element = record.getReplySubject();
+ return iterator;
+ }
+ }
+
+ static final class SendSubject extends DataAccessor {
+ public static final String IDENTIFIER = "sendSubject";
+ private final SingleElementIterator iterator = new SingleElementIterator();
+ public SendSubject() {
+ super(SEND_SUBJECT, IDENTIFIER);
+ }
+ public Iterator getDataElement(Record record) {
+ iterator.element = record.getSendSubject();
+ return iterator;
+ }
+ }
+
+ private static final class SingleElementIterator implements Iterator {
+ Object element;
+ public boolean hasNext() {
+ return element != null;
+ }
+ public Object next() {
+ if (element == null) throw new NoSuchElementException();
+ Object next = element;
+ element = null;
+ return next;
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ static final class TrackingId extends DataAccessor {
+ public static final String IDENTIFIER = "trackingId";
+ private final SingleElementIterator iterator = new SingleElementIterator();
+ public TrackingId() {
+ super(TRACKING_ID, IDENTIFIER);
+ }
+ public Iterator getDataElement(Record record) {
+ iterator.element = record.getTrackingId();
+ return iterator;
+ }
+ }
+
+ static String FIELD_CONTENTS, FIELD_NAMES, REPLY_SUBJECT, SEND_SUBJECT, TRACKING_ID;
+
+ static { NLSUtils.internationalize(DataAccessor.class); }
+
+ private final String displayName;
+ private final String identifier;
+
+ protected DataAccessor(String displayName, String identifier) {
+ Validate.notNull(displayName);
+ Validate.notNull(identifier);
+ this.displayName = displayName;
+ this.identifier = identifier;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) { return true; }
+ if (obj == null) { return false; }
+ if (getClass() != obj.getClass()) { return false; }
+ final DataAccessor other = (DataAccessor) obj;
+ if (!identifier.equals(other.identifier)) { return false; }
+ return true;
+ }
+
+ /**
+ * Get the data elements from a record.
+ *
+ * @param record The record to extract data from.
+ * @return The data elements.
+ */
+ public abstract Iterator getDataElement(Record record);
+
+ /**
+ ...
[truncated message content] |
|
From: <ia...@us...> - 2007-01-08 08:07:24
|
Revision: 384
http://svn.sourceforge.net/rvsn00p/?rev=384&view=rev
Author: ianp
Date: 2007-01-08 00:07:22 -0800 (Mon, 08 Jan 2007)
Log Message:
-----------
Added ConnectionList class to handle displaying the connection list.
Added ImageFactory to handle loading and caching icons and banners.
Added RecordLedgerSelectionEvent and RecordLedgerSelectionListener, these are
going to form the basis of handling any actions which need to know about the
selection status of the ledger. A future release will do the same for the
connections list and the subject hierarchy.
Added NLSUtils and started to internationalize all of the strings. I plan to
update all of the actions for I18N as I move them to the new org.rvsnoop...
package tree, after that I'll go through the rest of the app and change over
any other strings. All images loaded via the new ImageFactory will be I18N
enabled automatically.
This is a work in progress! ButI've been away from the net for a few days
and want to get this checked in even iof it isn't complete.
Modified Paths:
--------------
trunk/rvsn00p/build.properties
trunk/rvsn00p/build.xml
trunk/rvsn00p/doc/plans.txt
trunk/rvsn00p/src/org/rvsnoop/Application.java
trunk/rvsn00p/src/org/rvsnoop/FastFormatter.java
trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java
trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.java
trunk/rvsn00p/src/org/rvsnoop/ui/RecordLedgerTable.java
trunk/rvsn00p/src/resources/icons/copy.png
trunk/rvsn00p/src/resources/icons/cut.png
trunk/rvsn00p/src/resources/icons/delete.png
trunk/rvsn00p/src/resources/icons/filter.png
trunk/rvsn00p/src/resources/icons/open.png
trunk/rvsn00p/src/resources/icons/quit.png
trunk/rvsn00p/src/resources/icons/republish.png
trunk/rvsn00p/src/rvsnoop/Connections.java
trunk/rvsn00p/src/rvsnoop/MessageLedger.java
trunk/rvsn00p/src/rvsnoop/PreferencesManager.java
trunk/rvsn00p/src/rvsnoop/ProjectFileFilter.java
trunk/rvsn00p/src/rvsnoop/RecordTypes.java
trunk/rvsn00p/src/rvsnoop/RvConnection.java
trunk/rvsn00p/src/rvsnoop/StartRvSnooper.java
trunk/rvsn00p/src/rvsnoop/Version.java
trunk/rvsn00p/src/rvsnoop/actions/Actions.java
trunk/rvsn00p/src/rvsnoop/actions/Paste.java
trunk/rvsn00p/src/rvsnoop/ui/Banners.java
trunk/rvsn00p/src/rvsnoop/ui/Icons.java
trunk/rvsn00p/src/rvsnoop/ui/RecordTypesDialog.java
trunk/rvsn00p/src/rvsnoop/ui/UIManager.java
trunk/rvsn00p/src/rvsnoop/ui/UIUtils.java
Added Paths:
-----------
trunk/rvsn00p/src/org/rvsnoop/Application.properties
trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.properties
trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java
trunk/rvsn00p/src/org/rvsnoop/actions/Copy.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Cut.java
trunk/rvsn00p/src/org/rvsnoop/actions/Cut.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Delete.java
trunk/rvsn00p/src/org/rvsnoop/actions/Delete.properties
trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java
trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.properties
trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java
trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java
trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties
trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.properties
trunk/rvsn00p/src/org/rvsnoop/actions/OpenProject.java
trunk/rvsn00p/src/org/rvsnoop/actions/OpenProject.properties
trunk/rvsn00p/src/org/rvsnoop/actions/PauseConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/PauseConnection.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/org/rvsnoop/actions/Quit.properties
trunk/rvsn00p/src/org/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/org/rvsnoop/actions/Republish.properties
trunk/rvsn00p/src/org/rvsnoop/actions/RvSnoopAction.properties
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProject.java
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProject.properties
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProjectAs.java
trunk/rvsn00p/src/org/rvsnoop/actions/SaveProjectAs.properties
trunk/rvsn00p/src/org/rvsnoop/actions/StartConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/StartConnection.properties
trunk/rvsn00p/src/org/rvsnoop/actions/StopConnection.java
trunk/rvsn00p/src/org/rvsnoop/actions/StopConnection.properties
trunk/rvsn00p/src/org/rvsnoop/event/
trunk/rvsn00p/src/org/rvsnoop/event/RecordLedgerSelectionEvent.java
trunk/rvsn00p/src/org/rvsnoop/event/RecordLedgerSelectionListener.java
trunk/rvsn00p/src/org/rvsnoop/ui/ConnectionList.java
trunk/rvsn00p/src/org/rvsnoop/ui/FooterPanel.java
trunk/rvsn00p/src/org/rvsnoop/ui/HeaderPanel.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageBorder.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.java
trunk/rvsn00p/src/org/rvsnoop/ui/ImageFactory.properties
trunk/rvsn00p/src/org/rvsnoop/ui/RecordTypesMenuManager.java
trunk/rvsn00p/src/org/rvsnoop/ui/VisibleColumnsMenuManager.java
trunk/rvsn00p/src/resources/banners/editRecordTypes.png
trunk/rvsn00p/src/resources/icons/connectionPaused.png
trunk/rvsn00p/src/resources/icons/connectionStarted.png
trunk/rvsn00p/src/resources/icons/connectionStopped.png
trunk/rvsn00p/src/resources/icons/displayAbout.png
trunk/rvsn00p/src/resources/icons/editRecordTypes.png
trunk/rvsn00p/src/resources/icons/error.png
trunk/rvsn00p/src/resources/icons/filterBySelection.png
trunk/rvsn00p/src/resources/icons/information.png
trunk/rvsn00p/src/resources/icons/newRvConnection.png
trunk/rvsn00p/src/resources/icons/pauseConnection.png
trunk/rvsn00p/src/resources/icons/saveProject.png
trunk/rvsn00p/src/resources/icons/saveProjectAs.png
trunk/rvsn00p/src/resources/icons/startConnection.png
trunk/rvsn00p/src/resources/icons/stopConnection.png
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsSample.txt
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTest.java
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTestTarget.java
trunk/rvsn00p/tests/org/rvsnoop/NLSUtilsTestTarget.properties
Removed Paths:
-------------
trunk/rvsn00p/src/resources/banners/edit_types.png
trunk/rvsn00p/src/resources/icons/about.png
trunk/rvsn00p/src/resources/icons/add_connection.png
trunk/rvsn00p/src/resources/icons/rvd_connection.psd
trunk/rvsn00p/src/resources/icons/rvd_paused.png
trunk/rvsn00p/src/resources/icons/rvd_started.png
trunk/rvsn00p/src/resources/icons/rvd_stopped.png
trunk/rvsn00p/src/resources/icons/save.png
trunk/rvsn00p/src/resources/icons/save_as.png
trunk/rvsn00p/src/resources/icons/subject.png
trunk/rvsn00p/src/rvsnoop/actions/AddConnection.java
trunk/rvsn00p/src/rvsnoop/actions/Copy.java
trunk/rvsn00p/src/rvsnoop/actions/Cut.java
trunk/rvsn00p/src/rvsnoop/actions/Delete.java
trunk/rvsn00p/src/rvsnoop/actions/DisplayAbout.java
trunk/rvsn00p/src/rvsnoop/actions/EditRecordTypes.java
trunk/rvsn00p/src/rvsnoop/actions/Filter.java
trunk/rvsn00p/src/rvsnoop/actions/Open.java
trunk/rvsn00p/src/rvsnoop/actions/Quit.java
trunk/rvsn00p/src/rvsnoop/actions/Republish.java
trunk/rvsn00p/src/rvsnoop/actions/Save.java
trunk/rvsn00p/src/rvsnoop/actions/SaveAs.java
trunk/rvsn00p/src/rvsnoop/ui/ConnectionListRenderer.java
trunk/rvsn00p/src/rvsnoop/ui/HeaderPanel.java
Property Changed:
----------------
trunk/rvsn00p/
Property changes on: trunk/rvsn00p
___________________________________________________________________
Name: svn:ignore
-
.classpath
.project
build
local.properties
rvsnoop-*-???.tgz
dist
.pmd
.externalToolBuilders
.settings
stage
*.tgz
classes
+
.classpath
.project
build
local.properties
rvsnoop-*-???.tgz
dist
.pmd
.externalToolBuilders
.settings
stage
*.tgz
classes
debug-logging.properties
commons-logging.properties
Modified: trunk/rvsn00p/build.properties
===================================================================
--- trunk/rvsn00p/build.properties 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/build.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -35,11 +35,13 @@
# The svnversion command is needed to set the build number correctly.
svnversion=/usr/local/bin/svnversion
-svnversion.offline=false
# If you are building with a non-standard JDK (e.g. GCJ) you may need to change this.
java.lib=${java.home}/lib/rt.jar
# Build Options
+#skip.setbuildversion=true
+#skip.genjavadoc=true
+#skip.analyze=true
javac.debug=true
javac.optimize=true
javac.deprecation=false
Modified: trunk/rvsn00p/build.xml
===================================================================
--- trunk/rvsn00p/build.xml 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/build.xml 2007-01-08 08:07:22 UTC (rev 384)
@@ -26,7 +26,7 @@
</target>
<!-- Get the build version. -->
- <target name="setbuildversion" unless="svnversion.offline" depends="settimestamp">
+ <target name="setbuildversion" unless="skip.setbuildversion" depends="settimestamp">
<exec executable="${svnversion}" spawn="false" dir="." output="build.number" failifexecutionfails="false">
<arg line="."/>
</exec>
@@ -116,7 +116,7 @@
</copy>
<copy todir="${dir.stage}/tests" encoding="UTF-8">
<filterset refid="filters"/>
- <fileset dir="tests" includes="**/*.java"/>
+ <fileset dir="tests" includes="**/*.java, **/*.properties, **/*.txt"/>
</copy>
<copy todir="${dir.stage}/tests">
<fileset dir="tests" includes="**/*.rbz"/>
@@ -159,11 +159,12 @@
</javac>
</target>
- <target name="genjavadoc" depends="stage"
+ <target name="genjavadoc" depends="stage" unless="skip.genjavadoc"
description="Compile all of the Java API documentation.">
<mkdir dir="${dir.build}/doc/api"/>
- <javadoc destdir="${dir.build}/doc/api" version="true" author="true" use="true"
- access="${javadoc.access}" windowtitle="RvSnoop ${version} API Documentation">
+ <javadoc destdir="${dir.build}/doc/api" version="true" author="true"
+ use="true" source="1.4" access="${javadoc.access}"
+ windowtitle="RvSnoop ${version} API Documentation">
<doctitle><![CDATA[<h1>RvSnoop ${version}</h1>]]></doctitle>
<bottom><![CDATA[Copyright © 2002-${year} <a href="http://ianp.org/">Ian Phillips</a> and Örjan Lundberg.]]></bottom>
<packageset dir="${dir.stage}/src" defaultexcludes="true" includes="**"/>
@@ -241,6 +242,7 @@
</manifest>
<fileset dir="${dir.build}/classes/main" includes="**/*.class"/>
<fileset dir="${dir.stage}/src" includes="**/*.png"/>
+ <fileset dir="${dir.stage}/src" includes="**/*.properties" excludes="commons-logging.properties"/>
</jar>
<copy todir="${dir.dist}/lib">
<fileset file="${lib.binding}"/>
@@ -293,7 +295,7 @@
</scp>
</target>
- <target name="analyze" depends="compile"
+ <target name="analyze" depends="compile" unless="skip.analyze"
description="Analyze the code base and generate reports.">
<taskdef name="pmd" classpath="${lib.pmd}"
classname="net.sourceforge.pmd.ant.PMDTask"/>
Modified: trunk/rvsn00p/doc/plans.txt
===================================================================
(Binary files differ)
Modified: trunk/rvsn00p/src/org/rvsnoop/Application.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/src/org/rvsnoop/Application.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -9,10 +9,15 @@
import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.rvsnoop.actions.RvSnoopAction;
+import org.rvsnoop.ui.RecordLedgerTable;
import rvsnoop.PreferencesManager;
import rvsnoop.Project;
+import rvsnoop.RecordTypes;
+import rvsnoop.RvConnection;
import rvsnoop.actions.Actions;
import rvsnoop.ui.UIManager;
@@ -28,6 +33,12 @@
*/
public final class Application {
+ static { NLSUtils.internationalize(Application.class); }
+
+ private static final Log log = LogFactory.getLog(Application.class);
+
+ static String ERROR_SHUTDOWN;
+
private Actions actionFactory;
private FilteredLedgerView filteredLedger;
@@ -79,7 +90,7 @@
*/
public synchronized FilteredLedgerView getFilteredLedger() {
if (filteredLedger == null) {
- filteredLedger = new FilteredLedgerView(ledger);
+ filteredLedger = new FilteredLedgerView(getLedger());
}
return filteredLedger;
}
@@ -100,6 +111,15 @@
}
/**
+ * Get the record ledger table.
+ *
+ * @return The ledger table.
+ */
+ public RecordLedgerTable getLedgerTable() {
+ return getFrame().getMessageLedger();
+ }
+
+ /**
* Get the current project.
*
* @return The project, or <code>null</code> if the project has not been
@@ -136,11 +156,24 @@
* @return the frame
*/
public synchronized UIManager getFrame() {
- if (frame == null) { frame = new UIManager(this); }
+ if (frame == null) {
+ frame = new UIManager(this);
+ getActionFactory().configureListeners();
+ }
return frame;
}
/**
+ * Get all of the known record types.
+ *
+ * @return The record types.
+ */
+ public synchronized RecordTypes getRecordTypes() {
+ // FIXME this should not use a static instance, they should be loaded from the project.
+ return RecordTypes.getInstance();
+ }
+
+ /**
* @return the sessionState
*/
public synchronized PreferencesManager getSessionState() {
@@ -148,4 +181,16 @@
return sessionState;
}
+ /**
+ * Shut down the applicatiopn and stop the VM.
+ */
+ public void shutdown() {
+ try {
+ RvConnection.shutdown();
+ System.exit(0);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) { log.error(ERROR_SHUTDOWN, e); }
+ System.exit(1);
+ }
+ }
}
Added: trunk/rvsn00p/src/org/rvsnoop/Application.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/Application.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/Application.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1 @@
+ERROR_SHUTDOWN=Exception caught during shut down sequence.
\ No newline at end of file
Modified: trunk/rvsn00p/src/org/rvsnoop/FastFormatter.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/FastFormatter.java 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/src/org/rvsnoop/FastFormatter.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -74,6 +74,7 @@
if (message != null) { builder.append(message); }
final Throwable thrown = record.getThrown();
if (thrown != null) {
+ builder.appendNewLine();
// Use an auto-flushing writer that appends directly to the builder,
// so no need to worry about cleaning up or catching IOExceptions.
thrown.printStackTrace(new PrintWriter(new StrBuilderWriter(builder), true));
Added: trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,297 @@
+/*
+ * Class: NLSUtils
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2007-2007 Ian Phillips.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Utility methods to load message values from property files and assign them
+ * directly to the fields of a class. Originally based on a class from Equinox.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ */
+public final class NLSUtils {
+
+ private static final class PriviledgedFieldSetter implements PrivilegedAction {
+ private final Field field;
+ private final Object value;
+ private PriviledgedFieldSetter(Field field, Object value) {
+ this.field = field;
+ this.value = value;
+ }
+ public Object run() {
+ try {
+ field.setAccessible(true);
+ field.set(null, value);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error setting field " + field.getName() + " to " + value, e);
+ }
+ } finally {
+ field.setAccessible(false);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Class which sub-classes java.util.Properties and uses the #put method to
+ * set field values rather than storing the values in the table.
+ */
+ private static class MessagesProperties extends Properties {
+
+ private static final long serialVersionUID = 4566962090422045058L;
+
+ // values can be either String or Field instances.
+ private final Map namesToFields;
+
+ private final String resourcePath;
+
+ public MessagesProperties(Map namesToFields, String resourcePath) {
+ super();
+ this.namesToFields = namesToFields;
+ this.resourcePath = resourcePath;
+ }
+
+ /**
+ * Mark assigned fields to prevent them from being assigned twice.
+ *
+ * @see java.util.Hashtable#put(Object,Object)
+ */
+ public synchronized Object put(Object name, Object value) {
+ Object putObject = super.put(name, value); // value to return.
+ Object previousFieldValue = namesToFields.put(name, ASSIGNED);
+ // if already assigned, there is nothing to do
+ if (previousFieldValue == ASSIGNED) {
+ if (log.isDebugEnabled()) {
+ log.debug("Ignoring duplicate property " + name + " in " + resourcePath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return putObject;
+ }
+ // if there is no field with a corresponding name, there is nothing to do
+ if (previousFieldValue == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unused message " + name + " in " + resourcePath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return putObject;
+ }
+ Field previousField = (Field) previousFieldValue;
+ // Can only set value of public static non-final fields
+ if ((previousField.getModifiers() & MOD_MASK) != Modifier.STATIC) {
+ if (log.isTraceEnabled()) {
+ log.trace("Skipping non-static field " + name); //$NON-NLS-1$
+ }
+ return putObject;
+ }
+ try {
+ setField(previousField, value);
+ if (log.isTraceEnabled()) {
+ log.trace("Field " + name + " set to " + value); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Could not set field " + name, e); //$NON-NLS-1$
+ }
+ }
+ return putObject;
+ }
+ }
+
+ /**
+ * This is assigned to the value of a field map to indicate that a
+ * translated message has already been assigned to that field. It is a self
+ * referential field, see the static load section for details.
+ */
+ static Field ASSIGNED;
+
+ static final Log log = LogFactory.getLog(NLSUtils.class);
+
+ static final int MOD_MASK = Modifier.STATIC | Modifier.FINAL;
+
+ private static String[] nlSuffixes;
+
+ final static String SUFFIX = ".properties"; //$NON-NLS-1$
+
+ static {
+ try {
+ ASSIGNED = NLSUtils.class.getDeclaredField("ASSIGNED"); //$NON-NLS-1$
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not load internationalized strings correctly.", e); // $NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Build an array of property files to search. The returned array contains
+ * the property fields in order from most specific to most generic. So, in
+ * the fr_FR locale, it will return file_fr_FR.properties, then
+ * file_fr.properties, and finally file.properties.
+ */
+ private static String[] buildVariants(String resourcePath, String suffix) {
+ if (nlSuffixes == null) {
+ String nl = Locale.getDefault().toString();
+ final List result = new ArrayList(4);
+ int lastSeparator;
+ while (true) {
+ result.add('_' + nl);
+ lastSeparator = nl.lastIndexOf('_');
+ if (lastSeparator == -1) { break; }
+ nl = nl.substring(0, lastSeparator);
+ }
+ // Add the empty (most general) suffix last
+ result.add("");
+ nlSuffixes = (String[]) result.toArray(new String[result.size()]);
+ }
+ String[] variants = new String[nlSuffixes.length];
+ for (int i = 0; i < variants.length; i++) {
+ variants[i] = resourcePath + nlSuffixes[i] + suffix;
+ }
+ return variants;
+ }
+
+ private static void computeMissingMessages(String resourcePath,
+ Class clazz, Map namesToFields,
+ Field[] fields) {
+ // Make sure that there aren't any empty fields
+ for (int i = 0, imax = fields.length; i < imax; ++i) {
+ Field field = fields[i];
+ if ((field.getModifiers() & MOD_MASK) != Modifier.STATIC)
+ continue;
+ // If the field has a a value assigned, there is nothing to do
+ if (namesToFields.get(field.getName()) == ASSIGNED) { continue; }
+ try {
+ if (log.isWarnEnabled()) {
+ log.warn("Missing message: " + field.getName() + " in: " + resourcePath); //$NON-NLS-1$ $NON-NLS-2$
+ }
+ setField(field, "!" + field.getName() + "!"); //$NON-NLS-1$ $NON-NLS-2$
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not set missing message for " + field.getName(), e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ * Locate a "localized" file. For example a license file could be located by
+ * calling <code>NLS.findNLSResource("/META-INF/license.txt", clazz);</code>.
+ *
+ * @param resourcePath The resource to load.
+ * @param clazz The context ({@link java.lang.ClassLoader}) to load from.
+ * @return The resource, or <code>null</code> if it could not be found.
+ */
+ public static InputStream findNLSResource(String resourcePath, Class clazz) {
+ final int lastIndex = resourcePath.lastIndexOf(".");
+ final String basePath = resourcePath.substring(0, lastIndex);
+ final String suffix = resourcePath.substring(lastIndex);
+ final String[] variants = buildVariants(basePath, suffix);
+ for (int i = 0, imax = variants.length; i < imax; ++i) {
+ final InputStream stream = clazz.getResourceAsStream(variants[i]);
+ if (stream != null) { return stream; }
+ }
+ return null;
+ }
+
+ /** Internationalize a class. */
+ public static void internationalize(Class clazz) {
+ String resource = "/" + clazz.getName().replaceAll("\\.", "/");
+ internationalize(resource, clazz);
+ }
+
+ /**
+ * Internationalize a class.
+ * <p>
+ * This will load strings from the file at <code>resourcePath</code> and
+ * set any <code>static String</code> fields on <code>clazz</code>. The
+ * class' <code>ClassLoader</code> will be used to locate the resource
+ * file.
+ */
+ public static void internationalize(final String resourcePath, Class clazz) {
+ long start = log.isTraceEnabled() ? System.currentTimeMillis() : 0;
+ if (log.isDebugEnabled()) {
+ log.debug("Loading NLS bundle for " + ClassUtils.getShortClassName(clazz) + " from " + resourcePath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ Field[] fields = clazz.getDeclaredFields();
+ // Strip out compiler generated synthetic fields
+ Field[] tmpFields = new Field[fields.length];
+ int numFields = 0;
+ for (int i = 0, imax = fields.length; i < imax; ++i) {
+ final Field field = fields[i];
+ if (field.getType() == String.class && !(field.getName().indexOf('$') >= 0)) { //$NON-NLS-1$
+ tmpFields[numFields++] = field;
+ }
+ }
+ fields = new Field[numFields];
+ System.arraycopy(tmpFields, 0, fields, 0, fields.length);
+ // OK, ready to use the field array now.
+ // Build a map of field names to Field objects
+ final int len = fields.length;
+ final Map namesToFields = new HashMap(len * 2);
+ for (int i = 0; i < len; i++) {
+ namesToFields.put(fields[i].getName(), fields[i]);
+ }
+ // Search the variants from most specific to most general
+ final String[] variants = buildVariants(resourcePath, SUFFIX);
+ for (int i = 0, imax = variants.length; i < imax; ++i) {
+ String variant = variants[i];
+ if (log.isTraceEnabled()) {
+ log.trace("Trying to load message resource " + variant); //$NON-NLS-1$
+ }
+ final InputStream input = clazz.getResourceAsStream(variant);
+ if (input == null) { continue; }
+ try {
+ final MessagesProperties properties = new MessagesProperties(
+ namesToFields, resourcePath);
+ properties.load(input);
+ if (log.isTraceEnabled()) {
+ log.trace("Successfully loaded " + properties.size() + " messages from resource " + variant); //$NON-NLS-1$ $NON-NLS-2$
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error loading message resource" + variant, e); //$NON-NLS-1$
+ }
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+ computeMissingMessages(resourcePath, clazz, namesToFields, fields);
+ if (log.isTraceEnabled()) {
+ log.trace("Message bundle " + resourcePath + " loaded in " + (System.currentTimeMillis() - start) + " msecs."); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+ }
+ }
+
+ static void setField(final Field field, final Object value) throws IllegalArgumentException, IllegalAccessException {
+ if (field.isAccessible()) {
+ field.set(null, value);
+ } else {
+ AccessController.doPrivileged(new PriviledgedFieldSetter(field, value));
+ }
+ }
+
+ /** Private constructor, do not instantiate. */
+ private NLSUtils() { throw new UnsupportedOperationException(); }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/NLSUtils.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -74,7 +74,13 @@
public abstract Object getValue(Record record);
}
- public static ColumnFormat CONNECTION = new ColumnFormat("connection", "Connection", String.class, new ComparableComparator()) {
+ static String CONNECTION_NAME, MESSAGE_NAME, SEQUENCE_NO_NAME,
+ SIZE_IN_BYTES_NAME, SUBJECT_NAME, TIMESTAMP_NAME, TRACKING_ID_NAME,
+ TYPE_NAME;
+
+ static { NLSUtils.internationalize(RecordLedgerFormat.class); }
+
+ public static ColumnFormat CONNECTION = new ColumnFormat("connection", CONNECTION_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = -4938884664732119140L;
public Object getValue(Record record) {
final RvConnection connection = record.getConnection();
@@ -82,49 +88,49 @@
}
};
- public static final ColumnFormat MESSAGE = new ColumnFormat("message", "Message", Object.class) {
+ public static final ColumnFormat MESSAGE = new ColumnFormat("message", MESSAGE_NAME, Object.class) {
private static final long serialVersionUID = 3526646591996520301L;
public Object getValue(Record record) {
return record.getMessage();
}
};
- public static final ColumnFormat SEQUENCE_NO = new ColumnFormat("sequence", "Seq. No.", Long.class, new ComparableComparator()) {
+ public static final ColumnFormat SEQUENCE_NO = new ColumnFormat("sequence", SEQUENCE_NO_NAME, Long.class, new ComparableComparator()) {
private static final long serialVersionUID = -5762735421370128862L;
public Object getValue(Record record) {
return Long.toString(record.getSequenceNumber());
}
};
- public static final ColumnFormat SIZE_IN_BYTES = new ColumnFormat("size", "Size (bytes)", Integer.class, new ComparableComparator()) {
+ public static final ColumnFormat SIZE_IN_BYTES = new ColumnFormat("size", SIZE_IN_BYTES_NAME, Integer.class, new ComparableComparator()) {
private static final long serialVersionUID = 2274660797219318776L;
public Object getValue(Record record) {
return new Integer(record.getSizeInBytes());
}
};
- public static final ColumnFormat SUBJECT = new ColumnFormat("subject", "Subject", String.class, new ComparableComparator()) {
+ public static final ColumnFormat SUBJECT = new ColumnFormat("subject", SUBJECT_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = 7415054603888398693L;
public Object getValue(Record record) {
return record.getSendSubject();
}
};
- public static final ColumnFormat TIMESTAMP = new ColumnFormat("timestamp", "Timestamp", Date.class, new ComparableComparator()) {
+ public static final ColumnFormat TIMESTAMP = new ColumnFormat("timestamp", TIMESTAMP_NAME, Date.class, new ComparableComparator()) {
private static final long serialVersionUID = -3858078006527711756L;
public Object getValue(Record record) {
return new Date(record.getTimestamp());
}
};
- public static final ColumnFormat TRACKING_ID = new ColumnFormat("tracking", "Tracking ID", String.class, new ComparableComparator()) {
+ public static final ColumnFormat TRACKING_ID = new ColumnFormat("tracking", TRACKING_ID_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = -3033175036104293820L;
public Object getValue(Record record) {
return record.getTrackingId();
}
};
- public static final ColumnFormat TYPE = new ColumnFormat("type", "Type", String.class, new ComparableComparator()) {
+ public static final ColumnFormat TYPE = new ColumnFormat("type", TYPE_NAME, String.class, new ComparableComparator()) {
private static final long serialVersionUID = 6353909616946303068L;
final RecordTypes types = RecordTypes.getInstance();
public Object getValue(Record record) {
@@ -176,6 +182,17 @@
}
}
+ /**
+ * Is a given column visible in this format.
+ *
+ * @param column The column to check.
+ * @return <code>true</code> if the column is currently visible,
+ * <code>false</code> otherwise.
+ */
+ public boolean contains(ColumnFormat column) {
+ return columns.contains(column);
+ }
+
/* (non-Javadoc)
* @see ca.odell.glazedlists.gui.AdvancedTableFormat#getColumnClass(int)
*/
@@ -250,8 +267,7 @@
*
* @param model
*/
- public void setModel(EventTableModel model) {
- // TODO: reduce visibility.
+ void setModel(EventTableModel model) {
this.model = model;
}
Added: trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/RecordLedgerFormat.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,8 @@
+CONNECTION_NAME=Connection
+MESSAGE_NAME=Message
+SEQUENCE_NO_NAME=Seq. No.
+SIZE_IN_BYTES_NAME=Size (bytes)
+SUBJECT_NAME=Subject
+TIMESTAMP_NAME=Timestamp
+TRACKING_ID_NAME=Tracking ID
+TYPE_NAME=Type
\ No newline at end of file
Modified: trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java 2007-01-04 07:32:45 UTC (rev 383)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -8,15 +8,14 @@
package org.rvsnoop.actions;
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import javax.swing.Action;
import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
import rvsnoop.Record;
import rvsnoop.SubjectHierarchy;
-import rvsnoop.ui.Icons;
import rvsnoop.ui.UIManager;
/**
@@ -28,18 +27,19 @@
*/
public final class ClearLedger extends RvSnoopAction {
+ static { NLSUtils.internationalize(ClearLedger.class); }
+
private static final long serialVersionUID = -3552599952765687823L;
public static final String COMMAND = "clearLedger";
- private static String NAME = "Clear Ledger";
- private static String TOOLTIP = "Delete all records from the ledger";
+ static String MNEMONIC, NAME, TOOLTIP;
public ClearLedger(Application application) {
super(NAME, application);
putValue(Action.ACTION_COMMAND_KEY, COMMAND);
- putValue(Action.SMALL_ICON, Icons.createSmallIcon(COMMAND));
+ putSmallIconValue(COMMAND);
putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
- putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
+ putMnemonicValue(MNEMONIC);
}
/* (non-Javadoc)
Added: trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/ClearLedger.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,4 @@
+# 0x45 == KeyEvent.VK_E
+MNEMONIC=0x45
+NAME=Clear Ledger
+TOOLTIP=Delete all records from the ledger
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/Copy.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,66 @@
+/*
+ * Class: Copy
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+
+import rvsnoop.Record;
+import rvsnoop.RecordSelection;
+
+/**
+ * Copy the currently selected record(s) to the system clipboard.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class Copy extends RvSnoopAction implements RecordLedgerSelectionListener {
+
+ static { NLSUtils.internationalize(Copy.class); }
+
+ private static final long serialVersionUID = 7395491526593830048L;
+
+ public static final String COMMAND = "copy";
+ static String ACCELERATOR, MNEMONIC, NAME, TOOLTIP;
+
+ private transient Record[] currentSelection;
+
+ public Copy(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.RvSnoopAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ final RecordSelection sel = new RecordSelection(currentSelection);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ currentSelection = event.getSelectedRecords();
+ setEnabled(currentSelection.length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Copy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Copy.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Copy.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Copy.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,5 @@
+# 0x43 == KeyEvent.VK_C
+ACCELERATOR=0x43
+MNEMONIC=0x43
+NAME=Copy
+TOOLTIP=Copy the selected records to the clipboard
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Cut.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/Cut.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Cut.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Cut.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,60 @@
+/*
+ * Class: Cut
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+
+/**
+ * Copy the currently selected record(s) to the system clipboard then remove
+ * them from the ledger.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class Cut extends RvSnoopAction implements RecordLedgerSelectionListener {
+
+ static { NLSUtils.internationalize(Cut.class); }
+
+ private static final long serialVersionUID = 795156697514723501L;
+
+ public static final String COMMAND = "cut";
+ static String ACCELERATOR, MNEMONIC, NAME, TOOLTIP;
+
+ public Cut(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.RvSnoopAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ application.getAction(Copy.COMMAND).actionPerformed(e);
+ application.getAction(Delete.COMMAND).actionPerformed(e);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ setEnabled(event.getSelectedRecords().length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Cut.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Cut.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Cut.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Cut.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,5 @@
+# 0x58 == KeyEvent.VK_X
+ACCELERATOR=0x58
+MNEMONIC=0x58
+NAME=Cut
+TOOLTIP=Move the selected records from the ledger to the clipboard
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Delete.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/Delete.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Delete.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Delete.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,67 @@
+/*
+ * Class: Delete
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.event.ActionEvent;
+import java.util.Arrays;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+
+import rvsnoop.Record;
+
+/**
+ * Delete the currently selected record(s) from the ledger.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class Delete extends RvSnoopAction implements RecordLedgerSelectionListener {
+
+ static { NLSUtils.internationalize(Delete.class); }
+
+ private static final long serialVersionUID = -4082252661195745678L;
+ private static final Record[] NO_SELECTION = new Record[0];
+
+ public static final String COMMAND = "delete";
+ static String ACCELERATOR, MNEMONIC, NAME, TOOLTIP;
+
+ private transient Record[] currentSelection;
+
+ public Delete(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ putAcceleratorValue(ACCELERATOR);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.actions.RvSnoopAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ application.getFilteredLedger().removeAll(Arrays.asList(currentSelection));
+ currentSelection = NO_SELECTION;
+ setEnabled(false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ currentSelection = event.getSelectedRecords();
+ setEnabled(currentSelection.length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Delete.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Delete.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Delete.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Delete.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,6 @@
+# 0x7F == KeyEvent.VK_DELETE (ASCII DEL)
+ACCELERATOR=0x7F
+# 0x44 == KeyEvent.VK_D
+MNEMONIC=0x44
+NAME=Delete
+TOOLTIP=Delete the currently selected records from the ledger
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/DisplayAbout.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,73 @@
+/*
+ * Class: DisplayAbout
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+import javax.swing.JOptionPane;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+
+import rvsnoop.Version;
+
+/**
+ * Display the about dialog.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.4
+ */
+public final class DisplayAbout extends RvSnoopAction {
+
+ static { NLSUtils.internationalize(DisplayAbout.class); }
+
+ private static final long serialVersionUID = -7216295133474774451L;
+
+ public static final String COMMAND = "displayAbout";
+ static String MNEMONIC, NAME, TOOLTIP;
+
+ public DisplayAbout(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event) {
+ // TODO add a real about dialog
+ JOptionPane.showMessageDialog(
+ application.getFrame().getFrame(),
+ new String[] { Version.getAsStringWithName(),
+ " ",
+ "Constructed by Örjan Lundberg (lun...@ho...)",
+ "and Ian Phillips (ia...@ia...)",
+ " ",
+ "This product includes software developed by",
+ "The Apache Software Foundation (http://www.apache.org).",
+ " ",
+ "Thanks goes to (in no special order):",
+ "\tEric Albert, Stefan Axelsson, Thomas Bonderud,",
+ "\tStefan Farestam, Johan Hjort, Joe Jensen",
+ "\tMagnus L Johansson, Anders Lindlof, Linda Lundberg",
+ "\tStephanie Lundberg, Cedric Rouvrais, and Richard Valk.",
+ " ",
+ "Copyright © 2002-2007 Ian Phillips and Örjan Lundberg.",
+ " ",
+ "Licensed under the Apache Software License (Version 2.0).",
+ "\tA copy of the license has been included with this",
+ "\tdistribution in the file doc/license.html." },
+ NAME, JOptionPane.PLAIN_MESSAGE);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/DisplayAbout.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,4 @@
+# 0x41 == KeyEvent.VK_A
+MNEMONIC=0x41
+NAME=About
+TOOLTIP=Show some general information about RvSnoop
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/EditRecordTypes.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,54 @@
+/*
+ * Class: EditRecordTypes
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+
+import rvsnoop.ui.RecordTypesDialog;
+
+/**
+ * Display a dialog to allow editing of the record types.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.6
+ */
+public final class EditRecordTypes extends RvSnoopAction {
+
+ static { NLSUtils.internationalize(EditRecordTypes.class); }
+
+ private static final long serialVersionUID = 2918397665675386954L;
+
+ public static final String COMMAND = "editRecordTypes";
+ static String MNEMONIC, NAME, TOOLTIP;
+
+ public EditRecordTypes(Application application) {
+ super(NAME, application);
+ putValue(Action.ACTION_COMMAND_KEY, COMMAND);
+ putSmallIconValue(COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, TOOLTIP);
+ putMnemonicValue(MNEMONIC);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event) {
+ final RecordTypesDialog dialog = new RecordTypesDialog();
+ dialog.setModal(true);
+ dialog.pack();
+ dialog.setVisible(true);
+ application.getLedgerTable().repaint();
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/EditRecordTypes.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,4 @@
+# 0x4C == KeyEvent.VK_L
+MNEMONIC=0x4C
+NAME=Edit Record Types
+TOOLTIP=Customize the record types that are used
\ No newline at end of file
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/Filter.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,151 @@
+/*
+ * Class: Filter
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
+import ca.odell.glazedlists.matchers.Matcher;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.apache.commons.lang.text.StrBuilder;
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+import org.rvsnoop.event.RecordLedgerSelectionEvent;
+import org.rvsnoop.event.RecordLedgerSelectionListener;
+
+import rvsnoop.Record;
+import rvsnoop.ui.FilterDialog;
+
+/**
+ * Filter the messages visible in the ledger.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public final class Filter extends RvSnoopAction implements RecordLedgerSelectionListener {
+
+ private static class FilterMatcher implements Matcher {
+ private String sendSubject;
+ private String trackingId;
+
+ private boolean sendSubjectEnabled;
+ private boolean trackingIdEnabled;
+
+ FilterMatcher(String sendSubject, String trackingId, boolean sendSubjectEnabled, boolean trackingIdEnabled) {
+ super();
+ this.sendSubject = sendSubject;
+ this.trackingId = trackingId;
+ this.sendSubjectEnabled = sendSubjectEnabled;
+ this.trackingIdEnabled = trackingIdEnabled;
+ }
+
+ public boolean matches(Object item) {
+ final Record record = (Record) item;
+ if (sendSubjectEnabled && record.getSendSubject().indexOf(sendSubject) < 0) return false;
+ if (trackingIdEnabled && record.getTrackingId().indexOf(trackingId) < 0) return false;
+ return true;
+ }
+ }
+
+ private static class FilterMatcherEditor extends AbstractMatcherEditor {
+ // TODO: Make this more efficient by re-using the matcher and firing
+ // constrained or relaxed instead of just changed each time.
+ FilterMatcherEditor() {
+ super();
+ }
+ void setMatcher(Matcher matcher) {
+ currentMatcher = matcher;
+ fireChanged(matcher);
+ }
+ }
+
+ static { NLSUtils.internationalize(Filter.class); }
+
+ private static final long serialVersionUID = 7395491526593830048L;
+
+ public static final String FILTER_COMMAND = "filter";
+ public static final String FILTER_BY_SELECTION_COMMAND = "filterBySelection";
+
+ static String FILTER_ACCELERATOR, FILTER_MNEMONIC,
+ FILTER_NAME, FILTER_TOOLTIP;
+ static String FILTER_BY_SELECTION_ACCELERATOR, FILTER_BY_SELECTION_MNEMONIC,
+ FILTER_BY_SELECTION_NAME, FILTER_BY_SELECTION_TOOLTIP;
+
+ private final boolean bySelection;
+
+ private String sendSubject;
+ private String trackingId;
+
+ private boolean sendSubjectEnabled;
+ private boolean trackingIdEnabled;
+
+ private FilterMatcherEditor matcherEditor;
+
+ private transient Record[] currentSelection;
+
+ public Filter(Application application, boolean bySelection) {
+ super(bySelection ? FILTER_BY_SELECTION_NAME : FILTER_NAME, application);
+ this.bySelection = bySelection;
+ if (bySelection) {
+ putValue(Action.ACTION_COMMAND_KEY, FILTER_BY_SELECTION_COMMAND);
+ putSmallIconValue(FILTER_BY_SELECTION_COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, FILTER_BY_SELECTION_TOOLTIP);
+ putMnemonicValue(FILTER_BY_SELECTION_MNEMONIC);
+ putAcceleratorValue(FILTER_BY_SELECTION_ACCELERATOR);
+ } else {
+ putValue(Action.ACTION_COMMAND_KEY, FILTER_COMMAND);
+ putSmallIconValue(FILTER_COMMAND);
+ putValue(Action.SHORT_DESCRIPTION, FILTER_TOOLTIP);
+ putMnemonicValue(FILTER_MNEMONIC);
+ putAcceleratorValue(FILTER_ACCELERATOR);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event) {
+ if (bySelection) {
+ // TODO use all of the records when filtering by selection.
+ final Record record = currentSelection[0];
+ sendSubject = record.getSendSubject();
+ trackingId = record.getTrackingId();
+ }
+ final FilterDialog dialog = new FilterDialog(sendSubject, trackingId, sendSubjectEnabled, trackingIdEnabled);
+ dialog.setVisible(true);
+ if (dialog.isCancelled()) { return; }
+ sendSubject = dialog.getSendSubject();
+ trackingId = dialog.getTrackingId();
+ sendSubjectEnabled = dialog.isSendSubjectSelected();
+ trackingIdEnabled = dialog.isTrackingIdSelected();
+ synchronized (this) {
+ if (matcherEditor == null) {
+ matcherEditor = new FilterMatcherEditor();
+ application.getFilteredLedger().addFilter(matcherEditor);
+ }
+ }
+ matcherEditor.setMatcher(new FilterMatcher(sendSubject, trackingId, sendSubjectEnabled, trackingIdEnabled));
+ final StrBuilder builder = new StrBuilder();
+ if (sendSubjectEnabled) builder.append("Send Subject: ").append(sendSubject);
+ if (sendSubjectEnabled && trackingIdEnabled) builder.append("\n");
+ if (trackingIdEnabled) builder.append("Tracking ID: ").append(trackingId);
+ application.getFrame().setStatusBarFilter(builder.toString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.rvsnoop.event.RecordLedgerSelectionListener#valueChanged(org.rvsnoop.event.RecordLedgerSelectionEvent)
+ */
+ public void valueChanged(RecordLedgerSelectionEvent event) {
+ currentSelection = event.getSelectedRecords();
+ setEnabled(!bySelection || currentSelection.length > 0);
+ }
+
+}
Property changes on: trunk/rvsn00p/src/org/rvsnoop/actions/Filter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/Filter.properties 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,10 @@
+# 0x46 == KeyEvent.VK_F
+FILTER_ACCELERATOR=ALT+SHIFT+0x46
+FILTER_MNEMONIC=0x46
+FILTER_NAME=Filter
+FILTER_TOOLTIP=Filter the contents of the ledger
+# 0x53 == KeyEvent.VK_S
+FILTER_BY_SELECTION_ACCELERATOR=ALT+SHIFT+0x53
+FILTER_BY_SELECTION_MNEMONIC=0x53
+FILTER_BY_SELECTION_NAME=Filter By Selection
+FILTER_BY_SELECTION_TOOLTIP=Filter the contents of the ledger
\ No newline at end of file
Copied: trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java (from rev 383, trunk/rvsn00p/src/rvsnoop/actions/AddConnection.java)
===================================================================
--- trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java (rev 0)
+++ trunk/rvsn00p/src/org/rvsnoop/actions/NewRvConnection.java 2007-01-08 08:07:22 UTC (rev 384)
@@ -0,0 +1,60 @@
+/*
+ * Class: NewRvConnection
+ * Version: $Revision$
+ * Date: $Date$
+ * Copyright: Copyright © 2006-2007 Ian Phillips and Örjan Lundberg.
+ * License: Apache Software License (Version 2.0)
+ */
+package org.rvsnoop.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.rvsnoop.Application;
+import org.rvsnoop.NLSUtils;
+
+import rvsnoop.Connections;
+import rvsnoop.RecentConnections;
+import rvsnoop.RvConnection;
+import rvsnoop.ui.RvConnectionDialog;
+
+/**
+ * Create a new connection instance.
+ *
+ * @author <a href="mailto:ia...@ia...">Ian Phillips</a>
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public final class NewRvConnectio...
[truncated message content] |