diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml
index 03cce46c..b9ecbf47 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/update.xml
+++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml
@@ -2721,7 +2721,10 @@
NEW_FEATURE
New app icon!
-
+
+
+ NEW_FEATURE
+ Added ability to collapse and expand the component tree panel to the left edge of the screen
IMPROVEMENT
Upgraded to Java 8
diff --git a/diylc/diylc-swing/src/org/diylc/swing/ISwingUI.java b/diylc/diylc-swing/src/org/diylc/swing/ISwingUI.java
index f68dc2d9..bea042ac 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/ISwingUI.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/ISwingUI.java
@@ -53,10 +53,11 @@ public interface ISwingUI extends IView {
* Center position is reserved for the main canvas panel and cannot be used.
*
* @param component
- * @param position
+ * @param position
+ * @param collapsible
* @throws BadPositionException in case invalid position is specified
*/
- void injectGUIComponent(JComponent component, int position) throws BadPositionException;
+ void injectGUIComponent(JComponent component, int position, boolean collapsible) throws BadPositionException;
/**
* Injects a custom menu action into application's main menu. If action is set to
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/CollapsiblePanel.java b/diylc/diylc-swing/src/org/diylc/swing/gui/CollapsiblePanel.java
new file mode 100644
index 00000000..8557e643
--- /dev/null
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/CollapsiblePanel.java
@@ -0,0 +1,183 @@
+package org.diylc.swing.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import javax.swing.border.MatteBorder;
+
+/***
+ * Panel that has a clickable line that can used to collapse and expand the contents of the panel.
+ *
+ * @author bancika
+ */
+public class CollapsiblePanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private static int thickness = 4;
+
+ private MatteBorderEx border;
+
+ private Color defaultColor = Color.lightGray;
+ private Color highlightColor = Color.decode("#66CCFF");
+
+ public CollapsiblePanel(int position) {
+ border = new MatteBorderEx(position == SwingConstants.BOTTOM ? thickness : 0,
+ position == SwingConstants.RIGHT ? thickness : 0,
+ position == SwingConstants.TOP ? thickness : 0,
+ position == SwingConstants.LEFT ? thickness : 0, defaultColor);
+ setToolTipText("Click to collapse");
+ setBorder(border);
+ BorderLayout borderLayout = new BorderLayout();
+ setLayout(borderLayout);
+ addMouseListener(mouseListener);
+ }
+
+ MouseListener mouseListener = new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ toggleVisibility();
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ border.setMatteColor(highlightColor);
+ };
+
+ public void mouseExited(MouseEvent e) {
+ border.setMatteColor(defaultColor);
+ };
+ };
+
+ public Color getDefaultColor() {
+ return defaultColor;
+ }
+
+ public void setDefaultColor(Color defaultColor) {
+ this.defaultColor = defaultColor;
+ }
+
+ public Color getHighlightColor() {
+ return highlightColor;
+ }
+
+ public void setHighlightColor(Color highlightColor) {
+ this.highlightColor = highlightColor;
+ }
+
+ ComponentListener contentComponentListener = new ComponentAdapter() {
+ @Override
+ public void componentShown(ComponentEvent e) {
+ updateBorderTitle();
+ }
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ updateBorderTitle();
+ }
+ };
+
+ @Override
+ public Component add(Component comp) {
+ comp.addComponentListener(contentComponentListener);
+ Component r = super.add(comp);
+ updateBorderTitle();
+ return r;
+ }
+
+ @Override
+ public Component add(String name, Component comp) {
+ comp.addComponentListener(contentComponentListener);
+ Component r = super.add(name, comp);
+ updateBorderTitle();
+ return r;
+ }
+
+ @Override
+ public Component add(Component comp, int index) {
+ comp.addComponentListener(contentComponentListener);
+ Component r = super.add(comp, index);
+ updateBorderTitle();
+ return r;
+ }
+
+ @Override
+ public void add(Component comp, Object constraints) {
+ comp.addComponentListener(contentComponentListener);
+ super.add(comp, constraints);
+ updateBorderTitle();
+ }
+
+ @Override
+ public void add(Component comp, Object constraints, int index) {
+ comp.addComponentListener(contentComponentListener);
+ super.add(comp, constraints, index);
+ updateBorderTitle();
+ }
+
+ @Override
+ public void remove(int index) {
+ Component comp = getComponent(index);
+ comp.removeComponentListener(contentComponentListener);
+ super.remove(index);
+ }
+
+ @Override
+ public void remove(Component comp) {
+ comp.removeComponentListener(contentComponentListener);
+ super.remove(comp);
+ }
+
+ @Override
+ public void removeAll() {
+ for (Component c : getComponents()) {
+ c.removeComponentListener(contentComponentListener);
+ }
+ super.removeAll();
+ }
+
+ protected void toggleVisibility() {
+ toggleVisibility(hasInvisibleComponent());
+ }
+
+ protected void toggleVisibility(boolean visible) {
+ for (Component c : getComponents()) {
+ c.setVisible(visible);
+ }
+ updateBorderTitle();
+ }
+
+ protected void updateBorderTitle() {
+
+ }
+
+ protected final boolean hasInvisibleComponent() {
+ for (Component c : getComponents()) {
+ if (!c.isVisible()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ class MatteBorderEx extends MatteBorder {
+
+ public MatteBorderEx(int top, int left, int bottom, int right, Color matteColor) {
+ super(top, left, bottom, right, matteColor);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ public void setMatteColor(Color color) {
+ this.color = color;
+ repaint();
+ }
+ }
+}
\ No newline at end of file
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java b/diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
index 46d57833..43b67767 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
@@ -294,8 +294,13 @@ public class MainFrame extends JFrame implements ISwingUI {
}
@Override
- public void injectGUIComponent(JComponent component, int position) throws BadPositionException {
- LOG.info(String.format("injectGUIComponent(%s, %s)", component.getClass().getName(), position));
+ public void injectGUIComponent(JComponent component, int position, boolean collapsible) throws BadPositionException {
+ LOG.info(String.format("injectGUIComponent(%s, %s, %s)", component.getClass().getName(), position, collapsible));
+ if (collapsible) {
+ CollapsiblePanel panel = new CollapsiblePanel(position);
+ panel.add(component);
+ component = panel;
+ }
switch (position) {
case SwingConstants.TOP:
topPanel.add(component);
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
index bb04d4fa..efc7c07b 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
@@ -135,7 +135,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
try {
- swingUI.injectGUIComponent(getScrollPane(), SwingConstants.CENTER);
+ swingUI.injectGUIComponent(getScrollPane(), SwingConstants.CENTER, false);
} catch (BadPositionException e) {
LOG.error("Could not install canvas plugin", e);
}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
index 25515b3d..233a114a 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
@@ -122,7 +122,7 @@ public class StatusBar extends JPanel implements IPlugIn {
setLayout(new GridBagLayout());
try {
- swingUI.injectGUIComponent(this, SwingUtilities.BOTTOM);
+ swingUI.injectGUIComponent(this, SwingUtilities.BOTTOM, false);
} catch (BadPositionException e) {
LOG.error("Could not install status bar", e);
}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ToolBox.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ToolBox.java
index 7587a2c7..daff4678 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ToolBox.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/toolbox/ToolBox.java
@@ -54,7 +54,7 @@ public class ToolBox implements IPlugIn {
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
try {
- swingUI.injectGUIComponent(getComponentTabbedPane(), SwingConstants.TOP);
+ swingUI.injectGUIComponent(getComponentTabbedPane(), SwingConstants.TOP, false);
} catch (BadPositionException e) {
LOG.error("Could not install the toolbox", e);
}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/ComponentTree.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/ComponentTree.java
index e78e39f1..7574d90c 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/ComponentTree.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/ComponentTree.java
@@ -60,7 +60,7 @@ public class ComponentTree implements IPlugIn {
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
try {
- swingUI.injectGUIComponent(getTreePanel(), SwingConstants.LEFT);
+ swingUI.injectGUIComponent(getTreePanel(), SwingConstants.LEFT, true);
} catch (BadPositionException e) {
LOG.error("Could not install the component tree", e);
}