|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008,2011 IBM Corporation and others. |
2 |
* Copyright (c) 2008,2012 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 19-24
Link Here
|
| 19 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
19 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
| 20 |
import org.eclipse.core.runtime.jobs.Job; |
20 |
import org.eclipse.core.runtime.jobs.Job; |
| 21 |
import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
21 |
import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
|
|
22 |
import org.eclipse.jface.action.IMenuListener; |
| 23 |
import org.eclipse.jface.action.IMenuManager; |
| 24 |
import org.eclipse.jface.action.MenuManager; |
| 25 |
import org.eclipse.jface.viewers.ISelection; |
| 22 |
import org.eclipse.jface.viewers.StructuredSelection; |
26 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 23 |
import org.eclipse.jface.window.Window; |
27 |
import org.eclipse.jface.window.Window; |
| 24 |
import org.eclipse.jface.wizard.WizardDialog; |
28 |
import org.eclipse.jface.wizard.WizardDialog; |
|
Lines 29-39
Link Here
|
| 29 |
import org.eclipse.swt.layout.GridData; |
33 |
import org.eclipse.swt.layout.GridData; |
| 30 |
import org.eclipse.swt.layout.GridLayout; |
34 |
import org.eclipse.swt.layout.GridLayout; |
| 31 |
import org.eclipse.swt.widgets.*; |
35 |
import org.eclipse.swt.widgets.*; |
|
|
36 |
import org.eclipse.ui.actions.ActionContext; |
| 32 |
import org.eclipse.ui.contexts.IContextService; |
37 |
import org.eclipse.ui.contexts.IContextService; |
| 33 |
import org.eclipse.ui.forms.widgets.Form; |
38 |
import org.eclipse.ui.forms.widgets.Form; |
| 34 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
39 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
| 35 |
import org.eclipse.ui.navigator.CommonNavigator; |
40 |
import org.eclipse.ui.navigator.*; |
| 36 |
import org.eclipse.ui.navigator.CommonViewer; |
|
|
| 37 |
import org.eclipse.ui.part.PageBook; |
41 |
import org.eclipse.ui.part.PageBook; |
| 38 |
import org.eclipse.wst.server.core.*; |
42 |
import org.eclipse.wst.server.core.*; |
| 39 |
import org.eclipse.wst.server.core.internal.Server; |
43 |
import org.eclipse.wst.server.core.internal.Server; |
|
Lines 115-120
Link Here
|
| 115 |
} |
119 |
} |
| 116 |
}); |
120 |
}); |
| 117 |
|
121 |
|
|
|
122 |
|
| 123 |
// Create the context menu for the default page |
| 124 |
final CommonViewer commonViewer = this.getCommonViewer(); |
| 125 |
if (commonViewer != null){ |
| 126 |
ICommonViewerSite commonViewerSite = CommonViewerSiteFactory |
| 127 |
.createCommonViewerSite(this.getViewSite()); |
| 128 |
|
| 129 |
if (commonViewerSite != null){ |
| 130 |
// Note: actionService cannot be null |
| 131 |
final NavigatorActionService actionService = new NavigatorActionService(commonViewerSite, |
| 132 |
commonViewer, commonViewer.getNavigatorContentService()); |
| 133 |
|
| 134 |
MenuManager menuManager = new MenuManager("#PopupMenu"); |
| 135 |
menuManager.addMenuListener(new IMenuListener() { |
| 136 |
public void menuAboutToShow(IMenuManager mgr) { |
| 137 |
ISelection selection = commonViewer.getSelection(); |
| 138 |
actionService.setContext(new ActionContext(selection)); |
| 139 |
actionService.fillContextMenu(mgr); |
| 140 |
} |
| 141 |
}); |
| 142 |
Menu menu = menuManager.createContextMenu(body); |
| 143 |
|
| 144 |
// It is necessary to set the menu in two places: |
| 145 |
// 1. The white space in the server view |
| 146 |
// 2. The text and link in the server view. If this menu is not set, if the |
| 147 |
// user right clicks on the text or uses shortcut keys to open the context menu, |
| 148 |
// the context menu will not come up |
| 149 |
body.setMenu(menu); |
| 150 |
hlink.setMenu(menu); |
| 151 |
} |
| 152 |
else { |
| 153 |
if (Trace.FINEST) { |
| 154 |
Trace.trace(Trace.STRING_FINEST, "The commonViewerSite is null"); |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
else { |
| 159 |
if (Trace.FINEST) { |
| 160 |
Trace.trace(Trace.STRING_FINEST, "The commonViewer is null"); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 118 |
return form; |
164 |
return form; |
| 119 |
} |
165 |
} |
| 120 |
|
166 |
|
|
Lines 180-190
Link Here
|
| 180 |
public void done(IJobChangeEvent event) { |
226 |
public void done(IJobChangeEvent event) { |
| 181 |
Display.getDefault().asyncExec(new Runnable() { |
227 |
Display.getDefault().asyncExec(new Runnable() { |
| 182 |
public void run() { |
228 |
public void run() { |
| 183 |
if (tableViewer.getTree().getItemCount() > 0) { |
229 |
try { |
| 184 |
Object obj = tableViewer.getTree().getItem(0).getData(); |
230 |
if (tableViewer.getTree().getItemCount() > 0) { |
| 185 |
tableViewer.setSelection(new StructuredSelection(obj)); |
231 |
Object obj = tableViewer.getTree().getItem(0).getData(); |
| 186 |
} else{ |
232 |
tableViewer.setSelection(new StructuredSelection(obj)); |
| 187 |
toggleDefultPage(); |
233 |
} else{ |
|
|
234 |
toggleDefultPage(); |
| 235 |
} |
| 236 |
} |
| 237 |
catch (Exception e){ |
| 238 |
if (Trace.WARNING) { |
| 239 |
Trace.trace(Trace.STRING_WARNING, "Failed to update the server view.", e); |
| 240 |
} |
| 188 |
} |
241 |
} |
| 189 |
} |
242 |
} |
| 190 |
}); |
243 |
}); |