From: <fd...@us...> - 2009-05-02 10:29:37
|
Revision: 5383 http://jnode.svn.sourceforge.net/jnode/?rev=5383&view=rev Author: fduminy Date: 2009-05-02 10:29:31 +0000 (Sat, 02 May 2009) Log Message: ----------- Use of Context to get in/out/err streams instead of directly using System.in/out/err : that allow JPartitionCommand to work properly with JNode's shell streams. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/RemovePartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/BaseCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserFacade.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DiskAreaView.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/MainView.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/SwingViewFactory.java trunk/distr/src/test/org/jnode/apps/jpartition/JPartitionTest.java Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,9 @@ package org.jnode.apps.jpartition; +import java.io.InputStream; +import java.io.PrintStream; + import org.jnode.apps.jpartition.model.UserFacade; /** @@ -39,13 +42,33 @@ private final boolean install; /** + * The input stream to use. + */ + private final InputStream in; + + /** + * The output stream to use. + */ + private final PrintStream out; + + /** + * The error stream to use. + */ + private final PrintStream err; + + /** * Constructor for a new instance of JPartition application. * @param viewFactory The view factory used to create the user interface. + * @param in Input stream. + * @param out Output stream. * @param install True if we are trying to install jnode, false in other cases. */ - public JPartition(ViewFactory viewFactory, boolean install) { + public JPartition(ViewFactory viewFactory, InputStream in, PrintStream out, PrintStream err, boolean install) { this.viewFactory = viewFactory; this.install = install; + this.in = in; + this.out = out; + this.err = err; } /** @@ -53,13 +76,15 @@ * @throws Exception */ public final void launch() throws Exception { - ErrorReporter errorReporter = viewFactory.createErrorReporter(); - UserFacade.getInstance().setErrorReporter(errorReporter); + ErrorReporter errorReporter = viewFactory.createErrorReporter(err); + Context context = new Context(in, out, errorReporter); + UserFacade.getInstance().setContext(context); + // CommandProcessor - Object cmdProcessorView = viewFactory.createCommandProcessorView(); + Object cmdProcessorView = viewFactory.createCommandProcessorView(context); // Device - viewFactory.createDeviceView(errorReporter, cmdProcessorView, install); + viewFactory.createDeviceView(context, cmdProcessorView, install); } } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -81,14 +81,14 @@ */ public void doExecute(boolean install, InputStream in, PrintStream out, PrintStream err, boolean consoleView, boolean swingView) throws Exception { ViewFactory viewFactory = - consoleView ? new ConsoleViewFactory(in, out, err) + consoleView ? new ConsoleViewFactory() : swingView ? new SwingViewFactory() : null; if (viewFactory == null) { err.println("No UI selected"); exit(1); } - - JPartition jpartition = new JPartition(viewFactory, install); + + JPartition jpartition = new JPartition(viewFactory, in, out, err, install); jpartition.launch(); } } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,8 @@ package org.jnode.apps.jpartition; +import java.io.PrintStream; + /** * Factory used to build a user interface (text mode, graphical mode ...) for JPartition. * @@ -30,24 +32,27 @@ /** * Creates a view for the devices which might or might not (implementor's choice) * display available devices, their partitions... - * @param errorReporter The error reporter to use (normally created by this factory). + * @param context The {@link Context} to use. * @param cmdProcessorView The command processor view to use (normally created by this factory). * @param install True if we are trying to install jnode, false in other cases. * @return The device view. * @throws Exception */ - Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, boolean install) + Object createDeviceView(Context context, Object cmdProcessorView, boolean install) throws Exception; /** * Creates a command processor view. + * @param context The {@link Context} to use. * @return A new command processor view. */ - Object createCommandProcessorView(); + Object createCommandProcessorView(Context context); /** * Creates an error reporter. + * @param err The error stream to use. * @return A new error reporter. */ - ErrorReporter createErrorReporter(); + ErrorReporter createErrorReporter(PrintStream err); + } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -21,9 +21,9 @@ package org.jnode.apps.jpartition.commands; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.PrintWriter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.BaseCommand; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.ApiNotFoundException; @@ -43,10 +43,9 @@ this.device = device; } - protected final PartitionHelper createPartitionHelper() throws CommandException { + protected final PartitionHelper createPartitionHelper(Context context) throws CommandException { try { - //FIXME replace System.out by output stream from (Console)ViewFactory - return new PartitionHelper(device, new PrintWriter(new OutputStreamWriter(System.out))); + return new PartitionHelper(device, new PrintWriter(context.getOut())); } catch (DeviceNotFoundException e) { throw new CommandException(e); } catch (ApiNotFoundException e) { @@ -56,7 +55,7 @@ } } - protected abstract void doExecute() throws CommandException; + protected abstract void doExecute(Context context) throws CommandException; @Override public String toString() { Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,7 @@ package org.jnode.apps.jpartition.commands; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.bus.ide.IDEDevice; @@ -31,7 +32,7 @@ this.partitionNumber = partitionNumber; } - protected abstract void doExecute() throws CommandException; + protected abstract void doExecute(Context context) throws CommandException; @Override public String toString() { Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,7 @@ package org.jnode.apps.jpartition.commands; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.bus.ide.IDEDevice; @@ -34,7 +35,7 @@ } @Override - protected final void doExecute() throws CommandException { + protected final void doExecute(Context context) throws CommandException { // PartitionHelper helper = createPartitionHelper(); // try { // Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,7 @@ package org.jnode.apps.jpartition.commands; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.bus.ide.IDEDevice; import org.jnode.fs.FileSystem; @@ -35,7 +36,7 @@ } @Override - protected final void doExecute() throws CommandException { + protected final void doExecute(Context context) throws CommandException { // TODO Auto-generated method stub } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,9 +20,7 @@ package org.jnode.apps.jpartition.commands; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.bus.ide.IDEDevice; import org.jnode.partitions.command.PartitionHelper; @@ -34,11 +32,10 @@ } @Override - protected void doExecute() throws CommandException { + protected void doExecute(Context context) throws CommandException { PartitionHelper helper; - try { - //FIXME replace System.out by output stream from (Console)ViewFactory - helper = new PartitionHelper(device, new PrintWriter(new OutputStreamWriter(System.out))); + try { + helper = createPartitionHelper(context); helper.initMbr(); } catch (Throwable t) { throw new CommandException(t); Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/RemovePartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/RemovePartitionCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/RemovePartitionCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,6 +20,7 @@ package org.jnode.apps.jpartition.commands; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.framework.CommandException; import org.jnode.driver.bus.ide.IDEDevice; @@ -30,7 +31,7 @@ } @Override - protected final void doExecute() throws CommandException { + protected final void doExecute(Context context) throws CommandException { // TODO Auto-generated method stub } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/BaseCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/BaseCommand.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/BaseCommand.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -21,6 +21,7 @@ package org.jnode.apps.jpartition.commands.framework; import org.apache.log4j.Logger; +import org.jnode.apps.jpartition.Context; /** * Abstract implementation of the {@link Command} interface. @@ -47,7 +48,7 @@ status = CommandStatus.RUNNING; processor.commandStarted(this); - doExecute(); + doExecute(processor.getContext()); status = CommandStatus.SUCCESS; } catch (CommandException e) { log.error("command failed", e); @@ -67,7 +68,12 @@ return status; } - protected abstract void doExecute() throws CommandException; + /** + * Actually execute the command with the given context. + * @param context The context to use. + * @throws CommandException + */ + protected abstract void doExecute(Context context) throws CommandException; /** * Get a printable representation of the command. Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -25,20 +25,21 @@ import java.util.Stack; import org.apache.log4j.Logger; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.ErrorReporter; public class CommandProcessor { private static final Logger log = Logger.getLogger(CommandProcessor.class); - private final ErrorReporter errorReporter; + private final Context context; private Stack<Command> commands = new Stack<Command>(); private List<CommandProcessorListener> listeners = new ArrayList<CommandProcessorListener>(); private boolean running = false; - public CommandProcessor(ErrorReporter errorReporter) { - this.errorReporter = errorReporter; + public CommandProcessor(Context context) { + this.context = context; } public List<Command> getPendingCommands() { @@ -58,7 +59,7 @@ running = false; } } catch (Throwable t) { - errorReporter.reportError(log, this, t); + context.getErrorReporter().reportError(log, this, t); } } @@ -133,4 +134,11 @@ public void removeListener(CommandProcessorListener listener) { listeners.remove(listener); } + + /** + * @return + */ + public Context getContext() { + return context; + } } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -43,14 +43,14 @@ private final boolean install; private Partition selectedPartition; - ConsoleView(InputStream in, PrintStream out, ErrorReporter errorReporter, boolean install) { - super(new Context(in, out, errorReporter)); + ConsoleView(Context context, boolean install) { + super(context); this.install = install; try { start(); } catch (Throwable e) { - errorReporter.reportError(log, this, e); + context.getErrorReporter().reportError(log, this, e); } println(); Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,9 +20,9 @@ package org.jnode.apps.jpartition.consoleview; -import java.io.InputStream; import java.io.PrintStream; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.ErrorReporter; import org.jnode.apps.jpartition.ViewFactory; @@ -32,27 +32,26 @@ * */ public class ConsoleViewFactory implements ViewFactory { - private final InputStream in; - private final PrintStream out; - private final PrintStream err; - - public ConsoleViewFactory(InputStream in, PrintStream out, PrintStream err) { - this.in = in; - this.out = out; - this.err = err; + public ConsoleViewFactory() { } - public Object createCommandProcessorView() { - return null; // nothing particular to create : work is done by - // createDeviceView + public Object createCommandProcessorView(Context context) { + // nothing particular to create : work is done by createDeviceView + return null; } - public Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, + /** + * {@inheritDoc} + */ + public Object createDeviceView(Context context, Object cmdProcessorView, boolean install) throws Exception { - return new ConsoleView(in, out, errorReporter, install); + return new ConsoleView(context, install); } - public ErrorReporter createErrorReporter() { + /** + * {@inheritDoc} + */ + public ErrorReporter createErrorReporter(PrintStream err) { return new ConsoleErrorReporter(err); } } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserFacade.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserFacade.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserFacade.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -30,7 +30,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.jnode.apps.jpartition.ErrorReporter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.commands.CreatePartitionCommand; import org.jnode.apps.jpartition.commands.FormatPartitionCommand; import org.jnode.apps.jpartition.commands.RemovePartitionCommand; @@ -62,7 +62,8 @@ private final Map<String, Formatter<? extends FileSystem<?>>> formatters = new HashMap<String, Formatter<? extends FileSystem<?>>>(); private Formatter<? extends FileSystem<?>> selectedFormatter; - private ErrorReporter errorReporter; + + private Context context; private CommandProcessor cmdProcessor; @@ -78,9 +79,9 @@ addFormatter(new Ext2FileSystemFormatter(BlockSize._4Kb)); } - public void setErrorReporter(ErrorReporter errorReporter) { - this.errorReporter = errorReporter; - cmdProcessor = new CommandProcessor(errorReporter); + public void setContext(Context context) { + this.context = context; + cmdProcessor = new CommandProcessor(context); } public void selectFormatter(String name) { @@ -122,8 +123,8 @@ } public void errorHappened(OSFacadeException e) { - if (errorReporter != null) { - errorReporter.reportError(LOG, UserFacade.this, e); + if (context.getErrorReporter() != null) { + context.getErrorReporter().reportError(LOG, UserFacade.this, e); } } }; @@ -226,8 +227,8 @@ // not called by user => need to notify selectDevice(selectedDev, true); } catch (OSFacadeException e) { - if (errorReporter != null) { - errorReporter.reportError(LOG, this, e); + if (context.getErrorReporter() != null) { + context.getErrorReporter().reportError(LOG, this, e); } } } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -27,7 +27,7 @@ import javax.swing.Action; import javax.swing.JLabel; -import org.jnode.apps.jpartition.ErrorReporter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.model.Device; import org.jnode.apps.jpartition.model.Partition; import org.jnode.apps.jpartition.model.UserFacade; @@ -36,8 +36,8 @@ public class DeviceView extends DiskAreaView<Device> { private static final long serialVersionUID = 4961328945650444476L; - public DeviceView(ErrorReporter errorReporter) { - super(errorReporter); + public DeviceView(Context context) { + super(context); setLayout(null); update(); @@ -73,7 +73,7 @@ final int space = 1; double x = 0; for (Partition partition : bounded.getPartitions()) { - PartitionView p = new PartitionView(errorReporter, this, partition); + PartitionView p = new PartitionView(context, this, partition); double size = pixelsPerByte * partition.getSize(); p.setBounds((int) x + space, 0 + space, (int) size - 2 * space, getHeight() - 2 * Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DiskAreaView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DiskAreaView.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DiskAreaView.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -22,6 +22,7 @@ import java.awt.Color; import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -32,24 +33,22 @@ import javax.swing.JPopupMenu; import javax.swing.border.Border; -import org.jnode.apps.jpartition.ErrorReporter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.model.Bounded; -import java.awt.Rectangle; - public abstract class DiskAreaView<T extends Bounded> extends JComponent { private static final long serialVersionUID = -506634580666065291L; private final int DEFAULT_PIXELS_PER_BYTE = 1; protected final int borderWidth = 5; - protected final ErrorReporter errorReporter; + protected final Context context; protected T bounded; protected double pixelsPerByte = DEFAULT_PIXELS_PER_BYTE; - public DiskAreaView(ErrorReporter errorReporter) { - this.errorReporter = errorReporter; + public DiskAreaView(Context context) { + this.context = context; setLayout(null); setOpaque(true); Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/MainView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/MainView.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/MainView.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -31,7 +31,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import org.jnode.apps.jpartition.ErrorReporter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.model.Device; import org.jnode.apps.jpartition.model.UserFacade; import org.jnode.apps.jpartition.model.UserListener; @@ -42,14 +42,14 @@ private final DefaultComboBoxModel devices; private final DeviceView deviceView; - public MainView(ErrorReporter errorReporter, JComponent cmdProcessorView) throws Exception { + public MainView(Context context, JComponent cmdProcessorView) throws Exception { setTitle("JPartition"); setLayout(new BorderLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(cmdProcessorView, BorderLayout.SOUTH); - deviceView = new DeviceView(errorReporter); + deviceView = new DeviceView(context); add(deviceView, BorderLayout.CENTER); devices = new DefaultComboBoxModel(UserFacade.getInstance().getDeviceNames()); Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -28,7 +28,7 @@ import javax.swing.Action; import javax.swing.BorderFactory; -import org.jnode.apps.jpartition.ErrorReporter; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.model.Partition; import org.jnode.apps.jpartition.model.UserFacade; import org.jnode.apps.jpartition.swingview.actions.AddPartitionAction; @@ -41,8 +41,8 @@ private PartitionState state = new IdleState(); - public PartitionView(ErrorReporter errorReporter, DeviceView deviceView, Partition partition) { - super(errorReporter); + public PartitionView(Context context, DeviceView deviceView, Partition partition) { + super(context); this.deviceView = deviceView; this.bounded = partition; update(); @@ -119,10 +119,10 @@ Action[] actions; if (bounded.isUsed()) { actions = - new Action[] {new FormatPartitionAction(errorReporter, this), - new RemovePartitionAction(errorReporter, this), }; + new Action[] {new FormatPartitionAction(context.getErrorReporter(), this), + new RemovePartitionAction(context.getErrorReporter(), this), }; } else { - actions = new Action[] {new AddPartitionAction(errorReporter, this), }; + actions = new Action[] {new AddPartitionAction(context.getErrorReporter(), this), }; } return actions; } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/SwingViewFactory.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/SwingViewFactory.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/SwingViewFactory.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,22 +20,31 @@ package org.jnode.apps.jpartition.swingview; +import java.io.PrintStream; + import javax.swing.JComponent; +import org.jnode.apps.jpartition.Context; import org.jnode.apps.jpartition.ErrorReporter; import org.jnode.apps.jpartition.ViewFactory; public class SwingViewFactory implements ViewFactory { - public Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, + public Object createDeviceView(Context context, Object cmdProcessorView, boolean install) throws Exception { - return new MainView(errorReporter, (JComponent) cmdProcessorView); + return new MainView(context, (JComponent) cmdProcessorView); } - public Object createCommandProcessorView() { + /** + * {@inheritDoc} + */ + public Object createCommandProcessorView(Context context) { return new CommandProcessorView(); } - public ErrorReporter createErrorReporter() { + /** + * {@inheritDoc} + */ + public ErrorReporter createErrorReporter(PrintStream err) { return new SwingErrorReporter(); } } Modified: trunk/distr/src/test/org/jnode/apps/jpartition/JPartitionTest.java =================================================================== --- trunk/distr/src/test/org/jnode/apps/jpartition/JPartitionTest.java 2009-05-02 01:44:40 UTC (rev 5382) +++ trunk/distr/src/test/org/jnode/apps/jpartition/JPartitionTest.java 2009-05-02 10:29:31 UTC (rev 5383) @@ -20,7 +20,9 @@ package org.jnode.apps.jpartition; +import java.io.InputStream; import java.io.OutputStreamWriter; +import java.io.PrintStream; import java.io.PrintWriter; import junit.framework.TestSuite; @@ -30,8 +32,6 @@ import org.jnode.apps.jpartition.model.TestNonEmptyDevice; import org.jnode.apps.jpartition.model.TestOSFacade; import org.jnode.apps.jpartition.model.TestRemovePartitionFromDevice; -import org.jnode.apps.jpartition.swingview.FileDeviceView; -import org.jnode.apps.jpartition.utils.device.AbstractIDEDevice; import org.jnode.apps.jpartition.utils.device.DeviceUtils; import org.jnode.driver.bus.ide.IDEDevice; import org.jnode.fs.jfat.command.JGrub; @@ -62,9 +62,12 @@ * @throws Throwable */ public static void main(String[] args) throws Throwable { + InputStream in = System.in; + PrintStream out = System.out; + PrintStream err = System.err; - final ViewFactory vf = new ConsoleViewFactory(System.in, System.out, System.err); - final ErrorReporter errorReporter = vf.createErrorReporter(); + final ViewFactory vf = new ConsoleViewFactory(); + final ErrorReporter errorReporter = vf.createErrorReporter(err); /* final Thread t = new Thread() { public void run() { @@ -83,6 +86,6 @@ // jgrub.install(); - new JPartitionCommand().doExecute(true, System.in, System.out, System.err, true, false); + new JPartitionCommand().doExecute(true, in, out, err, true, false); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |