KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > preferences > PerspectivePreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.debug.internal.ui.preferences;
13
14 import java.io.IOException JavaDoc;
15 import java.io.StringReader JavaDoc;
16 import com.ibm.icu.text.MessageFormat;
17 import java.util.ArrayList JavaDoc;
18 import java.util.HashMap JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 import javax.xml.parsers.DocumentBuilder JavaDoc;
22 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
23 import javax.xml.parsers.ParserConfigurationException JavaDoc;
24
25 import org.eclipse.debug.core.DebugPlugin;
26 import org.eclipse.debug.core.ILaunchConfigurationType;
27 import org.eclipse.debug.core.ILaunchManager;
28 import org.eclipse.debug.core.ILaunchMode;
29 import org.eclipse.debug.internal.ui.DebugUIPlugin;
30 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
31 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
32 import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
33 import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupFilter;
34 import org.eclipse.debug.internal.ui.launchConfigurations.PerspectiveManager;
35 import org.eclipse.debug.ui.DebugUITools;
36 import org.eclipse.debug.ui.IDebugUIConstants;
37 import org.eclipse.jface.dialogs.Dialog;
38 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
39 import org.eclipse.jface.preference.IPreferenceStore;
40 import org.eclipse.jface.preference.PreferencePage;
41 import org.eclipse.jface.preference.RadioGroupFieldEditor;
42 import org.eclipse.jface.viewers.ISelectionChangedListener;
43 import org.eclipse.jface.viewers.IStructuredSelection;
44 import org.eclipse.jface.viewers.SelectionChangedEvent;
45 import org.eclipse.jface.viewers.TreeViewer;
46 import org.eclipse.swt.SWT;
47 import org.eclipse.swt.events.SelectionAdapter;
48 import org.eclipse.swt.events.SelectionEvent;
49 import org.eclipse.swt.graphics.Font;
50 import org.eclipse.swt.layout.GridData;
51 import org.eclipse.swt.layout.GridLayout;
52 import org.eclipse.swt.widgets.Combo;
53 import org.eclipse.swt.widgets.Composite;
54 import org.eclipse.swt.widgets.Control;
55 import org.eclipse.swt.widgets.Label;
56 import org.eclipse.swt.widgets.Tree;
57 import org.eclipse.swt.widgets.TreeItem;
58 import org.eclipse.ui.IPerspectiveDescriptor;
59 import org.eclipse.ui.IPerspectiveRegistry;
60 import org.eclipse.ui.IWorkbench;
61 import org.eclipse.ui.IWorkbenchPreferencePage;
62 import org.eclipse.ui.PlatformUI;
63 import org.eclipse.ui.activities.ActivityManagerEvent;
64 import org.eclipse.ui.activities.IActivityManagerListener;
65 import org.eclipse.ui.activities.WorkbenchActivityHelper;
66 import org.eclipse.ui.model.WorkbenchViewerSorter;
67 import org.w3c.dom.Element JavaDoc;
68 import org.w3c.dom.Node JavaDoc;
69 import org.w3c.dom.NodeList JavaDoc;
70 import org.xml.sax.InputSource JavaDoc;
71 import org.xml.sax.SAXException JavaDoc;
72 import org.xml.sax.helpers.DefaultHandler JavaDoc;
73
74 /**
75  * Provides one place to set perspective preferences
76  *
77  * @since 3.2
78  */

79 public class PerspectivePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IDebugPreferenceConstants, IActivityManagerListener {
80
81     // constants
82
private static final String JavaDoc DEBUG_LAUNCH_GROUP = "org.eclipse.debug.ui.launchGroup.debug"; //$NON-NLS-1$
83

84     private static final String JavaDoc LAST_SELECTED_CONFIGTYPE = "last_selected"; //$NON-NLS-1$
85

86     private static final int LABEL_WIDTH_HINT = 450;
87
88     /**
89      * A composite to add and dispose fComboComposites from
90      */

91     private Composite fPerspectiveComp = null;
92     
93     /**
94      * Launch configuration type to mode mapping. allows us to store all the
95      * changed information until ok, apply or cancel is pressed Formed as
96      * follows: Map<typeId,HashMap<modeId, perspective>>
97      */

98     private HashMap JavaDoc fTypeInformationMapping = null;
99
100     /**
101      * The list of perspective labels
102      */

103     private String JavaDoc[] fPerspectiveLabels = null;
104
105     /**
106      * A mapping of perspective labels to ids of the form Map<label, id>
107      */

108     private HashMap JavaDoc fPerspectiveIds = null;
109
110     /**
111      * the composite to add the combo boxes and their labels to
112      */

113     private Composite fComboPlaceHolder = null;
114
115     /**
116      * the viewer for the list of launch configurations
117      */

118     private TreeViewer fViewer = null;
119
120     /**
121      * The tree for the viewer
122      */

123     private Tree fTree = null;
124
125     /**
126      * Manages a launch configuration
127      */

128     private ILaunchManager fLManager = DebugPlugin.getDefault().getLaunchManager();
129
130     /**
131      * The global manager for all launch configurations
132      */

133     private LaunchConfigurationManager fLCM = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
134
135     /**
136      * manages perspectives
137      */

138     private PerspectiveManager fPmanager = DebugUIPlugin.getDefault().getPerspectiveManager();
139
140     /**
141      * The field for switching perspective on run/debug
142      */

143     private RadioGroupFieldEditor perspec = null;
144
145     /**
146      * The field for switching when suspends
147      */

148     private RadioGroupFieldEditor suspend = null;
149
150     /**
151      * The currently selected ILaunchConfiguration from the tree
152      */

153     private ILaunchConfigurationType fCurrentType = null;
154
155     /**
156      * listens for widgets to change their selection. In this case we use it
157      * soley for setting changes in any of the combo boxes for perspective
158      * types.
159      */

160     private SelectionAdapter fSelectionAdapter = new SelectionAdapter() {
161         public void widgetSelected(SelectionEvent e) {
162             Object JavaDoc source = e.getSource();
163             if (source instanceof Combo) {
164                 Combo combo = (Combo) source;
165                 HashMap JavaDoc map = (HashMap JavaDoc) fTypeInformationMapping.get(fCurrentType);
166                 if (map == null) {
167                     map = new HashMap JavaDoc();
168                 }// end if
169
map.put(combo.getData(), fPerspectiveIds.get(combo.getText()));
170                 fTypeInformationMapping.put(fCurrentType, map);
171             }// end if
172
}// end widgetselected
173
};
174
175     /**
176      * Default constructor
177      */

178     public PerspectivePreferencePage() {
179         IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
180         setPreferenceStore(store);
181         setTitle(DebugPreferencesMessages.PerspectivePreferencePage_6);
182         setDescription(DebugPreferencesMessages.PerspectivePreferencePage_0);
183     }// end constructor
184

185     /*
186      * (non-Javadoc)
187      *
188      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
189      */

190     public boolean performOk() {
191         IPreferenceStore store = getPreferenceStore();
192         perspec.store();
193         suspend.store();
194         for (Iterator JavaDoc iter = fTypeInformationMapping.keySet().iterator(); iter.hasNext();) {
195             ILaunchConfigurationType typekey = (ILaunchConfigurationType)iter.next();
196             HashMap JavaDoc map = (HashMap JavaDoc) fTypeInformationMapping.get(typekey);
197             for (Iterator JavaDoc iter2 = map.keySet().iterator(); iter2.hasNext();) {
198                 String JavaDoc modekey = (String JavaDoc) iter2.next();
199                 String JavaDoc perspective = (String JavaDoc) map.get(modekey);
200                 if (perspective != null) {
201                     if (perspective.equals(DebugPreferencesMessages.PerspectivePreferencePage_4)) {
202                         perspective = IDebugUIConstants.PERSPECTIVE_NONE;
203                     }// end if
204
}// end if
205
else {
206                     perspective = IDebugUIConstants.PERSPECTIVE_NONE;
207                 }//end else
208
fPmanager.setLaunchPerspective(typekey, modekey, perspective);
209             }// end for
210
}// end for
211
if(fCurrentType != null) {
212             store.setValue(LAST_SELECTED_CONFIGTYPE, fCurrentType.getName());
213         }
214         DebugUIPlugin.getDefault().savePluginPreferences();
215         return super.performOk();
216     }// end performOK
217

218     /*
219      * (non-Javadoc)
220      *
221      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
222      */

223     public void init(IWorkbench workbench) {}
224
225     /**
226      * Restore the state from the preference store
227      */

228     private void restoreState() {
229         String JavaDoc xml = getPreferenceStore().getString(IInternalDebugUIConstants.PREF_LAUNCH_PERSPECTIVES);
230 // bug 111485 in case a new plugin offers a launch type between invocations, do this prior to setting them to saved states
231
setDefaultPerspectives();
232         if (xml != null && xml.length() > 0) {
233             try {
234                 Element JavaDoc root = null;
235                 DocumentBuilder JavaDoc parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
236                 parser.setErrorHandler(new DefaultHandler JavaDoc());
237                 StringReader JavaDoc reader = new StringReader JavaDoc(xml);
238                 InputSource JavaDoc source = new InputSource JavaDoc(reader);
239                 root = parser.parse(source).getDocumentElement();
240                 NodeList JavaDoc list = root.getChildNodes();
241                 int length = list.getLength();
242                 for (int i = 0; i < length; ++i) {
243                     Node JavaDoc node = list.item(i);
244                     short nt = node.getNodeType();
245                     if (nt == Node.ELEMENT_NODE) {
246                         Element JavaDoc element = (Element JavaDoc) node;
247                         String JavaDoc nodeName = element.getNodeName();
248                         if (nodeName.equalsIgnoreCase(PerspectiveManager.ELEMENT_PERSPECTIVE)) {
249                             String JavaDoc type = element.getAttribute(PerspectiveManager.ATTR_TYPE_ID);
250                             ILaunchConfigurationType typeobj = fLManager.getLaunchConfigurationType(type);
251                             String JavaDoc mode = element.getAttribute(PerspectiveManager.ATTR_MODE_ID);
252                             if(typeobj != null) {
253                                 String JavaDoc perspective = fPmanager.getLaunchPerspective(typeobj, mode);
254                                 HashMap JavaDoc map = (HashMap JavaDoc) fTypeInformationMapping.get(typeobj);
255                                 if(map == null) {
256                                     map = new HashMap JavaDoc();
257                                 }//end if
258
map.put(mode, (perspective != null ? perspective : IDebugUIConstants.PERSPECTIVE_NONE));
259                                 fTypeInformationMapping.put(typeobj, map);
260                             }//end if
261
}// end if
262
}// end if
263
}// end for
264
}// end try
265
catch (ParserConfigurationException JavaDoc e) {DebugUIPlugin.log(e);}
266             catch (SAXException JavaDoc e) {DebugUIPlugin.log(e);}
267             catch (IOException JavaDoc e) {DebugUIPlugin.log(e);}
268         }// end if
269
perspec.load();
270         suspend.load();
271         TreeItem item = findLastSelected(getPreferenceStore().getString(LAST_SELECTED_CONFIGTYPE));
272         if (item != null) {
273             fTree.setSelection(new TreeItem[] { item });
274         }// end if
275
else {
276             if(fTree.getItemCount() > 0) {
277                 fTree.setSelection(new TreeItem[] { fTree.getItem(0) });
278             }
279         }// end else
280
fCurrentType = (ILaunchConfigurationType) ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
281         buildComboBoxes(fCurrentType);
282     }// restoreState
283

284     /**
285      * Sets the default perspectives for the modes of an ILaunchConfiguration
286      */

287     private void setDefaultPerspectives() {
288         ILaunchConfigurationType[] types = fLManager.getLaunchConfigurationTypes();
289         ArrayList JavaDoc modes = null;
290         HashMap JavaDoc map = null;
291         for (int i = 0; i < types.length; i++) {
292             modes = new ArrayList JavaDoc(types[i].getSupportedModes());
293             map = new HashMap JavaDoc();
294             for (int j = 0; j < modes.size(); j++) {
295                 String JavaDoc mode = (String JavaDoc) modes.get(j);
296                 String JavaDoc persp = fPmanager.getDefaultLaunchPerspective(types[i], mode);
297                 map.put(mode, (persp != null ? persp : IDebugUIConstants.PERSPECTIVE_NONE));
298             }// end for
299
fTypeInformationMapping.put(types[i], map);
300         }// end for
301
}//setDefaultPerspective
302

303     /**
304      * Finds the ILaunchConfiguration within the tree based on its text
305      *
306      * @param last
307      * the name of the last Launch Configuration selected
308      * @return the treeitem if found or null
309      */

310     private TreeItem findLastSelected(String JavaDoc last) {
311         TreeItem[] selection = fTree.getItems();
312         for (int i = 0; i < selection.length; i++) {
313             if (selection[i].getText().equals(last)) {
314                 return selection[i];
315             }// end if
316
}// end for
317
return null;
318     }// end findLastSelected
319

320     /**
321      * Builds all possible combo boxes per supported modes
322      */

323     private void buildComboBoxes(ILaunchConfigurationType type) {
324         HashMap JavaDoc launchmodes = (HashMap JavaDoc) fTypeInformationMapping.get(type);
325         if (fComboPlaceHolder != null) {
326             fComboPlaceHolder.dispose();
327         }// end if
328
Font font = fPerspectiveComp.getFont();
329         fComboPlaceHolder = new Composite(fPerspectiveComp, SWT.NONE);
330         fComboPlaceHolder.setLayout(new GridLayout(2, false));
331         fComboPlaceHolder.setLayoutData(new GridData(GridData.FILL_BOTH));
332         fComboPlaceHolder.setFont(font);
333         Label label = new Label(fComboPlaceHolder, SWT.NONE);
334         label.setText(DebugPreferencesMessages.PerspectivePreferencePage_2);
335         label.setFont(font);
336         GridData gd = null;
337         gd = new GridData(GridData.FILL_HORIZONTAL);
338         gd.horizontalSpan = 2;
339         label.setLayoutData(gd);
340         if(launchmodes != null) {
341             for(Iterator JavaDoc iter = launchmodes.keySet().iterator(); iter.hasNext();) {
342                 String JavaDoc modekey = (String JavaDoc)iter.next();
343                 String JavaDoc persp = (String JavaDoc)launchmodes.get(modekey);
344            // build label
345
label = new Label(fComboPlaceHolder, SWT.NONE);
346                 label.setFont(font);
347                 gd = new GridData(GridData.BEGINNING);
348                 label.setLayoutData(gd);
349                 ILaunchMode mode = fLManager.getLaunchMode(modekey);
350                 String JavaDoc clabel = mode.getLabel();
351                 //resolve conflict with Default and Debug mneumonics bug 122882
352
if(clabel.equals(DebugPreferencesMessages.PerspectivePreferencePage_7)) {
353                     clabel = DebugPreferencesMessages.PerspectivePreferencePage_8;
354                 }
355                 label.setText(MessageFormat.format(DebugPreferencesMessages.PerspectivePreferencePage_3, new String JavaDoc[] { clabel }));
356             // build combobox
357
Combo combo = new Combo(fComboPlaceHolder, SWT.READ_ONLY);
358                 combo.setFont(font);
359                 combo.setItems(fPerspectiveLabels);
360                 combo.setData(modekey);
361                 gd = new GridData(GridData.BEGINNING);
362                 combo.setLayoutData(gd);
363                 if(persp.equals(IDebugUIConstants.PERSPECTIVE_NONE)) {
364                     persp = DebugPreferencesMessages.PerspectivePreferencePage_4;
365                 }//end if
366
else {
367                     IPerspectiveDescriptor desc = PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(persp);
368                     persp = (desc != null ? desc.getLabel() : DebugPreferencesMessages.PerspectivePreferencePage_4);
369                 }//end else
370
combo.setText(persp);
371                 combo.addSelectionListener(fSelectionAdapter);
372             }//end for
373
}
374         fPerspectiveComp.layout();
375     }// buildComboBoxes
376

377     /**
378      * Handles the change in selection from the launch configuration listing
379      *
380      * @param event
381      * the selection changed event
382      */

383     private void handleLaunchConfigurationSelectionChanged(SelectionChangedEvent event) {
384         // handle prompting and saving before moving on.
385
ILaunchConfigurationType type = (ILaunchConfigurationType) ((IStructuredSelection) event.getSelection()).getFirstElement();
386         if(type != null) {
387             if(!type.equals(fCurrentType)) {
388                 //if they are the same do nothing
389
fCurrentType = type;
390                 buildComboBoxes(fCurrentType);
391             }
392         }
393     }// end handleLaunchConfigurationSelectionChanged
394

395     /**
396      * Gets the perspective labels
397      *
398      * @return the (label, id) mappings of perspectives
399      */

400     private void getPerspectiveLabels() {
401         IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
402         IPerspectiveDescriptor[] descriptors = filterIds(registry.getPerspectives());
403         fPerspectiveLabels = new String JavaDoc[descriptors.length + 1];
404         fPerspectiveLabels[0] = DebugPreferencesMessages.PerspectivePreferencePage_4;
405         fPerspectiveIds = new HashMap JavaDoc();
406         for (int i = 0; i < descriptors.length; i++) {
407             fPerspectiveLabels[i + 1] = descriptors[i].getLabel();
408             fPerspectiveIds.put(descriptors[i].getLabel(), descriptors[i].getId());
409         }// end for
410
}// end getPerspectiveLabels
411

412     /**
413      * filters the list of labels based on capabilities
414      * @param ids ther ids we want to filter
415      * @return the filtered list of ids based on capabilities
416      */

417     private IPerspectiveDescriptor[] filterIds(IPerspectiveDescriptor[] ids) {
418         ArrayList JavaDoc list = new ArrayList JavaDoc();
419         for(int i = 0; i < ids.length; i++) {
420             if(!WorkbenchActivityHelper.filterItem(ids[i])) {
421                 list.add(ids[i]);
422             }
423         }
424         return (IPerspectiveDescriptor[])list.toArray(new IPerspectiveDescriptor[list.size()]);
425     }
426     
427     /**
428      * Simple method to create a spacer in the page
429      *
430      * @param composite
431      * the composite to add the spacer to
432      * @param columnSpan
433      * the amount of space for the spacer
434      */

435     protected void createSpacer(Composite composite, int columnSpan) {
436         Label label = new Label(composite, SWT.NONE);
437         GridData gd = new GridData();
438         gd.horizontalSpan = columnSpan;
439         label.setLayoutData(gd);
440     }// end createSpacer
441

442     /*
443      * (non-Javadoc)
444      *
445      * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
446      */

447     protected void performDefaults() {
448         perspec.loadDefault();
449         suspend.loadDefault();
450         setDefaultPerspectives();
451         buildComboBoxes(fCurrentType);
452         super.performDefaults();
453     }// end performdefaults
454

455     /* (non-Javadoc)
456      * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
457      */

458     public void createControl(Composite parent) {
459         super.createControl(parent);
460         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.PERSPECTIVE_PREFERENCE_PAGE);
461     }
462
463     /*
464      * (non-Javadoc)
465      *
466      * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
467      */

468     protected Control createContents(Composite parent) {
469         Composite composite = new Composite(parent, SWT.NONE);
470         composite.setLayout(new GridLayout(1, false));
471         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
472         
473     // create the global radio buttons
474
createSpacer(composite, 1);
475         perspec = new RadioGroupFieldEditor(
476                 IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE,
477                 DebugPreferencesMessages.LaunchingPreferencePage_11, 3,
478                 new String JavaDoc[][] {{DebugPreferencesMessages.LaunchingPreferencePage_12, MessageDialogWithToggle.ALWAYS },
479                             { DebugPreferencesMessages.LaunchingPreferencePage_13, MessageDialogWithToggle.NEVER },
480                             { DebugPreferencesMessages.LaunchingPreferencePage_14, MessageDialogWithToggle.PROMPT } },
481                             composite,
482                             true);
483         perspec.setPreferenceName(IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE);
484         perspec.setPreferenceStore(getPreferenceStore());
485         suspend = new RadioGroupFieldEditor(
486                 IInternalDebugUIConstants.PREF_SWITCH_PERSPECTIVE_ON_SUSPEND,
487                 DebugPreferencesMessages.DebugPreferencePage_21, 3,
488                 new String JavaDoc[][] {{ DebugPreferencesMessages.DebugPreferencePage_22, MessageDialogWithToggle.ALWAYS },
489                                 { DebugPreferencesMessages.DebugPreferencePage_23, MessageDialogWithToggle.NEVER },
490                                 { DebugPreferencesMessages.DebugPreferencePage_24, MessageDialogWithToggle.PROMPT } },
491                                 composite,
492                                 true);
493         suspend.setPreferenceName(IInternalDebugUIConstants.PREF_SWITCH_PERSPECTIVE_ON_SUSPEND);
494         suspend.setPreferenceStore(getPreferenceStore());
495         
496         createSpacer(composite, 1);
497         
498         Label lbl = new Label(composite, SWT.LEFT + SWT.WRAP);
499         lbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
500         ((GridData)lbl.getLayoutData()).widthHint = LABEL_WIDTH_HINT;
501         lbl.setText(MessageFormat.format(DebugPreferencesMessages.PerspectivePreferencePage_5, null));
502         
503         Composite comp = new Composite(composite, SWT.FILL);
504         comp.setLayout(new GridLayout(2, false));
505         comp.setLayoutData(new GridData(GridData.FILL_BOTH));
506         
507         Composite treeComp = new Composite(comp, SWT.NONE);
508         treeComp.setLayout(new GridLayout(1, true));
509         treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
510         Label label = new Label(treeComp, SWT.NONE);
511         label.setText(DebugPreferencesMessages.PerspectivePreferencePage_1);
512         
513         fTree = new Tree(treeComp, SWT.H_SCROLL + SWT.V_SCROLL + SWT.SINGLE + SWT.BORDER);
514         fTree.setLayoutData(new GridData(GridData.FILL_BOTH));
515         fViewer = new TreeViewer(fTree);
516         fViewer.setLabelProvider(DebugUITools.newDebugModelPresentation());
517         fViewer.setSorter(new WorkbenchViewerSorter());
518         fViewer.setContentProvider(new LaunchConfigurationTreeContentProviderNoChildren(null, parent.getShell()));
519         fViewer.addFilter(new LaunchGroupFilter(fLCM.getLaunchGroup(DEBUG_LAUNCH_GROUP)));
520         fViewer.setInput(fLManager.getLaunchConfigurationTypes());
521         fViewer.expandAll();
522         fViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
523                     public void selectionChanged(SelectionChangedEvent event) {
524                         handleLaunchConfigurationSelectionChanged(event);
525                     }//end selectionChanged
526
});
527         fPerspectiveComp = new Composite(comp, SWT.NONE);
528         fPerspectiveComp.setLayout(new GridLayout(1, true));
529         fPerspectiveComp.setLayoutData(new GridData(GridData.FILL_BOTH));
530         fTypeInformationMapping = new HashMap JavaDoc();
531         // get the available labels
532
getPerspectiveLabels();
533         // restore from preference store
534
restoreState();
535         
536         PlatformUI.getWorkbench().getActivitySupport().getActivityManager().addActivityManagerListener(this);
537         
538         Dialog.applyDialogFont(composite);
539         return composite;
540     }// end createControl
541

542     /* (non-Javadoc)
543      * @see org.eclipse.ui.activities.IActivityManagerListener#activityManagerChanged(org.eclipse.ui.activities.ActivityManagerEvent)
544      */

545     public void activityManagerChanged(ActivityManagerEvent activityManagerEvent) {
546         if(!fTree.isDisposed()) {
547             fViewer.refresh();
548             getPerspectiveLabels();
549             restoreState();
550         }
551     }
552
553     /* (non-Javadoc)
554      * @see org.eclipse.jface.dialogs.DialogPage#dispose()
555      */

556     public void dispose() {
557         PlatformUI.getWorkbench().getActivitySupport().getActivityManager().removeActivityManagerListener(this);
558         super.dispose();
559     }
560
561 }// end class
562
Popular Tags