0023097: MFC Samples do not compile after redesigning the TKOpenGl driver
[occt.git] / samples / java / java / SamplesTopologyPanel.java
1
2 //Title:        OpenCASCADE Samples
3 //Version:
4 //Copyright:    Copyright (c) 1999
5 //Author:       User Interface group
6 //Company:      Matra Datavision
7 //Description:
8
9 import java.awt.*;
10 import java.awt.event.*;
11 import javax.swing.*;
12 import javax.swing.event.*;
13 import java.util.*;
14
15
16 public class SamplesTopologyPanel extends JPanel
17                             implements ChangeListener
18 {
19   private Component myCurrentPage = null;
20   private JTabbedPane myTabbedPane = null;
21
22 //=======================================================================//
23 // Constructor
24 //=======================================================================//
25   public SamplesTopologyPanel()
26   {
27     setLayout(new BorderLayout());
28
29     //-----------------------------------------------------------//
30     // Create a tab pane
31     //-----------------------------------------------------------//
32     myTabbedPane = new JTabbedPane();
33     myTabbedPane.setVisible(false);
34     myTabbedPane.addChangeListener(this);
35     add(myTabbedPane, BorderLayout.CENTER);
36
37     // The Topology Primitives sample
38     myTabbedPane.addTab("Topology Primitives", new SampleTopologyPrimitivesPanel());
39
40     // The Topological Operations sample
41     myTabbedPane.addTab("Topological Operations", new SampleTopologicalOperationsPanel());
42
43     // The Topology Building sample
44     myTabbedPane.addTab("Topology Building", new SampleTopologyBuildingPanel());
45
46     // The Topology Analysis sample
47     myTabbedPane.addTab("Topology Analysis", new SampleTopologyAnalysisPanel());
48
49     // The Topology Transformations sample
50     myTabbedPane.addTab("Topology Transformations", new SampleTopologyTransformationsPanel());
51
52     // The Local Operations sample
53     myTabbedPane.addTab("Local Operations", new SampleLocalOperationsPanel());
54
55     // The Triangulation sample
56     myTabbedPane.addTab("Triangulation", new SampleTriangulationPanel());
57   
58     myTabbedPane.setSelectedIndex(0);
59   }
60
61 //-----------------------------------------------------------------------//
62   public void setVisible(boolean b)
63   {
64     super.setVisible(b);
65     myTabbedPane.setVisible(b);
66     if (myCurrentPage != null)
67       myCurrentPage.setVisible(b);
68     if (b) this.validate();
69   }
70
71
72 //=======================================================================//
73 //                          Change Listener                              //
74 //=======================================================================//
75   public void stateChanged(ChangeEvent event)
76   {
77     SamplesStarter.put_info("");
78
79     JTabbedPane tab = (JTabbedPane) event.getSource();
80     int index = tab.getSelectedIndex();
81     Component currentPage = tab.getComponentAt(index);
82
83     if (myCurrentPage != null)
84     {
85       myCurrentPage.setVisible(false);
86       myCurrentPage.setEnabled(false);
87       currentPage.setVisible(true);
88       currentPage.setEnabled(true);
89     }
90     else
91     {
92       currentPage.setVisible(false);
93       currentPage.setEnabled(false);
94     }
95     myCurrentPage = currentPage;
96   }
97
98 }