|
Lines 28-33
Link Here
|
| 28 |
import org.eclipse.jface.viewers.TableViewer; |
28 |
import org.eclipse.jface.viewers.TableViewer; |
| 29 |
import org.eclipse.jface.viewers.TextCellEditor; |
29 |
import org.eclipse.jface.viewers.TextCellEditor; |
| 30 |
import org.eclipse.jface.viewers.TreeViewer; |
30 |
import org.eclipse.jface.viewers.TreeViewer; |
|
|
31 |
import org.eclipse.jface.viewers.ViewerComparator; |
| 31 |
import org.eclipse.swt.SWT; |
32 |
import org.eclipse.swt.SWT; |
| 32 |
import org.eclipse.swt.custom.CTabFolder; |
33 |
import org.eclipse.swt.custom.CTabFolder; |
| 33 |
import org.eclipse.swt.custom.CTabItem; |
34 |
import org.eclipse.swt.custom.CTabItem; |
|
Lines 35-59
Link Here
|
| 35 |
import org.eclipse.swt.events.ModifyListener; |
36 |
import org.eclipse.swt.events.ModifyListener; |
| 36 |
import org.eclipse.swt.events.SelectionAdapter; |
37 |
import org.eclipse.swt.events.SelectionAdapter; |
| 37 |
import org.eclipse.swt.events.SelectionEvent; |
38 |
import org.eclipse.swt.events.SelectionEvent; |
|
|
39 |
import org.eclipse.swt.graphics.Image; |
| 40 |
import org.eclipse.swt.graphics.Point; |
| 41 |
import org.eclipse.swt.graphics.Rectangle; |
| 38 |
import org.eclipse.swt.layout.FillLayout; |
42 |
import org.eclipse.swt.layout.FillLayout; |
| 39 |
import org.eclipse.swt.layout.GridData; |
43 |
import org.eclipse.swt.layout.GridData; |
| 40 |
import org.eclipse.swt.layout.GridLayout; |
44 |
import org.eclipse.swt.layout.GridLayout; |
| 41 |
import org.eclipse.swt.widgets.Button; |
45 |
import org.eclipse.swt.widgets.Button; |
| 42 |
import org.eclipse.swt.widgets.Composite; |
46 |
import org.eclipse.swt.widgets.Composite; |
| 43 |
import org.eclipse.swt.widgets.Menu; |
47 |
import org.eclipse.swt.widgets.Menu; |
|
|
48 |
import org.eclipse.swt.widgets.MenuItem; |
| 44 |
import org.eclipse.swt.widgets.Table; |
49 |
import org.eclipse.swt.widgets.Table; |
| 45 |
import org.eclipse.swt.widgets.TableColumn; |
50 |
import org.eclipse.swt.widgets.TableColumn; |
| 46 |
import org.eclipse.swt.widgets.TableItem; |
51 |
import org.eclipse.swt.widgets.TableItem; |
| 47 |
import org.eclipse.swt.widgets.Text; |
52 |
import org.eclipse.swt.widgets.Text; |
|
|
53 |
import org.eclipse.swt.widgets.ToolBar; |
| 54 |
import org.eclipse.swt.widgets.ToolItem; |
| 55 |
import org.eclipse.swt.widgets.Tree; |
| 48 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.ManagedAgentUIPlugin; |
56 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.ManagedAgentUIPlugin; |
| 49 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesCellModifier; |
57 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesCellModifier; |
| 50 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesViewContentProvider; |
58 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesViewContentProvider; |
| 51 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesViewLabelProvider; |
59 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.editor.PropertiesViewLabelProvider; |
|
|
60 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.filter.Comparator; |
| 61 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.filter.Filter; |
| 62 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.filter.FilterDialog; |
| 63 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.filter.MaxFilterPreference; |
| 52 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.util.ImageUtil; |
64 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.internal.util.ImageUtil; |
| 53 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.BrowserLabelProvider; |
65 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.BrowserLabelProvider; |
| 54 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.BrowserViewContentProvider; |
66 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.BrowserViewContentProvider; |
| 55 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.IBrowserNode; |
67 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.IBrowserNode; |
| 56 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.IViewContributor; |
68 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.IViewContributor; |
|
|
69 |
import org.eclipse.tptp.monitoring.managedagent.ui.explorer.provisional.controller.ManagedResourceNode; |
| 57 |
import org.eclipse.ui.IWorkbenchActionConstants; |
70 |
import org.eclipse.ui.IWorkbenchActionConstants; |
| 58 |
import org.eclipse.ui.PlatformUI; |
71 |
import org.eclipse.ui.PlatformUI; |
| 59 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
72 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
Lines 102-112
Link Here
|
| 102 |
|
115 |
|
| 103 |
private static MAExplorerView _default = null; |
116 |
private static MAExplorerView _default = null; |
| 104 |
|
117 |
|
|
|
118 |
private ViewerComparator _sorter; |
| 119 |
|
| 120 |
private boolean _sort = false; |
| 121 |
|
| 122 |
private Image _imgSort; |
| 123 |
|
| 124 |
private Image _imgFilter; |
| 125 |
|
| 126 |
private Image _imgUnSort; |
| 127 |
|
| 128 |
private MenuItem _miFilter; |
| 129 |
|
| 105 |
/** |
130 |
/** |
| 106 |
* The constructor. |
131 |
* The constructor. |
| 107 |
*/ |
132 |
*/ |
| 108 |
public MAExplorerView() { |
133 |
public MAExplorerView() { |
| 109 |
_default = this; |
134 |
_default = this; |
|
|
135 |
new MaxFilterPreference(); |
| 110 |
} |
136 |
} |
| 111 |
|
137 |
|
| 112 |
public static MAExplorerView getDefault() { |
138 |
public static MAExplorerView getDefault() { |
|
Lines 116-125
Link Here
|
| 116 |
return _default; |
142 |
return _default; |
| 117 |
} |
143 |
} |
| 118 |
|
144 |
|
| 119 |
public TreeViewer getTopologyViewer(){ |
145 |
public TreeViewer getTopologyViewer() { |
| 120 |
return _topologyViewer; |
146 |
return _topologyViewer; |
| 121 |
} |
147 |
} |
| 122 |
|
148 |
|
| 123 |
/** |
149 |
/** |
| 124 |
* This is a callback that will allow us to create the viewer and initialize |
150 |
* This is a callback that will allow us to create the viewer and initialize |
| 125 |
* it. |
151 |
* it. |
|
Lines 155-236
Link Here
|
| 155 |
|
181 |
|
| 156 |
private void layoutDetailsPanel(Composite parent) { |
182 |
private void layoutDetailsPanel(Composite parent) { |
| 157 |
createLabel(parent); |
183 |
createLabel(parent); |
| 158 |
|
184 |
|
| 159 |
//createTabFolder(parent); |
185 |
//createTabFolder(parent); |
| 160 |
|
186 |
|
| 161 |
createDetailsTextTab(parent); |
187 |
createDetailsTextTab(parent); |
| 162 |
} |
188 |
} |
| 163 |
|
189 |
|
| 164 |
private void createDetailsTextTab(Composite parent) { |
190 |
private void createDetailsTextTab(Composite parent) { |
| 165 |
_detailsText = _toolkit.createText(parent, new String(), SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL); |
191 |
_detailsText = _toolkit.createText(parent, new String(), SWT.BORDER |
|
|
192 |
| SWT.H_SCROLL | SWT.V_SCROLL); |
| 166 |
|
193 |
|
| 167 |
_propertiesViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
194 |
_propertiesViewer |
| 168 |
public void selectionChanged(SelectionChangedEvent event) { |
195 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
| 169 |
TableItem[] tableSelection = _propertiesViewer.getTable().getSelection(); |
196 |
public void selectionChanged(SelectionChangedEvent event) { |
|
|
197 |
TableItem[] tableSelection = _propertiesViewer |
| 198 |
.getTable().getSelection(); |
| 199 |
|
| 200 |
if (tableSelection.length > 0) { |
| 201 |
if (_detailsObject != tableSelection[0]) { |
| 202 |
checkDetailsAndSave(); |
| 203 |
} |
| 204 |
_detailsObject = tableSelection[0]; |
| 205 |
|
| 206 |
PropertiesViewLabelProvider labelProvier = (PropertiesViewLabelProvider) _propertiesViewer |
| 207 |
.getLabelProvider(); |
| 208 |
String text = labelProvier.getColumnText( |
| 209 |
_detailsObject.getData(), 1); |
| 210 |
if (text == null) { |
| 211 |
text = new String(); |
| 212 |
} |
| 213 |
|
| 214 |
_detailsText.removeModifyListener(_modifyListener); |
| 215 |
_detailsText.setText(text); |
| 216 |
_detailsText.setEnabled(true); |
| 217 |
_detailsText.addModifyListener(_modifyListener); |
| 218 |
} else { |
| 219 |
checkDetailsAndSave(); |
| 220 |
_detailsObject = null; |
| 221 |
} |
| 222 |
_applyButton.setEnabled(false); |
| 223 |
} |
| 224 |
}); |
| 170 |
|
225 |
|
| 171 |
if(tableSelection.length > 0) { |
226 |
_topologyViewer |
| 172 |
if(_detailsObject != tableSelection[0]) { |
227 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
|
|
228 |
public void selectionChanged(SelectionChangedEvent event) { |
| 173 |
checkDetailsAndSave(); |
229 |
checkDetailsAndSave(); |
| 174 |
} |
230 |
} |
| 175 |
_detailsObject = tableSelection[0]; |
231 |
}); |
| 176 |
|
232 |
|
| 177 |
PropertiesViewLabelProvider labelProvier = (PropertiesViewLabelProvider) _propertiesViewer.getLabelProvider(); |
|
|
| 178 |
String text = labelProvier.getColumnText(_detailsObject.getData(), 1); |
| 179 |
if(text == null) { |
| 180 |
text = new String(); |
| 181 |
} |
| 182 |
|
| 183 |
_detailsText.removeModifyListener(_modifyListener); |
| 184 |
_detailsText.setText(text); |
| 185 |
_detailsText.setEnabled(true); |
| 186 |
_detailsText.addModifyListener(_modifyListener); |
| 187 |
} else { |
| 188 |
checkDetailsAndSave(); |
| 189 |
_detailsObject = null; |
| 190 |
} |
| 191 |
_applyButton.setEnabled(false); |
| 192 |
} |
| 193 |
}); |
| 194 |
|
| 195 |
_topologyViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
| 196 |
public void selectionChanged(SelectionChangedEvent event) { |
| 197 |
checkDetailsAndSave(); |
| 198 |
} |
| 199 |
}); |
| 200 |
|
| 201 |
GridData gd = new GridData(); |
233 |
GridData gd = new GridData(); |
| 202 |
gd.grabExcessHorizontalSpace = true; |
234 |
gd.grabExcessHorizontalSpace = true; |
| 203 |
gd.grabExcessVerticalSpace = true; |
235 |
gd.grabExcessVerticalSpace = true; |
| 204 |
gd.horizontalAlignment = SWT.FILL; |
236 |
gd.horizontalAlignment = SWT.FILL; |
| 205 |
gd.verticalAlignment = SWT.FILL; |
237 |
gd.verticalAlignment = SWT.FILL; |
| 206 |
_detailsText.setLayoutData(gd); |
238 |
_detailsText.setLayoutData(gd); |
| 207 |
|
239 |
|
| 208 |
createApplyButton(parent); |
240 |
createApplyButton(parent); |
| 209 |
} |
241 |
} |
| 210 |
|
242 |
|
| 211 |
private void checkDetailsAndSave() { |
243 |
private void checkDetailsAndSave() { |
| 212 |
if(_applyButton.isEnabled()) { |
244 |
if (_applyButton.isEnabled()) { |
| 213 |
if(MessageDialog.openConfirm(_detailsText.getShell(), Messages.getString("MAExplorerView.DISCARD.UI."), Messages.getString("MAExplorerView.SAVE_QUESTION.UI."))) { //$NON-NLS-1$ //$NON-NLS-2$ |
245 |
if (MessageDialog |
|
|
246 |
.openConfirm( |
| 247 |
_detailsText.getShell(), |
| 248 |
Messages.getString("MAExplorerView.DISCARD.UI."), Messages.getString("MAExplorerView.SAVE_QUESTION.UI."))) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 214 |
_propertiesViewer.getCellModifier().modify(_detailsObject, |
249 |
_propertiesViewer.getCellModifier().modify(_detailsObject, |
| 215 |
PropertiesCellModifier.VALUE_PROPERTY, |
250 |
PropertiesCellModifier.VALUE_PROPERTY, |
| 216 |
_detailsText.getText()); |
251 |
_detailsText.getText()); |
| 217 |
} |
252 |
} |
| 218 |
} |
253 |
} |
| 219 |
_detailsText.setEnabled(false); |
254 |
_detailsText.setEnabled(false); |
| 220 |
_detailsText.removeModifyListener(_modifyListener); |
255 |
_detailsText.removeModifyListener(_modifyListener); |
| 221 |
_detailsText.setText(new String()); |
256 |
_detailsText.setText(new String()); |
| 222 |
_applyButton.setEnabled(false); |
257 |
_applyButton.setEnabled(false); |
| 223 |
} |
258 |
} |
| 224 |
|
259 |
|
| 225 |
private void createApplyButton(Composite parent) { |
260 |
private void createApplyButton(Composite parent) { |
| 226 |
_applyButton = _toolkit.createButton(parent, Messages.getString("MAExplorerView.APPLY.UI."), SWT.NONE); //$NON-NLS-1$ |
261 |
_applyButton = _toolkit.createButton(parent, Messages |
|
|
262 |
.getString("MAExplorerView.APPLY.UI."), SWT.NONE); //$NON-NLS-1$ |
| 227 |
|
263 |
|
| 228 |
_modifyListener = new ModifyListener() { |
264 |
_modifyListener = new ModifyListener() { |
| 229 |
public void modifyText(ModifyEvent e) { |
265 |
public void modifyText(ModifyEvent e) { |
| 230 |
_applyButton.setEnabled(true); |
266 |
_applyButton.setEnabled(true); |
| 231 |
} |
267 |
} |
| 232 |
}; |
268 |
}; |
| 233 |
|
269 |
|
| 234 |
_applyButton.addSelectionListener(new SelectionAdapter() { |
270 |
_applyButton.addSelectionListener(new SelectionAdapter() { |
| 235 |
public void widgetSelected(SelectionEvent e) { |
271 |
public void widgetSelected(SelectionEvent e) { |
| 236 |
saveDetailsData(); |
272 |
saveDetailsData(); |
|
Lines 245-264
Link Here
|
| 245 |
_applyButton.setLayoutData(gd); |
281 |
_applyButton.setLayoutData(gd); |
| 246 |
_applyButton.setEnabled(false); |
282 |
_applyButton.setEnabled(false); |
| 247 |
} |
283 |
} |
| 248 |
|
284 |
|
| 249 |
private void saveDetailsData() { |
285 |
private void saveDetailsData() { |
| 250 |
_propertiesViewer.getCellModifier().modify(_detailsObject, |
286 |
_propertiesViewer.getCellModifier().modify(_detailsObject, |
| 251 |
PropertiesCellModifier.VALUE_PROPERTY, |
287 |
PropertiesCellModifier.VALUE_PROPERTY, _detailsText.getText()); |
| 252 |
_detailsText.getText()); |
288 |
_applyButton.setEnabled(false); |
| 253 |
_applyButton.setEnabled(false); |
|
|
| 254 |
} |
289 |
} |
| 255 |
|
290 |
|
| 256 |
private void createTabFolder(Composite parent) { |
291 |
private void createTabFolder(Composite parent) { |
| 257 |
CTabFolder folder = new CTabFolder(parent, SWT.FLAT|SWT.TOP); |
292 |
CTabFolder folder = new CTabFolder(parent, SWT.FLAT | SWT.TOP); |
| 258 |
_toolkit.adapt(folder, true, true); |
293 |
_toolkit.adapt(folder, true, true); |
| 259 |
|
294 |
|
| 260 |
createTabs(folder); |
295 |
createTabs(folder); |
| 261 |
|
296 |
|
| 262 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
297 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
| 263 |
gd.heightHint = 0; |
298 |
gd.heightHint = 0; |
| 264 |
folder.setLayoutData(gd); |
299 |
folder.setLayoutData(gd); |
|
Lines 267-273
Link Here
|
| 267 |
private void createLabel(Composite parent) { |
302 |
private void createLabel(Composite parent) { |
| 268 |
Section label = _toolkit.createSection(parent, Section.TITLE_BAR); |
303 |
Section label = _toolkit.createSection(parent, Section.TITLE_BAR); |
| 269 |
label.setText(Messages.getString("MAExplorerView.VALUE_EDITOR.UI.")); //$NON-NLS-1$ |
304 |
label.setText(Messages.getString("MAExplorerView.VALUE_EDITOR.UI.")); //$NON-NLS-1$ |
| 270 |
|
305 |
|
| 271 |
GridData gd = new GridData(); |
306 |
GridData gd = new GridData(); |
| 272 |
gd.grabExcessHorizontalSpace = true; |
307 |
gd.grabExcessHorizontalSpace = true; |
| 273 |
gd.grabExcessVerticalSpace = false; |
308 |
gd.grabExcessVerticalSpace = false; |
|
Lines 276-282
Link Here
|
| 276 |
} |
311 |
} |
| 277 |
|
312 |
|
| 278 |
private void createTabs(CTabFolder folder) { |
313 |
private void createTabs(CTabFolder folder) { |
| 279 |
CTabItem item = new CTabItem(folder, SWT.NULL); |
314 |
CTabItem item = new CTabItem(folder, SWT.NULL); |
| 280 |
item.setText(Messages.getString("MAExplorerView.SOURCE.UI.")); //$NON-NLS-1$ |
315 |
item.setText(Messages.getString("MAExplorerView.SOURCE.UI.")); //$NON-NLS-1$ |
| 281 |
item = new CTabItem(folder, SWT.NULL); |
316 |
item = new CTabItem(folder, SWT.NULL); |
| 282 |
item.setText(Messages.getString("MAExplorerView.DESIGN.UI.")); //$NON-NLS-1$ |
317 |
item.setText(Messages.getString("MAExplorerView.DESIGN.UI.")); //$NON-NLS-1$ |
|
Lines 301-307
Link Here
|
| 301 |
table.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); |
336 |
table.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); |
| 302 |
|
337 |
|
| 303 |
TableColumn propertyColumn = new TableColumn(table, SWT.LEFT); |
338 |
TableColumn propertyColumn = new TableColumn(table, SWT.LEFT); |
| 304 |
propertyColumn.setText(Messages.getString("MAExplorerView.PROPERTY.UI.")); //$NON-NLS-1$ |
339 |
propertyColumn.setText(Messages |
|
|
340 |
.getString("MAExplorerView.PROPERTY.UI.")); //$NON-NLS-1$ |
| 305 |
propertyColumn.setWidth(140); |
341 |
propertyColumn.setWidth(140); |
| 306 |
TableColumn valueColumn = new TableColumn(table, SWT.LEFT); |
342 |
TableColumn valueColumn = new TableColumn(table, SWT.LEFT); |
| 307 |
valueColumn.setText(Messages.getString("MAExplorerView.VALUE.UI.")); //$NON-NLS-1$ |
343 |
valueColumn.setText(Messages.getString("MAExplorerView.VALUE.UI.")); //$NON-NLS-1$ |
|
Lines 318-336
Link Here
|
| 318 |
gd.horizontalAlignment = SWT.FILL; |
354 |
gd.horizontalAlignment = SWT.FILL; |
| 319 |
gd.verticalAlignment = SWT.FILL; |
355 |
gd.verticalAlignment = SWT.FILL; |
| 320 |
table.setLayoutData(gd); |
356 |
table.setLayoutData(gd); |
| 321 |
|
357 |
|
| 322 |
createPropertiesEditors(); |
358 |
createPropertiesEditors(); |
| 323 |
} |
359 |
} |
| 324 |
|
360 |
|
| 325 |
private void createPropertiesEditors() { |
361 |
private void createPropertiesEditors() { |
| 326 |
CellEditor[] editors = new CellEditor[2]; |
362 |
CellEditor[] editors = new CellEditor[2]; |
| 327 |
editors[0] = new TextCellEditor(_propertiesViewer.getTable()); |
363 |
editors[0] = new TextCellEditor(_propertiesViewer.getTable()); |
| 328 |
editors[1] = new TextCellEditor(_propertiesViewer.getTable(), SWT.READ_ONLY); |
364 |
editors[1] = new TextCellEditor(_propertiesViewer.getTable(), |
|
|
365 |
SWT.READ_ONLY); |
| 329 |
_propertiesViewer.setCellEditors(editors); |
366 |
_propertiesViewer.setCellEditors(editors); |
| 330 |
_propertiesViewer.setCellModifier(new PropertiesCellModifier(_propertiesViewer)); |
367 |
_propertiesViewer.setCellModifier(new PropertiesCellModifier( |
| 331 |
_propertiesViewer.setColumnProperties(new String[] {Messages.getString("MAExplorerView.PROPERTY.UI."),Messages.getString("MAExplorerView.VALUE.UI.")}); //$NON-NLS-1$ //$NON-NLS-2$ |
368 |
_propertiesViewer)); |
|
|
369 |
_propertiesViewer |
| 370 |
.setColumnProperties(new String[] { |
| 371 |
Messages.getString("MAExplorerView.PROPERTY.UI."), Messages.getString("MAExplorerView.VALUE.UI.") }); //$NON-NLS-1$ //$NON-NLS-2$ |
| 332 |
} |
372 |
} |
| 333 |
|
373 |
|
| 334 |
private void layoutAgentTopologyTree() { |
374 |
private void layoutAgentTopologyTree() { |
| 335 |
|
375 |
|
| 336 |
Composite parent = _toolkit.createComposite(_form.getBody()); |
376 |
Composite parent = _toolkit.createComposite(_form.getBody()); |
|
Lines 340-355
Link Here
|
| 340 |
layout.marginHeight = DEFAULT_PADDING; |
380 |
layout.marginHeight = DEFAULT_PADDING; |
| 341 |
layout.marginWidth = DEFAULT_PADDING; |
381 |
layout.marginWidth = DEFAULT_PADDING; |
| 342 |
layout.numColumns = 1; |
382 |
layout.numColumns = 1; |
| 343 |
|
383 |
|
| 344 |
parent.setLayout(layout); |
384 |
parent.setLayout(layout); |
| 345 |
|
385 |
|
| 346 |
Section label = _toolkit.createSection(parent, Section.TITLE_BAR); |
386 |
Section label = _toolkit.createSection(parent, Section.TITLE_BAR); |
| 347 |
label.setText(Messages.getString("MAExplorerView.RESOURCE_TOPOLOGY.UI.")); //$NON-NLS-1$ |
387 |
label.setText(Messages |
|
|
388 |
.getString("MAExplorerView.RESOURCE_TOPOLOGY.UI.")); //$NON-NLS-1$ |
| 348 |
GridData gd = new GridData(); |
389 |
GridData gd = new GridData(); |
| 349 |
gd.grabExcessHorizontalSpace = true; |
390 |
gd.grabExcessHorizontalSpace = true; |
| 350 |
gd.grabExcessVerticalSpace = false; |
391 |
gd.grabExcessVerticalSpace = false; |
| 351 |
gd.horizontalAlignment = SWT.FILL; |
392 |
gd.horizontalAlignment = SWT.FILL; |
| 352 |
label.setLayoutData(gd); |
393 |
label.setLayoutData(gd); |
|
|
394 |
|
| 395 |
_sorter = new Comparator(); |
| 396 |
addSortAndFilterToolBar(label); |
| 353 |
|
397 |
|
| 354 |
_topologyViewer = new TreeViewer(parent); |
398 |
_topologyViewer = new TreeViewer(parent); |
| 355 |
|
399 |
|
|
Lines 383-393
Link Here
|
| 383 |
getSite().setSelectionProvider(_topologyViewer); |
427 |
getSite().setSelectionProvider(_topologyViewer); |
| 384 |
|
428 |
|
| 385 |
} |
429 |
} |
| 386 |
|
430 |
|
| 387 |
private void hookupSelectionListeners(){ |
431 |
private void hookupSelectionListeners() { |
| 388 |
ISelectionChangedListener[] listeners = ManagedAgentUIPlugin.getSelectionListeners(); |
432 |
ISelectionChangedListener[] listeners = ManagedAgentUIPlugin |
| 389 |
if(listeners!=null){ |
433 |
.getSelectionListeners(); |
| 390 |
for(int i=0; i<listeners.length; i++){ |
434 |
if (listeners != null) { |
|
|
435 |
for (int i = 0; i < listeners.length; i++) { |
| 391 |
_topologyViewer.addSelectionChangedListener(listeners[i]); |
436 |
_topologyViewer.addSelectionChangedListener(listeners[i]); |
| 392 |
} |
437 |
} |
| 393 |
} |
438 |
} |
|
Lines 435-441
Link Here
|
| 435 |
manager.add(new Separator()); |
480 |
manager.add(new Separator()); |
| 436 |
|
481 |
|
| 437 |
// Other plug-ins can contribute their actions here |
482 |
// Other plug-ins can contribute their actions here |
| 438 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); |
483 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 439 |
} |
484 |
} |
| 440 |
|
485 |
|
| 441 |
private void contributeToActionBars() { |
486 |
private void contributeToActionBars() { |
|
Lines 449-464
Link Here
|
| 449 |
_drillDownAdapter.addNavigationActions(manager); |
494 |
_drillDownAdapter.addNavigationActions(manager); |
| 450 |
} |
495 |
} |
| 451 |
|
496 |
|
|
|
497 |
private void addSortAndFilterToolBar(Section label) { |
| 498 |
Composite sfComp = _toolkit.createComposite(label); |
| 499 |
sfComp.setLayout(new FillLayout()); |
| 500 |
ToolBar tb = new ToolBar(sfComp, SWT.NONE); |
| 501 |
ToolItem ti = new ToolItem(tb, SWT.DROP_DOWN); |
| 502 |
_imgSort = ImageUtil.getImage(ImageUtil.SORT_IMAGE); |
| 503 |
ti.setImage(_imgSort); |
| 504 |
|
| 505 |
_imgUnSort = ImageUtil.getImage(ImageUtil.UNSORT_IMAGE); |
| 506 |
|
| 507 |
Menu ddMenu = new Menu(ti.getParent().getShell(), SWT.NONE); |
| 508 |
_miFilter = new MenuItem(ddMenu, SWT.NONE); |
| 509 |
_imgFilter = ImageUtil.getImage(ImageUtil.FILTER_IMAGE); |
| 510 |
_miFilter.setImage(_imgFilter); |
| 511 |
_miFilter.setText(Messages.getString("MAExplorerView.FILTER.UI.")); |
| 512 |
|
| 513 |
addMenuItemSelectionListener(); |
| 514 |
addToolItemSelectionListener(ti, ddMenu); |
| 515 |
|
| 516 |
_toolkit.adapt(sfComp); |
| 517 |
label.setTextClient(sfComp); |
| 518 |
} |
| 519 |
|
| 520 |
private void addMenuItemSelectionListener() { |
| 521 |
_miFilter.addSelectionListener(new SelectionAdapter() { |
| 522 |
public void widgetSelected(SelectionEvent se) { |
| 523 |
Filter filter = new FilterDialog().showWindow(); |
| 524 |
if (filter == null) { |
| 525 |
return; |
| 526 |
} |
| 527 |
|
| 528 |
IBrowserNode root = _topologyViewContentProvider.getRoot(); |
| 529 |
|
| 530 |
// if this is a service group then we can apply this filter |
| 531 |
// note that we do not check if it has members coz it might be an empty service group at this point and more members might be added later |
| 532 |
|
| 533 |
System.out.println("root instanceof ManagedResourceNode = "+(root instanceof ManagedResourceNode)); |
| 534 |
System.out.println(root.getClass()); |
| 535 |
Object[] children = root.getChildren(); |
| 536 |
|
| 537 |
// the first child is what we want |
| 538 |
IBrowserNode child = null; |
| 539 |
try{ |
| 540 |
child = (IBrowserNode) children[0]; |
| 541 |
}catch(ArrayIndexOutOfBoundsException ae){ |
| 542 |
|
| 543 |
} |
| 544 |
if(child != null |
| 545 |
&& child instanceof ManagedResourceNode){ |
| 546 |
((ManagedResourceNode)child).setFilter(filter); |
| 547 |
} |
| 548 |
|
| 549 |
// this filtering must not be done here - it should be done by the ManagedResourceNode in figuring out which of its children to show |
| 550 |
/* |
| 551 |
Object[] children = root.getChildren(); |
| 552 |
for (int i = 0; i < children.length; i++) { |
| 553 |
root.removeChild((IBrowserNode) children[i]); |
| 554 |
} |
| 555 |
FilterUtil.setFilter(filter); |
| 556 |
System.out.println("FILTER STRING: " + filter.toString()); |
| 557 |
ManagedResource[] resources = FilterUtil.getManagedResources(); |
| 558 |
if (resources == null || resources.length<0) { |
| 559 |
return; |
| 560 |
} |
| 561 |
_topologyViewContentProvider.setFilterMatch(false); |
| 562 |
|
| 563 |
boolean match = _topologyViewContentProvider.getFilterMatch(); |
| 564 |
if (!match) { |
| 565 |
MessageDialog |
| 566 |
.openInformation( |
| 567 |
_topologyViewer.getControl().getShell(), |
| 568 |
Messages |
| 569 |
.getString("MAExplorerView.FILTER.TITILE.UI."), |
| 570 |
Messages |
| 571 |
.getString("MAExplorerView.FILTER.MESSAGE.UI.")); |
| 572 |
_topologyViewer.setInput(null); |
| 573 |
} |
| 574 |
*/ |
| 575 |
} |
| 576 |
}); |
| 577 |
} |
| 578 |
|
| 579 |
private void addToolItemSelectionListener(ToolItem ti, final Menu ddMenu) { |
| 580 |
ti.addSelectionListener(new SelectionAdapter() { |
| 581 |
public void widgetSelected(SelectionEvent se) { |
| 582 |
ToolItem item = (ToolItem) se.widget; |
| 583 |
if (se.detail == SWT.ARROW) { |
| 584 |
// Determine where to put the dropdown list |
| 585 |
Rectangle rect = item.getBounds(); |
| 586 |
Point pt = item.getParent().toDisplay( |
| 587 |
new Point(rect.x, rect.y)); |
| 588 |
ddMenu.setLocation(pt.x, pt.y + rect.height); |
| 589 |
ddMenu.setVisible(true); |
| 590 |
} else { |
| 591 |
_sort = !_sort; |
| 592 |
if (_sort) { |
| 593 |
item.setImage(_imgUnSort); |
| 594 |
Tree tree = _topologyViewer.getTree(); |
| 595 |
if (tree != null) { |
| 596 |
_topologyViewer.setComparator(_sorter); |
| 597 |
} |
| 598 |
} else { |
| 599 |
item.setImage(_imgSort); |
| 600 |
_topologyViewer.setComparator(null); |
| 601 |
} |
| 602 |
} |
| 603 |
} |
| 604 |
}); |
| 605 |
} |
| 606 |
|
| 452 |
private void makeActions() { |
607 |
private void makeActions() { |
| 453 |
_refreshPropertiesAction = new Action() { |
608 |
_refreshPropertiesAction = new Action() { |
| 454 |
public void run() { |
609 |
public void run() { |
| 455 |
getViewerSelection().refresh(); |
610 |
if(getViewerSelection()!=null){ |
| 456 |
_propertiesViewer.refresh(); |
611 |
getViewerSelection().refresh(); |
|
|
612 |
_propertiesViewer.refresh(); |
| 613 |
}else{ |
| 614 |
// TODO figure out if we can refresh something else |
| 615 |
} |
| 457 |
} |
616 |
} |
| 458 |
}; |
617 |
}; |
| 459 |
|
618 |
|
| 460 |
_refreshPropertiesAction.setText(Messages.getString("MAExplorerView.REFRESH_PROPS.UI.")); //$NON-NLS-1$ |
619 |
_refreshPropertiesAction.setText(Messages |
| 461 |
_refreshPropertiesAction.setToolTipText(Messages.getString("MAExplorerView.REFRESH_PROPS.UI.")); //$NON-NLS-1$ |
620 |
.getString("MAExplorerView.REFRESH_PROPS.UI.")); //$NON-NLS-1$ |
|
|
621 |
_refreshPropertiesAction.setToolTipText(Messages |
| 622 |
.getString("MAExplorerView.REFRESH_PROPS.UI.")); //$NON-NLS-1$ |
| 462 |
_refreshPropertiesAction.setImageDescriptor(ImageUtil |
623 |
_refreshPropertiesAction.setImageDescriptor(ImageUtil |
| 463 |
.getDescriptor(ImageUtil.REFRESH_PROPERTIES)); |
624 |
.getDescriptor(ImageUtil.REFRESH_PROPERTIES)); |
| 464 |
} |
625 |
} |
|
Lines 489-493
Link Here
|
| 489 |
_toolkit.dispose(); |
650 |
_toolkit.dispose(); |
| 490 |
super.dispose(); |
651 |
super.dispose(); |
| 491 |
} |
652 |
} |
| 492 |
|
653 |
|
| 493 |
} |
654 |
} |