Skip to content
Snippets Groups Projects
Commit b961acd0 authored by GIRARDOT Raphael's avatar GIRARDOT Raphael Committed by MADELA Patrick
Browse files

some methods renamed + added the possibility to interact with any docking area...

some methods renamed + added the possibility to interact with any docking area (not necessary the main one)
parent 716a3234
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,6 @@ import java.io.ObjectInputStream; ...@@ -16,7 +16,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.UIManager; import javax.swing.UIManager;
import com.vldocking.swing.docking.DockingDesktop; import com.vldocking.swing.docking.DockingDesktop;
...@@ -83,19 +82,20 @@ public class VlDockDockingManager extends ADockingManager { ...@@ -83,19 +82,20 @@ public class VlDockDockingManager extends ADockingManager {
} }
@Override @Override
public void loadPerspective(IPerspective perspective) throws DockingException { public void applyPerspective(IPerspective perspective, JComponent dockingArea) throws DockingException {
DockingException dockingException = null; DockingException dockingException = null;
if (perspective.getByteArray().length > 0) { if ((perspective != null) && (perspective.getByteArray().length > 0)
&& (dockingArea instanceof SoleilDockingDesktop)) {
SoleilDockingDesktop mainDockingDesktop = (SoleilDockingDesktop) dockingArea;
ObjectInputStream ois = null; ObjectInputStream ois = null;
ByteArrayInputStream bais = null; ByteArrayInputStream bais = null;
try { try {
bais = new ByteArrayInputStream(perspective.getByteArray()); bais = new ByteArrayInputStream(perspective.getByteArray());
ois = new ObjectInputStream(bais); ois = new ObjectInputStream(bais);
mainDockingDesktop.readXML(ois); mainDockingDesktop.readXML(ois);
} catch (Exception e) { } catch (Exception e) {
dockingException = new DockingException("Perspective.load() :" + " Unexpected Error", e); dockingException = new DockingException(getClass().getSimpleName()
+ ".applyPerspective(): Unexpected Error", e);
} finally { } finally {
try { try {
if (ois != null) { if (ois != null) {
...@@ -117,28 +117,36 @@ public class VlDockDockingManager extends ADockingManager { ...@@ -117,28 +117,36 @@ public class VlDockDockingManager extends ADockingManager {
} }
@Override @Override
protected void savePerspective(IPerspective perspective) { public void updatePerspective(IPerspective perspective, JComponent dockingArea) throws DockingException {
ByteArrayOutputStream baos = null; DockingException dockingException = null;
ObjectOutputStream ous = null; if ((perspective != null) && (dockingArea instanceof SoleilDockingDesktop)) {
baos = new ByteArrayOutputStream(); SoleilDockingDesktop mainDockingDesktop = (SoleilDockingDesktop) dockingArea;
try { ByteArrayOutputStream baos = null;
ous = new ObjectOutputStream(baos); ObjectOutputStream ous = null;
mainDockingDesktop.writeXML(ous); baos = new ByteArrayOutputStream();
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(mainDockingDesktop,
"Perspective.save() :" + " Unexpected Error (see traces)", "VLDock - Error",
JOptionPane.ERROR_MESSAGE);
} finally {
try { try {
ous.close(); ous = new ObjectOutputStream(baos);
// Actually there is no effect to close baos ... mainDockingDesktop.writeXML(ous);
perspective.setByteArray(baos.toByteArray());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); dockingException = new DockingException(getClass().getSimpleName()
+ ".updatePerspective(): Unexpected Error", e);
} finally {
try {
ous.close();
// Actually there is no effect to close baos ...
} catch (IOException e) {
if (dockingException == null) {
dockingException = new DockingException("I/O Exception", e);
} else {
e.printStackTrace();
}
}
} }
} }
perspective.setByteArray(baos.toByteArray()); if (dockingException != null) {
throw dockingException;
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment