|
From: <fd...@us...> - 2008-06-15 19:35:58
|
Revision: 4252
http://jnode.svn.sourceforge.net/jnode/?rev=4252&view=rev
Author: fduminy
Date: 2008-06-15 12:35:53 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
checkstyle fixes
Modified Paths:
--------------
trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java
trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java
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/Command.java
trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandException.java
trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java
trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessorListener.java
trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandStatus.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleErrorReporter.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/consoleview/DeviceLabelizer.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/PartitionLabelizer.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Component.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Labelizer.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/NumberField.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Options.java
trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/YesNo.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/Bounded.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/Device.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/DeviceException.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/OSFacade.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/OSFacadeException.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/OSListener.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/Partition.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserFacade.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/UserListener.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/CommandProcessorView.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/Constants.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/SwingErrorReporter.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/SwingViewFactory.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/actions/AbstractAction.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/actions/AddPartitionAction.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/actions/FormatPartitionAction.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/actions/InitMbrAction.java
trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/actions/RemovePartitionAction.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/ExtentDeclaration.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/IOUtils.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/RandomAccessFileReader.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/VMWareDisk.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/AdapterType.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/CreateType.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/Descriptor.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/DescriptorRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/DiskDatabase.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/Header.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Access.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Extent.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/ExtentType.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/ExtentFactory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/ExtentIO.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/FileDescriptor.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/IOHandler.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/UnsupportedFormatException.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleDescriptorRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleExtentFactory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleIOHandler.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTable.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTableRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/EntryArray.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainDirectory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainTable.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseDescriptorRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseDiskFactory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtent.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtentFactory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtentHeader.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtentHeaderRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtentIO.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseExtentRW.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseFileDescriptor.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseIOHandler.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/tools/DiskCopier.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/tools/DiskFactory.java
trunk/distr/src/test/org/jnode/apps/jpartition/JPartitionTest.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/AbstractTest.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/AbstractTestDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/CustomDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/TestEmptyDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/TestNonEmptyDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/TestOSFacade.java
trunk/distr/src/test/org/jnode/apps/jpartition/model/TestRemovePartitionFromDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/swingview/FileDeviceView.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/BasicNameSpace.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/AbstractIDEDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/FakeIDEDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/FileIDEDevice.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/FileIDEDeviceDriver.java
trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/VMWareIDEDevice.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/BaseTest.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/TestCreation.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/Utils.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/readwrite/BaseReadWriteTest.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/readwrite/TestHeader.java
trunk/distr/src/test/org/jnode/apps/vmware/disk/test/readwrite/TestVMWareDisk.java
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -5,30 +5,28 @@
import java.io.InputStreamReader;
import java.io.PrintStream;
-
public class Context {
- private final BufferedReader in;
- private final PrintStream out;
- private final ErrorReporter errorReporter;
-
- public Context(InputStream in, PrintStream out, ErrorReporter errorReporter)
- {
- InputStreamReader r = new InputStreamReader(in);
- this.in = new BufferedReader(r);
-
- this.out = out;
- this.errorReporter = errorReporter;
- }
+ private final BufferedReader in;
+ private final PrintStream out;
+ private final ErrorReporter errorReporter;
- final public PrintStream getOut() {
- return out;
- }
+ public Context(InputStream in, PrintStream out, ErrorReporter errorReporter) {
+ InputStreamReader r = new InputStreamReader(in);
+ this.in = new BufferedReader(r);
- final public BufferedReader getIn() {
- return in;
- }
+ this.out = out;
+ this.errorReporter = errorReporter;
+ }
- final public ErrorReporter getErrorReporter() {
- return errorReporter;
- }
+ public final PrintStream getOut() {
+ return out;
+ }
+
+ public final BufferedReader getIn() {
+ return in;
+ }
+
+ public final ErrorReporter getErrorReporter() {
+ return errorReporter;
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -3,38 +3,30 @@
import org.apache.log4j.Logger;
public class ErrorReporter {
- final public void reportError(Logger log, Object source, Throwable t)
- {
- reportError(log, source, (Object) t);
- }
+ public final void reportError(Logger log, Object source, Throwable t) {
+ reportError(log, source, (Object) t);
+ }
- final public void reportError(Logger log, Object source, String message)
- {
- reportError(log, source, (Object) message);
- }
+ public final void reportError(Logger log, Object source, String message) {
+ reportError(log, source, (Object) message);
+ }
- protected void displayError(Object source, String message)
- {
- // by default display nothing
- }
+ protected void displayError(Object source, String message) {
+ // by default display nothing
+ }
- final private void reportError(Logger log, Object source, Object message)
- {
- Throwable t = (message instanceof Throwable) ? (Throwable) message : null;
+ private final void reportError(Logger log, Object source, Object message) {
+ Throwable t = (message instanceof Throwable) ? (Throwable) message : null;
- String msg = (t == null) ? String.valueOf(message) : t.getMessage();
- displayError(source, msg);
+ String msg = (t == null) ? String.valueOf(message) : t.getMessage();
+ displayError(source, msg);
- if(log != null)
- {
- if(t != null)
- {
- log.error(msg, t);
- }
- else
- {
- log.error(msg);
- }
- }
- }
+ if (log != null) {
+ if (t != null) {
+ log.error(msg, t);
+ } else {
+ log.error(msg);
+ }
+ }
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -3,24 +3,22 @@
import org.jnode.apps.jpartition.model.UserFacade;
public class JPartition {
- final private ViewFactory viewFactory;
- final private boolean install;
+ private final ViewFactory viewFactory;
+ private final boolean install;
- public JPartition(ViewFactory viewFactory, boolean install)
- {
- this.viewFactory = viewFactory;
- this.install = install;
- }
+ public JPartition(ViewFactory viewFactory, boolean install) {
+ this.viewFactory = viewFactory;
+ this.install = install;
+ }
- public final void launch() throws Exception
- {
- ErrorReporter errorReporter = viewFactory.createErrorReporter();
- UserFacade.getInstance().setErrorReporter(errorReporter);
+ public final void launch() throws Exception {
+ ErrorReporter errorReporter = viewFactory.createErrorReporter();
+ UserFacade.getInstance().setErrorReporter(errorReporter);
// CommandProcessor
Object cmdProcessorView = viewFactory.createCommandProcessorView();
// Device
viewFactory.createDeviceView(errorReporter, cmdProcessorView, install);
- }
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -10,34 +10,32 @@
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FlagArgument;
-
public class JPartitionCommand extends AbstractCommand {
- private final FlagArgument FLAG_SWING =
- new FlagArgument("swing", Argument.OPTIONAL, "if set, use the Swing (graphic) UI");
-
- private final FlagArgument FLAG_CONSOLE =
- new FlagArgument("console", Argument.OPTIONAL, "if set, use the console (text) UI");
+ private final FlagArgument FLAG_SWING =
+ new FlagArgument("swing", Argument.OPTIONAL, "if set, use the Swing (graphic) UI");
- private final FlagArgument ARG_INSTALL = new FlagArgument(
- "install", Argument.OPTIONAL, "if set, format the partition(s)");
-
- public JPartitionCommand() {
+ private final FlagArgument FLAG_CONSOLE =
+ new FlagArgument("console", Argument.OPTIONAL, "if set, use the console (text) UI");
+
+ private final FlagArgument ARG_INSTALL =
+ new FlagArgument("install", Argument.OPTIONAL, "if set, format the partition(s)");
+
+ public JPartitionCommand() {
super("interactive disk partitioning tool");
registerArguments(FLAG_CONSOLE, FLAG_SWING, ARG_INSTALL);
}
- public static void main(String[] args) throws Exception {
- new JPartitionCommand().execute(args);
- }
+ public static void main(String[] args) throws Exception {
+ new JPartitionCommand().execute(args);
+ }
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err)
- throws Exception {
+ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ throws Exception {
boolean install = ARG_INSTALL.isSet();
- ViewFactory viewFactory = FLAG_CONSOLE.isSet() ?
- new ConsoleViewFactory(in, out, err) :
- FLAG_SWING.isSet() ? new SwingViewFactory() : null;
+ ViewFactory viewFactory =
+ FLAG_CONSOLE.isSet() ? new ConsoleViewFactory(in, out, err)
+ : FLAG_SWING.isSet() ? new SwingViewFactory() : null;
if (viewFactory == null) {
err.println("No UI selected");
exit(1);
@@ -45,5 +43,5 @@
JPartition jpartition = new JPartition(viewFactory, install);
jpartition.launch();
- }
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -1,11 +1,10 @@
package org.jnode.apps.jpartition;
-
public interface ViewFactory {
- Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, boolean install)
- throws Exception;
+ Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, boolean install)
+ throws Exception;
- Object createCommandProcessorView();
+ Object createCommandProcessorView();
- ErrorReporter createErrorReporter();
+ ErrorReporter createErrorReporter();
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -9,37 +9,34 @@
import org.jnode.driver.bus.ide.IDEDevice;
import org.jnode.partitions.command.PartitionHelper;
-abstract public class BaseDeviceCommand extends BaseCommand {
- protected final IDEDevice device;
+public abstract class BaseDeviceCommand extends BaseCommand {
+ protected final IDEDevice device;
- public BaseDeviceCommand(String name, IDEDevice device)
- {
- super(name);
- if(device == null)
- {
- throw new NullPointerException("device is null");
- }
+ public BaseDeviceCommand(String name, IDEDevice device) {
+ super(name);
+ if (device == null) {
+ throw new NullPointerException("device is null");
+ }
- this.device = device;
- }
-
- final protected PartitionHelper createPartitionHelper() throws CommandException
- {
- try {
- return new PartitionHelper(device);
- } catch (DeviceNotFoundException e) {
- throw new CommandException(e);
- } catch (ApiNotFoundException e) {
- throw new CommandException(e);
- } catch (IOException e) {
- throw new CommandException(e);
- }
- }
+ this.device = device;
+ }
- abstract protected void doExecute() throws CommandException;
+ protected final PartitionHelper createPartitionHelper() throws CommandException {
+ try {
+ return new PartitionHelper(device);
+ } catch (DeviceNotFoundException e) {
+ throw new CommandException(e);
+ } catch (ApiNotFoundException e) {
+ throw new CommandException(e);
+ } catch (IOException e) {
+ throw new CommandException(e);
+ }
+ }
- @Override
- public String toString() {
- return super.toString() + " - " + device.getId();
- }
+ protected abstract void doExecute() throws CommandException;
+
+ @Override
+ public String toString() {
+ return super.toString() + " - " + device.getId();
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BasePartitionCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -3,19 +3,18 @@
import org.jnode.apps.jpartition.commands.framework.CommandException;
import org.jnode.driver.bus.ide.IDEDevice;
-abstract public class BasePartitionCommand extends BaseDeviceCommand {
- protected final int partitionNumber;
+public abstract class BasePartitionCommand extends BaseDeviceCommand {
+ protected final int partitionNumber;
- public BasePartitionCommand(String name, IDEDevice device, int partitionNumber)
- {
- super(name, device);
- this.partitionNumber = partitionNumber;
- }
+ public BasePartitionCommand(String name, IDEDevice device, int partitionNumber) {
+ super(name, device);
+ this.partitionNumber = partitionNumber;
+ }
- abstract protected void doExecute() throws CommandException;
+ protected abstract void doExecute() throws CommandException;
- @Override
- public String toString() {
- return super.toString() + " - partition " + partitionNumber;
- }
+ @Override
+ public String toString() {
+ return super.toString() + " - partition " + partitionNumber;
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/CreatePartitionCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -4,28 +4,29 @@
import org.jnode.driver.bus.ide.IDEDevice;
public class CreatePartitionCommand extends BasePartitionCommand {
- final private long start;
- final private long size;
+ private final long start;
+ private final long size;
- public CreatePartitionCommand(IDEDevice device, int partitionNumber, long start, long size) {
- super("create partition", device, partitionNumber);
- this.start = start;
- this.size = size;
- }
+ public CreatePartitionCommand(IDEDevice device, int partitionNumber, long start, long size) {
+ super("create partition", device, partitionNumber);
+ this.start = start;
+ this.size = size;
+ }
- @Override
- final protected void doExecute() throws CommandException {
-// PartitionHelper helper = createPartitionHelper();
-// try {
-//
-// helper.write();
-// } catch (IOException e) {
-// throw new CommandException(e);
-// }
- }
+ @Override
+ protected final void doExecute() throws CommandException {
+ // PartitionHelper helper = createPartitionHelper();
+ // try {
+ //
+ // helper.write();
+ // } catch (IOException e) {
+ // throw new CommandException(e);
+ // }
+ }
- @Override
- public String toString() {
- return "create partition [" + start + ", " + (start+size-1) + "] on device " + device.getId();
- }
+ @Override
+ public String toString() {
+ return "create partition [" + start + ", " + (start + size - 1) + "] on device " +
+ device.getId();
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/FormatPartitionCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -6,20 +6,22 @@
import org.jnode.fs.Formatter;
public class FormatPartitionCommand extends BasePartitionCommand {
- private final Formatter<? extends FileSystem<?>> formatter;
+ private final Formatter<? extends FileSystem<?>> formatter;
- public FormatPartitionCommand(IDEDevice device, int partitionNumber, Formatter<? extends FileSystem<?>> formatter) {
- super("format partition", device, partitionNumber);
- this.formatter = formatter;
- }
+ public FormatPartitionCommand(IDEDevice device, int partitionNumber,
+ Formatter<? extends FileSystem<?>> formatter) {
+ super("format partition", device, partitionNumber);
+ this.formatter = formatter;
+ }
- @Override
- final protected void doExecute() throws CommandException {
- // TODO Auto-generated method stub
- }
+ @Override
+ protected final void doExecute() throws CommandException {
+ // TODO Auto-generated method stub
+ }
- @Override
- public String toString() {
- return "format partition " + partitionNumber + " on device " + device.getId() + " with " + formatter.getFileSystemType().getName();
- }
+ @Override
+ public String toString() {
+ return "format partition " + partitionNumber + " on device " + device.getId() + " with " +
+ formatter.getFileSystemType().getName();
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -6,18 +6,18 @@
public class InitMbrCommand extends BaseDeviceCommand {
- public InitMbrCommand(IDEDevice device) {
- super("init MBR", device);
- }
+ public InitMbrCommand(IDEDevice device) {
+ super("init MBR", device);
+ }
- @Override
- protected void doExecute() throws CommandException {
- PartitionHelper helper;
- try {
- helper = new PartitionHelper(device);
- helper.initMbr();
- } catch (Throwable t) {
- throw new CommandException(t);
- }
- }
+ @Override
+ protected void doExecute() throws CommandException {
+ PartitionHelper helper;
+ try {
+ helper = new PartitionHelper(device);
+ 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 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/RemovePartitionCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -5,18 +5,18 @@
public class RemovePartitionCommand extends BasePartitionCommand {
- public RemovePartitionCommand(IDEDevice device, int partitionNumber) {
- super("remove partition", device, partitionNumber);
- }
+ public RemovePartitionCommand(IDEDevice device, int partitionNumber) {
+ super("remove partition", device, partitionNumber);
+ }
- @Override
- final protected void doExecute() throws CommandException {
- // TODO Auto-generated method stub
- }
-
- @Override
- public String toString() {
- return "remove partition " + partitionNumber + " on device" + device.getId();
- }
-
+ @Override
+ protected final void doExecute() throws CommandException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public String toString() {
+ return "remove partition " + partitionNumber + " on device" + device.getId();
+ }
+
}
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 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/BaseCommand.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -2,51 +2,42 @@
import org.apache.log4j.Logger;
-abstract public class BaseCommand implements Command
-{
- private static final Logger log = Logger.getLogger(BaseCommand.class);
+public abstract class BaseCommand implements Command {
+ private static final Logger log = Logger.getLogger(BaseCommand.class);
- private CommandStatus status = CommandStatus.NOT_RUNNING;
- final private String name;
+ private CommandStatus status = CommandStatus.NOT_RUNNING;
+ private final String name;
- protected BaseCommand(String name)
- {
- this.name = name;
- }
+ protected BaseCommand(String name) {
+ this.name = name;
+ }
- final public void execute(CommandProcessor processor) throws CommandException
- {
- try
- {
- status = CommandStatus.RUNNING;
- processor.commandStarted(this);
+ public final void execute(CommandProcessor processor) throws CommandException {
+ try {
+ status = CommandStatus.RUNNING;
+ processor.commandStarted(this);
- doExecute();
- status = CommandStatus.SUCCESS;
- }
- catch(CommandException e)
- {
- log.error("command failed", e);
- status = CommandStatus.FAILED;
- throw e;
- }
- catch(Throwable t)
- {
- log.error("command failed", t);
- status = CommandStatus.FAILED;
- throw new CommandException("command failed", t);
- }
- }
+ doExecute();
+ status = CommandStatus.SUCCESS;
+ } catch (CommandException e) {
+ log.error("command failed", e);
+ status = CommandStatus.FAILED;
+ throw e;
+ } catch (Throwable t) {
+ log.error("command failed", t);
+ status = CommandStatus.FAILED;
+ throw new CommandException("command failed", t);
+ }
+ }
- final public CommandStatus getStatus()
- {
- return status;
- }
+ public final CommandStatus getStatus() {
+ return status;
+ }
- abstract protected void doExecute() throws CommandException;
+ protected abstract void doExecute() throws CommandException;
- @Override
- public String toString() {
- return status + " - " + name;
- }
+ @Override
+ public String toString() {
+ return status + " - " + name;
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/Command.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/Command.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/Command.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -1,6 +1,7 @@
package org.jnode.apps.jpartition.commands.framework;
public interface Command {
- public void execute(CommandProcessor processor) throws CommandException;
- public CommandStatus getStatus();
+ public void execute(CommandProcessor processor) throws CommandException;
+
+ public CommandStatus getStatus();
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandException.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandException.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandException.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -1,18 +1,18 @@
package org.jnode.apps.jpartition.commands.framework;
public class CommandException extends Exception {
- private static final long serialVersionUID = -8340890789850970389L;
+ private static final long serialVersionUID = -8340890789850970389L;
- public CommandException(String s, Throwable cause) {
- super(s, cause);
- }
+ public CommandException(String s, Throwable cause) {
+ super(s, cause);
+ }
- public CommandException(String s) {
- super(s);
- }
+ public CommandException(String s) {
+ super(s);
+ }
- public CommandException(Throwable cause) {
- super(cause);
- }
+ public CommandException(Throwable cause) {
+ super(cause);
+ }
}
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 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessor.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -7,142 +7,110 @@
import org.apache.log4j.Logger;
import org.jnode.apps.jpartition.ErrorReporter;
-public class CommandProcessor
-{
- private static final Logger log = Logger.getLogger(CommandProcessor.class);
+public class CommandProcessor {
+ private static final Logger log = Logger.getLogger(CommandProcessor.class);
- private final ErrorReporter errorReporter;
+ private final ErrorReporter errorReporter;
- private Stack<Command> commands = new Stack<Command>();
- private List<CommandProcessorListener> listeners = new ArrayList<CommandProcessorListener>();
+ private Stack<Command> commands = new Stack<Command>();
+ private List<CommandProcessorListener> listeners = new ArrayList<CommandProcessorListener>();
- private boolean running = false;
+ private boolean running = false;
- public CommandProcessor(ErrorReporter errorReporter)
- {
- this.errorReporter = errorReporter;
- }
+ public CommandProcessor(ErrorReporter errorReporter) {
+ this.errorReporter = errorReporter;
+ }
- public List<Command> getPendingCommands()
- {
- return new ArrayList<Command>(commands);
- }
+ public List<Command> getPendingCommands() {
+ return new ArrayList<Command>(commands);
+ }
- public synchronized void process()
- {
- try
- {
- if(!running)
- {
- running = true;
+ public synchronized void process() {
+ try {
+ if (!running) {
+ running = true;
- boolean quit = false;
- while(!commands.isEmpty() && !quit)
- {
- quit = processCommand();
- }
+ boolean quit = false;
+ while (!commands.isEmpty() && !quit) {
+ quit = processCommand();
+ }
- running = false;
- }
- }
- catch(Throwable t)
- {
- errorReporter.reportError(log, this, t);
- }
- }
+ running = false;
+ }
+ } catch (Throwable t) {
+ errorReporter.reportError(log, this, t);
+ }
+ }
- private boolean processCommand()
- {
- boolean quit = false;
- Command command = null;
- try
- {
- command = peekCommand();
+ private boolean processCommand() {
+ boolean quit = false;
+ Command command = null;
+ try {
+ command = peekCommand();
- command.execute(this);
- }
- catch(CommandException e)
- {
- log.error("error in command processing", e);
- quit = true;
- }
- catch(Throwable t)
- {
- log.error("unexpected error in command processing", t);
- quit = true;
- }
- finally
- {
- if(command != null)
- {
- for(CommandProcessorListener l : listeners)
- {
- l.commandFinished(this, command);
- }
+ command.execute(this);
+ } catch (CommandException e) {
+ log.error("error in command processing", e);
+ quit = true;
+ } catch (Throwable t) {
+ log.error("unexpected error in command processing", t);
+ quit = true;
+ } finally {
+ if (command != null) {
+ for (CommandProcessorListener l : listeners) {
+ l.commandFinished(this, command);
+ }
- try {
- removeCommand();
- }
- catch(Throwable t)
- {
- log.error("error in removeCommand", t);
- }
- }
- }
+ try {
+ removeCommand();
+ } catch (Throwable t) {
+ log.error("error in removeCommand", t);
+ }
+ }
+ }
- return quit;
- }
+ return quit;
+ }
- public void addCommand(Command command)
- {
- if(command.getStatus() != CommandStatus.NOT_RUNNING)
- {
- throw new IllegalArgumentException("command must be in status NOT_RUNNING");
- }
+ public void addCommand(Command command) {
+ if (command.getStatus() != CommandStatus.NOT_RUNNING) {
+ throw new IllegalArgumentException("command must be in status NOT_RUNNING");
+ }
- commands.push(command);
+ commands.push(command);
- for(CommandProcessorListener l : listeners)
- {
- l.commandAdded(this, command);
- }
- }
+ for (CommandProcessorListener l : listeners) {
+ l.commandAdded(this, command);
+ }
+ }
- protected Command peekCommand() throws Exception
- {
- Command command = commands.peek();
- if(command.getStatus() != CommandStatus.NOT_RUNNING)
- {
- throw new Exception("command already started : "+command);
- }
- return command;
- }
+ protected Command peekCommand() throws Exception {
+ Command command = commands.peek();
+ if (command.getStatus() != CommandStatus.NOT_RUNNING) {
+ throw new Exception("command already started : " + command);
+ }
+ return command;
+ }
- protected void removeCommand()
- {
- Command command = commands.pop();
+ protected void removeCommand() {
+ Command command = commands.pop();
- for(CommandProcessorListener l : listeners)
- {
- l.commandRemoved(this, command);
- }
- }
+ for (CommandProcessorListener l : listeners) {
+ l.commandRemoved(this, command);
+ }
+ }
- public void commandStarted(Command command)
- {
- for(CommandProcessorListener l : listeners)
- {
- l.commandStarted(this, command);
- }
- }
+ public void commandStarted(Command command) {
+ for (CommandProcessorListener l : listeners) {
+ l.commandStarted(this, command);
+ }
+ }
- public void addListener(CommandProcessorListener listener)
- {
- listeners.add(listener);
- }
+ public void addListener(CommandProcessorListener listener) {
+ listeners.add(listener);
+ }
- public void removeListener(CommandProcessorListener listener)
- {
- listeners.remove(listener);
- }
+ public void removeListener(CommandProcessorListener listener) {
+ listeners.remove(listener);
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessorListener.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessorListener.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandProcessorListener.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -1,8 +1,11 @@
package org.jnode.apps.jpartition.commands.framework;
public interface CommandProcessorListener {
- void commandAdded(CommandProcessor processor, Command command);
- void commandRemoved(CommandProcessor processor, Command command);
- void commandStarted(CommandProcessor processor, Command command);
- void commandFinished(CommandProcessor processor, Command command);
+ void commandAdded(CommandProcessor processor, Command command);
+
+ void commandRemoved(CommandProcessor processor, Command command);
+
+ void commandStarted(CommandProcessor processor, Command command);
+
+ void commandFinished(CommandProcessor processor, Command command);
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandStatus.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandStatus.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/framework/CommandStatus.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -1,19 +1,15 @@
package org.jnode.apps.jpartition.commands.framework;
public enum CommandStatus {
- NOT_RUNNING("not running"),
- RUNNING("running"),
- SUCCESS("success"),
- FAILED("failed");
-
-
- private final String name;
- private CommandStatus(String name)
- {
- this.name = name;
- }
-
- final public String toString(){
- return name;
- }
+ NOT_RUNNING("not running"), RUNNING("running"), SUCCESS("success"), FAILED("failed");
+
+ private final String name;
+
+ private CommandStatus(String name) {
+ this.name = name;
+ }
+
+ public final String toString() {
+ return name;
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleErrorReporter.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleErrorReporter.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleErrorReporter.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -7,24 +7,21 @@
/**
*
* @author Fabien Duminy
- *
+ *
*/
class ConsoleErrorReporter extends ErrorReporter {
- private final PrintStream err;
-
- ConsoleErrorReporter(PrintStream err)
- {
- this.err = err;
- }
-
- protected void displayError(Object source, String message)
- {
- StringBuilder sb = new StringBuilder();
- if(source != null)
- {
- sb.append('[').append(String.valueOf(source)).append("] ");
- }
- sb.append(message);
- err.println(sb.toString());
- }
+ private final PrintStream err;
+
+ ConsoleErrorReporter(PrintStream err) {
+ this.err = err;
+ }
+
+ protected void displayError(Object source, String message) {
+ StringBuilder sb = new StringBuilder();
+ if (source != null) {
+ sb.append('[').append(String.valueOf(source)).append("] ");
+ }
+ sb.append(message);
+ err.println(sb.toString());
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleView.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -18,185 +18,166 @@
import org.jnode.apps.jpartition.model.UserFacade;
class ConsoleView extends Component {
- private static final Logger log = Logger.getLogger(ConsoleView.class);
+ private static final Logger log = Logger.getLogger(ConsoleView.class);
- private final boolean install;
- private Partition selectedPartition;
+ private final boolean install;
+ private Partition selectedPartition;
- ConsoleView(InputStream in, PrintStream out, ErrorReporter errorReporter, boolean install)
- {
- super(new Context(in, out, errorReporter));
- this.install = install;
+ ConsoleView(InputStream in, PrintStream out, ErrorReporter errorReporter, boolean install) {
+ super(new Context(in, out, errorReporter));
+ this.install = install;
- try {
- start();
- } catch (Throwable e) {
- errorReporter.reportError(log, this, e);
- }
+ try {
+ start();
+ } catch (Throwable e) {
+ errorReporter.reportError(log, this, e);
+ }
- println();
+ println();
- if(selectedPartition == null)
- {
- print("selectedPartition=none");
- }
- else
- {
- print("selectedPartition="+PartitionLabelizer.INSTANCE.getLabel(selectedPartition));
- }
+ if (selectedPartition == null) {
+ print("selectedPartition=none");
+ } else {
+ print("selectedPartition=" + PartitionLabelizer.INSTANCE.getLabel(selectedPartition));
+ }
- if(UserFacade.getInstance().getSelectedDevice() == null)
- {
- println(" on no device");
- }
- else
- {
- println(" on device "+DeviceLabelizer.INSTANCE.getLabel(UserFacade.getInstance().getSelectedDevice()));
- }
- }
+ if (UserFacade.getInstance().getSelectedDevice() == null) {
+ println(" on no device");
+ } else {
+ println(" on device " +
+ DeviceLabelizer.INSTANCE.getLabel(UserFacade.getInstance().getSelectedDevice()));
+ }
+ }
- private void start() throws Exception
- {
- if(!selectDevice())
- {
- println("no device to partition");
- return;
- }
+ private void start() throws Exception {
+ if (!selectDevice()) {
+ println("no device to partition");
+ return;
+ }
- if(!UserFacade.getInstance().getSelectedDevice().hasPartititionTable())
- {
- println("device has no partition table");
- return;
- }
+ if (!UserFacade.getInstance().getSelectedDevice().hasPartititionTable()) {
+ println("device has no partition table");
+ return;
+ }
- selectPartition();
+ selectPartition();
- List<Command> pendingCommands = UserFacade.getInstance().getPendingCommands();
- if(!pendingCommands.isEmpty())
- {
- YesNo yesNo = new YesNo(context);
- println();
- println("The following modifications are pending :");
- for(Command cmd : pendingCommands)
- {
- println("\t"+cmd);
- }
+ List<Command> pendingCommands = UserFacade.getInstance().getPendingCommands();
+ if (!pendingCommands.isEmpty()) {
+ YesNo yesNo = new YesNo(context);
+ println();
+ println("The following modifications are pending :");
+ for (Command cmd : pendingCommands) {
+ println("\t" + cmd);
+ }
- boolean apply = yesNo.show("Would you like to apply them ?");
- if(apply)
- {
- UserFacade.getInstance().applyChanges();
- }
- }
- }
+ boolean apply = yesNo.show("Would you like to apply them ?");
+ if (apply) {
+ UserFacade.getInstance().applyChanges();
+ }
+ }
+ }
- private boolean selectDevice() throws IOException
- {
- boolean deviceSelected = false;
+ private boolean selectDevice() throws IOException {
+ boolean deviceSelected = false;
- List<Device> devices = UserFacade.getInstance().getDevices();
- if((devices != null) && !devices.isEmpty())
- {
- Options devicesOpt = new Options(context);
- int choice = (int) devicesOpt.show("Select a device", devices, DeviceLabelizer.INSTANCE);
+ List<Device> devices = UserFacade.getInstance().getDevices();
+ if ((devices != null) && !devices.isEmpty()) {
+ Options devicesOpt = new Options(context);
+ int choice =
+ (int) devicesOpt.show("Select a device", devices, DeviceLabelizer.INSTANCE);
- String device = devices.get(choice - 1).getName();
- UserFacade.getInstance().selectDevice(device);
- println("device="+device);
- deviceSelected = true;
- }
+ String device = devices.get(choice - 1).getName();
+ UserFacade.getInstance().selectDevice(device);
+ println("device=" + device);
+ deviceSelected = true;
+ }
- return deviceSelected;
- }
+ return deviceSelected;
+ }
- private void selectPartition() throws Exception
- {
- List<Partition> partitions = UserFacade.getInstance().getPartitions();
- if((partitions.size() == 1) && !partitions.get(0).isUsed())
- {
- YesNo yesNo = new YesNo(context);
- boolean create = yesNo.show("There is no partition. Would you like to create one ?");
- if(create)
- {
- selectedPartition = createPartition(partitions.get(0));
- }
- }
+ private void selectPartition() throws Exception {
+ List<Partition> partitions = UserFacade.getInstance().getPartitions();
+ if ((partitions.size() == 1) && !partitions.get(0).isUsed()) {
+ YesNo yesNo = new YesNo(context);
+ boolean create = yesNo.show("There is no partition. Would you like to create one ?");
+ if (create) {
+ selectedPartition = createPartition(partitions.get(0));
+ }
+ }
- if(selectedPartition == null)
- {
- partitions = UserFacade.getInstance().getPartitions();
+ if (selectedPartition == null) {
+ partitions = UserFacade.getInstance().getPartitions();
- Options partitionsOpt = new Options(context);
- int choice = (int) partitionsOpt.show("Select a partition", partitions, PartitionLabelizer.INSTANCE);
+ Options partitionsOpt = new Options(context);
+ int choice =
+ (int) partitionsOpt.show("Select a partition", partitions,
+ PartitionLabelizer.INSTANCE);
- selectedPartition = partitions.get(choice - 1);
- }
+ selectedPartition = partitions.get(choice - 1);
+ }
- if(selectedPartition != null)
- {
- if(install)
- {
- formatPartition(selectedPartition);
- }
- else
- {
- modifyPartition(selectedPartition);
- }
- }
- }
+ if (selectedPartition != null) {
+ if (install) {
+ formatPartition(selectedPartition);
+ } else {
+ modifyPartition(selectedPartition);
+ }
+ }
+ }
- private Partition createPartition(Partition freePart) throws Exception {
- long size = freePart.getSize();
- NumberField sizeField = new NumberField(context);
- size = sizeField.show("Size of the new partition ", size, 1, size);
+ private Partition createPartition(Partition freePart) throws Exception {
+ long size = freePart.getSize();
+ NumberField sizeField = new NumberField(context);
+ size = sizeField.show("Size of the new partition ", size, 1, size);
- return UserFacade.getInstance().createPartition(freePart.getStart(), size);
- }
+ return UserFacade.getInstance().createPartition(freePart.getStart(), size);
+ }
- private void modifyPartition(Partition partition) throws Exception {
- if(partition.isUsed())
- {
- final String[] operations = new String[]{"format partition", "remove partition"};
+ private void modifyPartition(Partition partition) throws Exception {
+ if (partition.isUsed()) {
+ final String[] operations = new String[] {"format partition", "remove partition"};
- Options partitionsOpt = new Options(context);
- int choice = (int) partitionsOpt.show("Select an operation", operations);
- switch(choice)
- {
- case 0: formatPartition(partition); break;
- case 1: removePartition(partition); break;
- }
- }
- else
- {
- final String[] operations = new String[]{"add partition"};
+ Options partitionsOpt = new Options(context);
+ int choice = (int) partitionsOpt.show("Select an operation", operations);
+ switch (choice) {
+ case 0:
+ formatPartition(partition);
+ break;
+ case 1:
+ removePartition(partition);
+ break;
+ }
+ } else {
+ final String[] operations = new String[] {"add partition"};
- Options partitionsOpt = new Options(context);
- int choice = (int) partitionsOpt.show("Select an operation", operations);
- switch(choice)
- {
- case 0: createPartition(partition); break;
- }
- }
- }
+ Options partitionsOpt = new Options(context);
+ int choice = (int) partitionsOpt.show("Select an operation", operations);
+ switch (choice) {
+ case 0:
+ createPartition(partition);
+ break;
+ }
+ }
+ }
- private void removePartition(Partition partition) throws Exception {
- YesNo yesNo = new YesNo(context);
- boolean remove = yesNo.show("Would like you to remove the partition ?");
+ private void removePartition(Partition partition) throws Exception {
+ YesNo yesNo = new YesNo(context);
+ boolean remove = yesNo.show("Would like you to remove the partition ?");
- if(remove)
- {
- UserFacade.getInstance().removePartition(partition.getStart() + 1);
- }
- }
+ if (remove) {
+ UserFacade.getInstance().removePartition(partition.getStart() + 1);
+ }
+ }
- private void formatPartition(Partition partition) throws Exception {
- String[] formatters = UserFacade.getInstance().getFormatters();
- Options partitionsOpt = new Options(context);
- int choice = (int) partitionsOpt.show("Select a filesystem", formatters);
- String formatter = formatters[choice];
+ private void formatPartition(Partition partition) throws Exception {
+ String[] formatters = UserFacade.getInstance().getFormatters();
+ Options partitionsOpt = new Options(context);
+ int choice = (int) partitionsOpt.show("Select a filesystem", formatters);
+ String formatter = formatters[choice];
- UserFacade.getInstance().selectFormatter(formatter);
+ UserFacade.getInstance().selectFormatter(formatter);
- UserFacade.getInstance().formatPartition(partition.getStart() + 1);
- }
+ UserFacade.getInstance().formatPartition(partition.getStart() + 1);
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/ConsoleViewFactory.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -7,32 +7,32 @@
import org.jnode.apps.jpartition.ViewFactory;
/**
- *
+ *
* @author Fabien Duminy
- *
+ *
*/
public class ConsoleViewFactory implements ViewFactory {
- private final InputStream in;
- private final PrintStream out;
- private final PrintStream err;
+ 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(InputStream in, PrintStream out, PrintStream err) {
+ this.in = in;
+ this.out = out;
+ this.err = err;
+ }
- public Object createCommandProcessorView() {
- return null; // nothing particular to create : work is done by createDeviceView
- }
+ public Object createCommandProcessorView() {
+ return null; // nothing particular to create : work is done by
+ // createDeviceView
+ }
- public Object createDeviceView(ErrorReporter errorReporter,
- Object cmdProcessorView, boolean install) throws Exception {
- return new ConsoleView(in, out, errorReporter, install);
- }
+ public Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView,
+ boolean install) throws Exception {
+ return new ConsoleView(in, out, errorReporter, install);
+ }
- public ErrorReporter createErrorReporter() {
- return new ConsoleErrorReporter(err);
- }
+ public ErrorReporter createErrorReporter() {
+ return new ConsoleErrorReporter(err);
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/DeviceLabelizer.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/DeviceLabelizer.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/DeviceLabelizer.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -4,21 +4,19 @@
import org.jnode.apps.jpartition.model.Device;
import org.jnode.util.NumberUtils;
-class DeviceLabelizer implements Labelizer<Device>
-{
- static final DeviceLabelizer INSTANCE = new DeviceLabelizer();
+class DeviceLabelizer implements Labelizer<Device> {
+ static final DeviceLabelizer INSTANCE = new DeviceLabelizer();
- public String getLabel(Device device) {
- if(device == null)
- {
- throw new NullPointerException("device is null");
- }
+ public String getLabel(Device device) {
+ if (device == null) {
+ throw new NullPointerException("device is null");
+ }
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
- sb.append(device.getName());
- sb.append(" (").append(NumberUtils.toBinaryByte(device.getSize())).append(')');
+ sb.append(device.getName());
+ sb.append(" (").append(NumberUtils.toBinaryByte(device.getSize())).append(')');
- return sb.toString();
- }
+ return sb.toString();
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/PartitionLabelizer.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/PartitionLabelizer.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/PartitionLabelizer.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -4,23 +4,22 @@
import org.jnode.apps.jpartition.model.Partition;
import org.jnode.util.NumberUtils;
-class PartitionLabelizer implements Labelizer<Partition>
-{
- static final PartitionLabelizer INSTANCE = new PartitionLabelizer();
-
- public String getLabel(Partition partition) {
- if(partition == null)
- {
- throw new NullPointerException("partition is null");
- }
-
- StringBuilder sb = new StringBuilder();
-
- sb.append('[').append(partition.getStart()).append(',').append(partition.getEnd()).append(']');
- sb.append(" (").append(NumberUtils.toBinaryByte(partition.getSize())).append(") ");
- String format = partition.isUsed() ? partition.getFormat() : "unused";
- sb.append(format);
-
- return sb.toString();
- }
+class PartitionLabelizer implements Labelizer<Partition> {
+ static final PartitionLabelizer INSTANCE = new PartitionLabelizer();
+
+ public String getLabel(Partition partition) {
+ if (partition == null) {
+ throw new NullPointerException("partition is null");
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append('[').append(partition.getStart()).append(',').append(partition.getEnd()).append(
+ ']');
+ sb.append(" (").append(NumberUtils.toBinaryByte(partition.getSize())).append(") ");
+ String format = partition.isUsed() ? partition.getFormat() : "unused";
+ sb.append(format);
+
+ return sb.toString();
+ }
}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Component.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Component.java 2008-06-15 17:12:49 UTC (rev 4251)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/consoleview/components/Component.java 2008-06-15 19:35:53 UTC (rev 4252)
@@ -7,192 +7,154 @@
import org.jnode.apps.jpartition.Context;
public class Component {
- protected static final String TRUE_LONG_STRING = "yes";
- protected static final String FALSE_LONG_STRING = "no";
-
- protected final Context context;
-
- protected Component(Context context) {
- this.context = context;
- }
+ protected static final String TRUE_LONG_STRING = "yes";
+ protected static final String FALSE_LONG_STRING = "no";
- final protected void print(String s) {
- context.getOut().print(s);
- }
+ protected final Context context;
- final protected void println() {
- context.getOut().println();
- }
+ protected Component(Context context) {
+ this.context = context;
+ }
- final protected void println(String s) {
- context.getOut().println(s);
- }
+ protected final void print(String s) {
+ context.getOut().print(s);
+ }
- final protected int read() throws IOException {
- return context.getIn().read();
- }
+ protected final void println() {
+ context.getOut().println();
+ }
- final protected String getValueStr(boolean value)
- {
- return value ? TRUE_LONG_STRING : FALSE_LONG_STRING;
- }
-
- final protected Boolean readBoolean(Boolean defaultValue) throws IOException {
- String line = context.getIn().readLine();
-
- Boolean value;
- if((line == null) || (line.trim().length() == 0))
- {
- value = defaultValue;
- if(value != null)
- {
- print(String.valueOf(defaultValue));
- }
- }
- else
- {
- try
- {
- line = line.trim();
- if(defaultValue == null)
- {
- if(TRUE_LONG_STRING.equals(line))
- {
- value = true;
- }
- ...
[truncated message content] |