mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 09:42:08 +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.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
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.IPlugInPort;
|
||||
@@ -42,6 +42,13 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
JPanel panel = createTab((componentTypes.get(category)));
|
||||
addTab(category, panel);
|
||||
}
|
||||
addChangeListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JPanel createTab(List<ComponentType> componentTypes) {
|
||||
@@ -87,13 +94,13 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JScrollPane createComponentScrollBar(List<ComponentType> componentTypes) {
|
||||
JScrollPane scrollPane = new JScrollPane(createComponentPanel(componentTypes));
|
||||
scrollPane.setOpaque(false);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
return scrollPane;
|
||||
}
|
||||
// private JScrollPane createComponentScrollBar(List<ComponentType> componentTypes) {
|
||||
// JScrollPane scrollPane = new JScrollPane(createComponentPanel(componentTypes));
|
||||
// scrollPane.setOpaque(false);
|
||||
// scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
// scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
// return scrollPane;
|
||||
// }
|
||||
|
||||
private Component createComponentPanel(List<ComponentType> componentTypes) {
|
||||
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 ISwingUI swingUI;
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
private ComponentTabbedPane componentTabbedPane;
|
||||
|
||||
public ToolBox(ISwingUI swingUI) {
|
||||
this.swingUI = swingUI;
|
||||
@@ -25,13 +28,21 @@ public class ToolBox implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
try {
|
||||
swingUI.injectGUIComponent(new ComponentTabbedPane(plugInPort), SwingConstants.TOP);
|
||||
swingUI.injectGUIComponent(getComponentTabbedPane(), SwingConstants.TOP);
|
||||
} catch (BadPositionException e) {
|
||||
LOG.error("Could not install the toolbox", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ComponentTabbedPane getComponentTabbedPane() {
|
||||
if (componentTabbedPane == null) {
|
||||
componentTabbedPane = new ComponentTabbedPane(plugInPort);
|
||||
}
|
||||
return componentTabbedPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Reference in New Issue
Block a user