2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: MultipleArrayToolbar.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.10 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/04/14 21:08:51 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
15 |
import java.util.ArrayList; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
import javax.swing.AbstractButton; |
2 |
26 Feb 07 |
jari |
18 |
import javax.swing.Action; |
2 |
26 Feb 07 |
jari |
19 |
import javax.swing.Icon; |
2 |
26 Feb 07 |
jari |
20 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.JToolBar; |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
import org.tigr.microarray.mev.action.ActionManager; |
2 |
26 Feb 07 |
jari |
24 |
|
2 |
26 Feb 07 |
jari |
25 |
public class MultipleArrayToolbar extends JToolBar { |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
/** |
2 |
26 Feb 07 |
jari |
* Construct a <code>MultipleArrayToolbar</code> using |
2 |
26 Feb 07 |
jari |
* specified action manager. |
2 |
26 Feb 07 |
jari |
* @see ActionManager |
2 |
26 Feb 07 |
jari |
31 |
*/ |
2 |
26 Feb 07 |
jari |
32 |
public MultipleArrayToolbar(ActionManager manager) { |
2 |
26 Feb 07 |
jari |
33 |
addAlgorithmActions(manager); |
2 |
26 Feb 07 |
jari |
34 |
} |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
/** |
2 |
26 Feb 07 |
jari |
* Adds actions into the toolbar. |
2 |
26 Feb 07 |
jari |
38 |
*/ |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
private int algorithmCount(ActionManager manager){ |
2 |
26 Feb 07 |
jari |
41 |
int count=0; |
2 |
26 Feb 07 |
jari |
42 |
Action action; |
2 |
26 Feb 07 |
jari |
43 |
while ((action = manager.getAction(ActionManager.ANALYSIS_ACTION+String.valueOf(count)))!=null){ |
2 |
26 Feb 07 |
jari |
44 |
count++; |
2 |
26 Feb 07 |
jari |
45 |
} |
2 |
26 Feb 07 |
jari |
46 |
return count; |
2 |
26 Feb 07 |
jari |
47 |
} |
2 |
26 Feb 07 |
jari |
48 |
private void addAlgorithmActions(ActionManager manager) { |
2 |
26 Feb 07 |
jari |
49 |
int index = 0; |
2 |
26 Feb 07 |
jari |
50 |
Action action; |
2 |
26 Feb 07 |
jari |
51 |
String []category={"Clustering","Statistics","Classification","Data Reduction","Meta Analysis","Visualization","Miscellaneous"}; |
2 |
26 Feb 07 |
jari |
52 |
for(int i=0;i<category.length;i++){ |
2 |
26 Feb 07 |
jari |
53 |
while ((action = manager.getAction(ActionManager.ANALYSIS_ACTION+String.valueOf(index)))!=null) { |
2 |
26 Feb 07 |
jari |
54 |
if((action.getValue(ActionManager.CATEGORY)).equals(category[i])){ |
2 |
26 Feb 07 |
jari |
55 |
if(this.algorithmCount(manager)==TMEV.getCustomerAnalysis().length){ |
2 |
26 Feb 07 |
jari |
56 |
if(TMEV.getCustomerAnalysis()[index]==1) |
2 |
26 Feb 07 |
jari |
57 |
add(action); |
2 |
26 Feb 07 |
jari |
58 |
} |
2 |
26 Feb 07 |
jari |
59 |
else{ |
2 |
26 Feb 07 |
jari |
60 |
TMEV.initCustomerAnalysis(this.algorithmCount(manager)); |
2 |
26 Feb 07 |
jari |
61 |
index--; |
2 |
26 Feb 07 |
jari |
62 |
} |
2 |
26 Feb 07 |
jari |
63 |
} |
2 |
26 Feb 07 |
jari |
64 |
index++; |
2 |
26 Feb 07 |
jari |
65 |
} |
2 |
26 Feb 07 |
jari |
66 |
this.addSeparator(); |
2 |
26 Feb 07 |
jari |
67 |
index=0; |
2 |
26 Feb 07 |
jari |
68 |
} |
2 |
26 Feb 07 |
jari |
69 |
} |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
/** |
2 |
26 Feb 07 |
jari |
* Overriden from JToolBar. |
2 |
26 Feb 07 |
jari |
73 |
*/ |
2 |
26 Feb 07 |
jari |
74 |
public JButton add(Action a) { |
2 |
26 Feb 07 |
jari |
75 |
JButton button = super.add(a); |
2 |
26 Feb 07 |
jari |
76 |
button.setActionCommand((String)a.getValue(Action.ACTION_COMMAND_KEY)); |
2 |
26 Feb 07 |
jari |
77 |
button.setIcon((Icon)a.getValue(ActionManager.LARGE_ICON)); |
2 |
26 Feb 07 |
jari |
78 |
button.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
// button.setBackground(java.awt.Color.white); |
2 |
26 Feb 07 |
jari |
// button.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black)); |
2 |
26 Feb 07 |
jari |
81 |
return button; |
2 |
26 Feb 07 |
jari |
82 |
} |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of buttons with the same action command. |
2 |
26 Feb 07 |
jari |
86 |
*/ |
2 |
26 Feb 07 |
jari |
87 |
private AbstractButton[] getButtons(String command) { |
2 |
26 Feb 07 |
jari |
88 |
ArrayList list = new ArrayList(); |
2 |
26 Feb 07 |
jari |
89 |
Component[] components = getComponents(); |
2 |
26 Feb 07 |
jari |
90 |
for (int i = 0; i < components.length; i++) { |
2 |
26 Feb 07 |
jari |
91 |
if (components[i] instanceof AbstractButton) { |
2 |
26 Feb 07 |
jari |
92 |
if (((AbstractButton)components[i]).getActionCommand().equals(command)) |
2 |
26 Feb 07 |
jari |
93 |
list.add(components[i]); |
2 |
26 Feb 07 |
jari |
94 |
} |
2 |
26 Feb 07 |
jari |
95 |
} |
2 |
26 Feb 07 |
jari |
96 |
return (AbstractButton[])list.toArray(new AbstractButton[list.size()]); |
2 |
26 Feb 07 |
jari |
97 |
} |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
/** |
2 |
26 Feb 07 |
jari |
* Sets state of buttons with specified action command. |
2 |
26 Feb 07 |
jari |
101 |
*/ |
2 |
26 Feb 07 |
jari |
102 |
private void setEnable(String command, boolean enable) { |
2 |
26 Feb 07 |
jari |
103 |
AbstractButton[] buttons = getButtons(command); |
2 |
26 Feb 07 |
jari |
104 |
if (buttons == null || buttons.length < 1) { |
2 |
26 Feb 07 |
jari |
105 |
return; |
2 |
26 Feb 07 |
jari |
106 |
} |
2 |
26 Feb 07 |
jari |
107 |
for (int i=0; i<buttons.length; i++) { |
2 |
26 Feb 07 |
jari |
108 |
buttons[i].setEnabled(enable); |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
} |
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
/** |
2 |
26 Feb 07 |
jari |
* Disables some buttons according to specified state. |
2 |
26 Feb 07 |
jari |
114 |
*/ |
2 |
26 Feb 07 |
jari |
115 |
public void systemDisable(int state) { |
2 |
26 Feb 07 |
jari |
116 |
switch (state) { |
2 |
26 Feb 07 |
jari |
117 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
118 |
setEnable(ActionManager.LOAD_DB_COMMAND, false); |
2 |
26 Feb 07 |
jari |
119 |
setEnable(ActionManager.LOAD_FILE_COMMAND, false); |
2 |
26 Feb 07 |
jari |
120 |
setEnable(ActionManager.LOAD_EXPRESSION_COMMAND, false); |
2 |
26 Feb 07 |
jari |
121 |
setEnable(ActionManager.LOAD_DIRECTORY_COMMAND, false); |
2 |
26 Feb 07 |
jari |
122 |
break; |
2 |
26 Feb 07 |
jari |
123 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
124 |
setEnable(ActionManager.LOAD_DB_COMMAND, false); |
2 |
26 Feb 07 |
jari |
125 |
setEnable(ActionManager.SAVE_IMAGE_COMMAND, false); |
2 |
26 Feb 07 |
jari |
126 |
setEnable(ActionManager.PRINT_IMAGE_COMMAND, false); |
2 |
26 Feb 07 |
jari |
127 |
setEnable(ActionManager.ANALYSIS_COMMAND, false); |
2 |
26 Feb 07 |
jari |
128 |
break; |
2 |
26 Feb 07 |
jari |
129 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
130 |
setEnable(ActionManager.LOAD_DB_COMMAND, false); |
2 |
26 Feb 07 |
jari |
131 |
break; |
2 |
26 Feb 07 |
jari |
132 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
133 |
setEnable(ActionManager.LOAD_DB_COMMAND, false); |
2 |
26 Feb 07 |
jari |
134 |
break; |
2 |
26 Feb 07 |
jari |
135 |
} |
2 |
26 Feb 07 |
jari |
136 |
} |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
/** |
2 |
26 Feb 07 |
jari |
* Enables some buttons according to specified state. |
2 |
26 Feb 07 |
jari |
140 |
*/ |
2 |
26 Feb 07 |
jari |
141 |
public void systemEnable(int state) { |
2 |
26 Feb 07 |
jari |
142 |
switch (state) { |
2 |
26 Feb 07 |
jari |
143 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
144 |
setEnable(ActionManager.LOAD_FILE_COMMAND, true); |
2 |
26 Feb 07 |
jari |
145 |
setEnable(ActionManager.LOAD_DIRECTORY_COMMAND, true); |
2 |
26 Feb 07 |
jari |
146 |
setEnable(ActionManager.LOAD_EXPRESSION_COMMAND, true); |
2 |
26 Feb 07 |
jari |
147 |
break; |
2 |
26 Feb 07 |
jari |
148 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
149 |
setEnable(ActionManager.SAVE_IMAGE_COMMAND, true); |
2 |
26 Feb 07 |
jari |
150 |
setEnable(ActionManager.PRINT_IMAGE_COMMAND, true); |
2 |
26 Feb 07 |
jari |
151 |
setEnable(ActionManager.ANALYSIS_COMMAND, true); |
2 |
26 Feb 07 |
jari |
152 |
break; |
2 |
26 Feb 07 |
jari |
153 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
154 |
break; |
2 |
26 Feb 07 |
jari |
155 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
156 |
setEnable(ActionManager.LOAD_DB_COMMAND, true); |
2 |
26 Feb 07 |
jari |
157 |
break; |
2 |
26 Feb 07 |
jari |
158 |
} |
2 |
26 Feb 07 |
jari |
159 |
} |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
} |