Skip to content
Snippets Groups Projects
Commit 0e9b2be1 authored by Fabien Tessier's avatar Fabien Tessier
Browse files

Issue #68: Review Filters of Diagram Elements

parent 7398b8ff
No related branches found
No related tags found
No related merge requests found
......@@ -60,17 +60,15 @@ import java.util.Vector;
*/
public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttributes {
public static final int VIEW_ALL = 0;
public static final int VIEW_ARCHITECTURE_ONLY = 1;
public static final int VIEW_TASK_MAPPING = 2;
public static final int VIEW_CHANNEL_MAPPING = 3;
public static final int VIEW_TASK_MAPPING = 16;
public static final int VIEW_CHANNEL_MAPPING = 8;
public static final int VIEW_COMM_PATTERN = 4;
public static final int VIEW_COMM_PATTERN_MAPPING = 5;
public static final int VIEW_SECURITY_MAPPING = 6;
public static final int VIEW_PORT_INTERFACE = 2;
public static final int VIEW_SECURITY_MAPPING = 1;
private int masterClockFrequency = 200; // in MHz
protected int view = VIEW_ALL;
protected int view = 31;
......@@ -410,23 +408,41 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib
}
public boolean inCurrentView(TGComponent tgc) {
switch(view) {
case VIEW_ALL:
return true;
case VIEW_ARCHITECTURE_ONLY:
return (tgc instanceof TMLArchiElementInterface);
case VIEW_TASK_MAPPING:
return (tgc instanceof TMLArchiElementInterface) || (tgc instanceof TMLArchiTaskInterface);
case VIEW_CHANNEL_MAPPING:
return (tgc instanceof TMLArchiElementInterface) || (tgc instanceof TMLArchiChannelInterface);
case VIEW_COMM_PATTERN:
return (tgc instanceof TMLArchiElementInterface) || (tgc instanceof TMLArchiCPInterface);
case VIEW_COMM_PATTERN_MAPPING:
return (tgc instanceof TMLArchiElementInterface) || (tgc instanceof TMLArchiCPInterface) || (tgc instanceof TMLArchiPortInterface);
case VIEW_SECURITY_MAPPING:
return (tgc instanceof TMLArchiElementInterface) || (tgc instanceof TMLArchiSecurityInterface) || (tgc instanceof TMLArchiTaskInterface);
default:
return true;
}
boolean res = (tgc instanceof TMLArchiElementInterface);
int tmp = view;
if (view >= VIEW_TASK_MAPPING)
{
res = res || (tgc instanceof TMLArchiTaskInterface);
view -= 16;
}
if (view >= VIEW_CHANNEL_MAPPING)
{
res = res || (tgc instanceof TMLArchiChannelInterface);
view -= 8;
}
if (view >= VIEW_COMM_PATTERN)
{
res = res || (tgc instanceof TMLArchiCPInterface);
view -= 4;
}
if (view >= VIEW_PORT_INTERFACE)
{
res = res || (tgc instanceof TMLArchiPortInterface);
view -= 2;
}
if (view >= VIEW_SECURITY_MAPPING)
{
res = res || (tgc instanceof TMLArchiSecurityInterface);
view -= 1;
}
view = tmp;
return res;
}
}//End of class
......@@ -37,9 +37,6 @@
* knowledge of the CeCILL license and that you accept its terms.
*/
package ui.tmldd;
import myutil.TraceManager;
......@@ -48,6 +45,9 @@ import ui.TGUIAction;
import ui.TToolBar;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
......@@ -55,14 +55,16 @@ import java.awt.event.ActionListener;
* Class TMLArchiDiagramToolBar
* Implements the toolbar to be used in conjunction with the panel of a TML Architecture diagram
* Creation: 18/09/2007
* @version 1.0 08/09/2017
* @version 1.0 18/09/2007
* @author Ludovic APVRILLE
* @see ui.cd.TClassDiagramPanel
*/
public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener {
protected JComboBox<String> box;
protected static String[] viewInfos = { "View all", "View architecture only", "View task mapping", "View channel mapping", "View Comm. Pattern", "View Comm. Pattern mapping", "View security mapping"};
protected JMenuBar box;
protected JMenu menu;
protected JCheckBoxMenuItem m1, m2, m3, m4, m5;
protected static String[] viewInfos = {"View task mapping", "View channel mapping", "View Comm. Pattern mapping", "View Port Interface", "View security mapping"};
protected TMLArchiDiagramPanel panel;
public TMLArchiDiagramToolBar(MainGUI _mgui) {
......@@ -76,7 +78,6 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
mgui.actions[TGUIAction.TMLARCHI_LINK].setEnabled(b);
mgui.actions[TGUIAction.TMLARCHI_CPUNODE].setEnabled(b);
mgui.actions[TGUIAction.TMLARCHI_HWANODE].setEnabled(b);
mgui.actions[TGUIAction.TMLARCHI_CAMSNODE].setEnabled(b); //ajout CD
mgui.actions[TGUIAction.TMLARCHI_BUSNODE].setEnabled(b);
mgui.actions[TGUIAction.TMLARCHI_CPNODE].setEnabled(b);
mgui.actions[TGUIAction.TMLARCHI_BRIDGENODE].setEnabled(b);
......@@ -125,8 +126,6 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_HWANODE]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_CAMSNODE]); //ajout CD
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
......@@ -143,26 +142,27 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_MEMORYNODE]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
/*button = this.add(mgui.actions[TGUIAction.TMLARCHI_EVENT_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);*/
if (MainGUI.experimentalOn) {
this.addSeparator();
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.TMLARCHI_CPNODE]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
}
this.addSeparator();
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.TMLARCHI_KEY]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]);
button.addMouseListener(mgui.mouseHandler);
......@@ -175,31 +175,69 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]);
button.addMouseListener(mgui.mouseHandler);
setPluginButtons("TMLArchiDiagramPanel");
setPluginButtons("TMLArchiDiagramPanel");
this.addSeparator();
if (viewInfos == null) {
TraceManager.addDev("null viewInfos");
}
box = new JComboBox<>(viewInfos);
//Issue #68: Review Filters of Diagram Elements
box = new JMenuBar();
menu = new JMenu("Edit configuration view");
m1 = new JCheckBoxMenuItem(viewInfos[0], true);
m1.addActionListener(this);
m2 = new JCheckBoxMenuItem(viewInfos[1], true);
m2.addActionListener(this);
m3 = new JCheckBoxMenuItem(viewInfos[2], true);
m3.addActionListener(this);
m4 = new JCheckBoxMenuItem(viewInfos[3], true);
m4.addActionListener(this);
m5 = new JCheckBoxMenuItem(viewInfos[4], true);
m5.addActionListener(this);
menu.add(m1);
menu.add(m2);
menu.add(m3);
menu.add(m4);
menu.add(m5);
box.add(menu);
this.add(box);
box.addActionListener(this);
}
public void setPanel(TMLArchiDiagramPanel _panel) {
panel = _panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == box) {
super.actionPerformed(e);
//if (e.getSource() == box) {
if (panel != null) {
panel.setCurrentView(box.getSelectedIndex());
int res = 0;
//Check if "View Comm. Pattern mapping" is check to enable "Port Interface" option
if (!((JCheckBoxMenuItem) box.getMenu(0).getItem(2)).getState())
((JCheckBoxMenuItem)box.getMenu(0).getItem(3)).setEnabled(false);
else
((JCheckBoxMenuItem)box.getMenu(0).getItem(3)).setEnabled(true);
//Verify checked options
for (int i = 0; i < box.getMenu(0).getItemCount(); i++) {
JMenuItem j = box.getMenu(0).getItem(i);
JCheckBoxMenuItem ci = (JCheckBoxMenuItem) j;
res *= 2;
if (ci.isEnabled() && ci.getState())
res++;
}
panel.setCurrentView(res);
}
}
//}
}
} // Class
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