mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
reset component selection when switching tabs
This commit is contained in:
+16
-9
@@ -11,9 +11,9 @@ import java.util.Map;
|
|||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
@@ -42,6 +42,13 @@ class ComponentTabbedPane extends JTabbedPane {
|
|||||||
JPanel panel = createTab((componentTypes.get(category)));
|
JPanel panel = createTab((componentTypes.get(category)));
|
||||||
addTab(category, panel);
|
addTab(category, panel);
|
||||||
}
|
}
|
||||||
|
addChangeListener(new ChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel createTab(List<ComponentType> componentTypes) {
|
private JPanel createTab(List<ComponentType> componentTypes) {
|
||||||
@@ -87,13 +94,13 @@ class ComponentTabbedPane extends JTabbedPane {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JScrollPane createComponentScrollBar(List<ComponentType> componentTypes) {
|
// private JScrollPane createComponentScrollBar(List<ComponentType> componentTypes) {
|
||||||
JScrollPane scrollPane = new JScrollPane(createComponentPanel(componentTypes));
|
// JScrollPane scrollPane = new JScrollPane(createComponentPanel(componentTypes));
|
||||||
scrollPane.setOpaque(false);
|
// scrollPane.setOpaque(false);
|
||||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
// scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
// scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||||
return scrollPane;
|
// return scrollPane;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private Component createComponentPanel(List<ComponentType> componentTypes) {
|
private Component createComponentPanel(List<ComponentType> componentTypes) {
|
||||||
Container toolbar = new Container();
|
Container toolbar = new Container();
|
||||||
|
|||||||
+12
-1
@@ -18,6 +18,9 @@ public class ToolBox implements IPlugIn {
|
|||||||
private static final Logger LOG = Logger.getLogger(StatusBar.class);
|
private static final Logger LOG = Logger.getLogger(StatusBar.class);
|
||||||
|
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
|
||||||
|
private ComponentTabbedPane componentTabbedPane;
|
||||||
|
|
||||||
public ToolBox(ISwingUI swingUI) {
|
public ToolBox(ISwingUI swingUI) {
|
||||||
this.swingUI = swingUI;
|
this.swingUI = swingUI;
|
||||||
@@ -25,12 +28,20 @@ public class ToolBox implements IPlugIn {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(IPlugInPort plugInPort) {
|
public void connect(IPlugInPort plugInPort) {
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
try {
|
try {
|
||||||
swingUI.injectGUIComponent(new ComponentTabbedPane(plugInPort), SwingConstants.TOP);
|
swingUI.injectGUIComponent(getComponentTabbedPane(), SwingConstants.TOP);
|
||||||
} catch (BadPositionException e) {
|
} catch (BadPositionException e) {
|
||||||
LOG.error("Could not install the toolbox", e);
|
LOG.error("Could not install the toolbox", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ComponentTabbedPane getComponentTabbedPane() {
|
||||||
|
if (componentTabbedPane == null) {
|
||||||
|
componentTabbedPane = new ComponentTabbedPane(plugInPort);
|
||||||
|
}
|
||||||
|
return componentTabbedPane;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||||
|
|||||||
Reference in New Issue
Block a user