|
From: <fd...@us...> - 2007-04-15 18:15:19
|
Revision: 3159
http://jnode.svn.sourceforge.net/jnode/?rev=3159&view=rev
Author: fduminy
Date: 2007-04-15 11:15:09 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
update of JPartition : refactor around stamps-mvc for better separation
of model, view and controller
Modified Paths:
--------------
trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
Removed Paths:
-------------
trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java
trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java
trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java
Deleted: trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java 2007-04-15 18:10:57 UTC (rev 3158)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java 2007-04-15 18:15:09 UTC (rev 3159)
@@ -1,35 +0,0 @@
-/**
- *
- */
-package org.jnode.apps.jpartition;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jnode.naming.NameSpace;
-
-public final class BasicNameSpace implements NameSpace {
- protected final Map<Class<?>, Object> namespace = new HashMap<Class<?>, Object>();
-
- public <T> void bind(Class<T> name, T service)
- throws NamingException, NameAlreadyBoundException {
- namespace.put(name, service);
- }
-
- public <T> T lookup(Class<T> name) throws NameNotFoundException {
- return (T) namespace.get(name);
- }
-
- public Set<Class<?>> nameSet() {
- return namespace.keySet();
- }
-
- public void unbind(Class<?> name) {
- namespace.remove(name);
- }
-}
\ No newline at end of file
Deleted: trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java 2007-04-15 18:10:57 UTC (rev 3158)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java 2007-04-15 18:15:09 UTC (rev 3159)
@@ -1,86 +0,0 @@
-package org.jnode.apps.jpartition;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jnode.apps.vmware.disk.VMWareDisk;
-import org.jnode.apps.vmware.disk.handler.UnsupportedFormatException;
-import org.jnode.driver.DeviceManager;
-import org.jnode.driver.DriverException;
-import org.jnode.driver.block.BlockDeviceAPIHelper;
-import org.jnode.driver.block.PartitionableBlockDeviceAPI;
-import org.jnode.driver.bus.ide.IDEConstants;
-import org.jnode.driver.bus.ide.IDEDevice;
-import org.jnode.driver.bus.ide.IDEDeviceFactory;
-import org.jnode.driver.bus.ide.IDEDriverUtils;
-import org.jnode.naming.InitialNaming;
-import org.jnode.partitions.PartitionTable;
-import org.jnode.partitions.ibm.IBMPartitionTable;
-import org.jnode.partitions.ibm.IBMPartitionTableType;
-
-public class FileIDEDevice extends IDEDevice implements PartitionableBlockDeviceAPI
-{
- private VMWareDisk vmwareDisk;
- private PartitionTable pt;
-
- public FileIDEDevice(File file, long fileSize,
- boolean primary, boolean master)
- throws IOException, DriverException, NameNotFoundException, UnsupportedFormatException
- {
- super(null, primary, master, file.getName(), null, null);
- registerAPI(PartitionableBlockDeviceAPI.class, this);
-
- vmwareDisk = new VMWareDisk(file);
-
- setDriver(new FileIDEDeviceDriver());
-
- pt = buildPartitionTable();
- }
-
- public void flush() throws IOException {
- vmwareDisk.flush();
- }
-
- public long getLength() throws IOException {
- return vmwareDisk.getLength();
- }
-
- public void read(long devOffset, ByteBuffer destBuf) throws IOException {
- BlockDeviceAPIHelper.checkBounds(this, devOffset, destBuf.remaining());
-
- vmwareDisk.read(devOffset, destBuf);
- }
-
- public void write(long devOffset, ByteBuffer srcBuf) throws IOException {
- BlockDeviceAPIHelper.checkBounds(this, devOffset, srcBuf.remaining());
-
- vmwareDisk.write(devOffset, srcBuf);
- }
-
- public String toString()
- {
- return getId();
- }
-
- public PartitionTable getPartitionTable() throws IOException {
- return pt;
- }
-
- public int getSectorSize() throws IOException {
- return IDEConstants.SECTOR_SIZE;
- }
-
- protected PartitionTable buildPartitionTable() throws DriverException, IOException, NameNotFoundException
- {
- // Read the bootsector
- final byte[] bs = new byte[IDEConstants.SECTOR_SIZE];
- read(0, ByteBuffer.wrap(bs));
-
- return new IBMPartitionTable(new IBMPartitionTableType(), bs, this);
- }
-}
Deleted: trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java 2007-04-15 18:10:57 UTC (rev 3158)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java 2007-04-15 18:15:09 UTC (rev 3159)
@@ -1,32 +0,0 @@
-package org.jnode.apps.jpartition;
-
-import org.jnode.driver.Driver;
-import org.jnode.driver.DriverException;
-import org.jnode.driver.DeviceAlreadyRegisteredException;
-import org.jnode.driver.bus.ide.IDEDevice;
-
-/**
- *
- * @author Fabien DUMINY (fduminy at jnode.org)
- *
- */
-public class FileIDEDeviceDriver extends Driver {
- /**
- * Start the device.
- *
- * @throws org.jnode.driver.DriverException
- *
- */
- protected void startDevice() throws DriverException {
- }
-
- /**
- * Stop the device.
- *
- * @throws org.jnode.driver.DriverException
- *
- */
- protected void stopDevice() throws DriverException {
-
- }
-}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2007-04-15 18:10:57 UTC (rev 3158)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2007-04-15 18:15:09 UTC (rev 3159)
@@ -1,60 +1,58 @@
package org.jnode.apps.jpartition;
-import java.util.Collection;
-
-import javax.naming.NameNotFoundException;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
import org.apache.log4j.Logger;
-import org.jnode.apps.jpartition.model.DevicePartitions;
-import org.jnode.apps.jpartition.model.DevicePartitionsList;
-import org.jnode.apps.jpartition.view.DevicePartitionsFrame;
-import org.jnode.apps.jpartition.view.FileDeviceFrame;
-import org.jnode.driver.Device;
-import org.jnode.driver.DeviceManager;
-import org.jnode.driver.block.PartitionableBlockDeviceAPI;
+import org.jnode.apps.jpartition.controller.MainController;
+import org.jnode.apps.jpartition.swingview.SwingViewFactory;
+import org.jnode.apps.jpartition.utils.BasicNameSpace;
import org.jnode.naming.InitialNaming;
import org.jnode.naming.NameSpace;
import org.jnode.test.fs.driver.stubs.StubDeviceManager;
+import org.jnode.test.gui.Emu;
+import org.jnode.util.OsUtils;
-public class JPartition {
+public class JPartition extends Emu
+{
private static final Logger log = Logger.getLogger(JPartition.class);
- public static void main(String[] args) throws Exception {
- initJNodeCore();
+ public static void main(String[] args) throws Throwable
+ {
+// testCharva();
- FileDeviceFrame frm = new FileDeviceFrame();
- frm.setSize(300, 300);
- frm.setVisible(true);
- frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ if(!OsUtils.isJNode())
+ {
+ initJNodeCore();
+ }
- DevicePartitionsFrame mainUI = new DevicePartitionsFrame(getDevicePartitions());
- mainUI.setSize(300, 300);
- mainUI.setVisible(true);
- mainUI.setLocation(frm.getX(), frm.getY() + frm.getHeight());
- mainUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ ViewFactory viewFactory = new SwingViewFactory();
+ MainController controller = new MainController(viewFactory);
}
- public static DevicePartitionsList getDevicePartitions()
- {
- DevicePartitionsList devParts = new DevicePartitionsList();
- try {
- DeviceManager devMan = InitialNaming.lookup(DeviceManager.NAME);
- Collection<Device> devices = devMan.getDevicesByAPI(PartitionableBlockDeviceAPI.class);
- for(Device device : devices)
- {
- devParts.add(new DevicePartitions(device));
- }
- } catch (NameNotFoundException e) {
- log.error(e);
- }
- return devParts;
- }
-
private static void initJNodeCore() throws Exception {
NameSpace namespace = new BasicNameSpace();
InitialNaming.setNameSpace(namespace);
namespace.bind(DeviceManager.NAME, StubDeviceManager.INSTANCE);
- }
+ }
+
+/*
+ private static void testCharva() throws Throwable
+ {
+ initEnv();
+ SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
+ TextConsole tc = (TextConsole) cm.createConsole("Console 1",
+ ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE);
+ cm.focus(tc);
+ CommandShell cs = new CommandShell(tc);
+ final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
+ sm.registerShell(cs);
+ new Thread(cs).start();
+
+ charvax.swing.JFrame frm = new charvax.swing.JFrame("test");
+ JLabel label = new JLabel("test");
+ frm.add(label);
+ frm.setFocus(label);
+ frm.setSize(300, 300);
+ frm.setVisible(true);
+ frm.setDefaultCloseOperation(charvax.swing.JFrame.EXIT_ON_CLOSE);
+ }
+*/
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|