|
|
@ -10,6 +10,9 @@ import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.EventListener; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by kerry on 2020-10-19 |
|
|
|
* Created by kerry on 2020-10-19 |
|
|
@ -20,8 +23,10 @@ public class OnlineWidgetTabPane extends JPanel { |
|
|
|
private CardLayout cardLayout; |
|
|
|
private CardLayout cardLayout; |
|
|
|
private JPanel centerPane; |
|
|
|
private JPanel centerPane; |
|
|
|
private boolean packagePaneCreated = false; |
|
|
|
private boolean packagePaneCreated = false; |
|
|
|
|
|
|
|
private List<TabChangeListener> tabChangeListeners; |
|
|
|
|
|
|
|
|
|
|
|
public OnlineWidgetTabPane(OnlineShareWidget[] sharableWidgets, OnlineShareWidget[] sharableWidgetPackage) { |
|
|
|
public OnlineWidgetTabPane(OnlineShareWidget[] sharableWidgets, OnlineShareWidget[] sharableWidgetPackage) { |
|
|
|
|
|
|
|
tabChangeListeners = new ArrayList<>(); |
|
|
|
initPane(sharableWidgets, sharableWidgetPackage); |
|
|
|
initPane(sharableWidgets, sharableWidgetPackage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -33,7 +38,9 @@ public class OnlineWidgetTabPane extends JPanel { |
|
|
|
//延迟组件包面板的初始化,防止组件面板里组件的缩略图和组件包面板里组件的缩略图一起加载
|
|
|
|
//延迟组件包面板的初始化,防止组件面板里组件的缩略图和组件包面板里组件的缩略图一起加载
|
|
|
|
UITabGroup headGroup = new UITabGroup(new String[]{COMPONENT, COMPONENT_PACKAGE}) { |
|
|
|
UITabGroup headGroup = new UITabGroup(new String[]{COMPONENT, COMPONENT_PACKAGE}) { |
|
|
|
public void tabChanged(int newSelectedIndex) { |
|
|
|
public void tabChanged(int newSelectedIndex) { |
|
|
|
OnlineWidgetRepoPane.getInstance().setShowPackagePanel(newSelectedIndex != 0); |
|
|
|
for (TabChangeListener changeListener : tabChangeListeners) { |
|
|
|
|
|
|
|
changeListener.tabChange(newSelectedIndex); |
|
|
|
|
|
|
|
} |
|
|
|
if (newSelectedIndex == 0) { |
|
|
|
if (newSelectedIndex == 0) { |
|
|
|
cardLayout.show(centerPane, COMPONENT); |
|
|
|
cardLayout.show(centerPane, COMPONENT); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -45,6 +52,7 @@ public class OnlineWidgetTabPane extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
cardLayout.show(centerPane, COMPONENT_PACKAGE); |
|
|
|
cardLayout.show(centerPane, COMPONENT_PACKAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
headGroup.setSelectedIndex(0); |
|
|
|
headGroup.setSelectedIndex(0); |
|
|
@ -55,4 +63,18 @@ public class OnlineWidgetTabPane extends JPanel { |
|
|
|
this.add(jPanel, BorderLayout.NORTH); |
|
|
|
this.add(jPanel, BorderLayout.NORTH); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void addTabChangeListener(TabChangeListener listener) { |
|
|
|
|
|
|
|
if (!tabChangeListeners.contains(listener)) { |
|
|
|
|
|
|
|
tabChangeListeners.add(listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void removeTabChangeListener(TabChangeListener listener) { |
|
|
|
|
|
|
|
tabChangeListeners.remove(listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface TabChangeListener extends EventListener { |
|
|
|
|
|
|
|
void tabChange(int selectedIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|