|
Lines 20-31
Link Here
|
| 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.viewers.StructuredSelection; |
22 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
|
23 |
import org.eclipse.jface.window.Window; |
| 24 |
import org.eclipse.jface.wizard.WizardDialog; |
| 25 |
import org.eclipse.swt.SWT; |
| 26 |
import org.eclipse.swt.events.SelectionAdapter; |
| 27 |
import org.eclipse.swt.events.SelectionEvent; |
| 23 |
import org.eclipse.swt.graphics.Point; |
28 |
import org.eclipse.swt.graphics.Point; |
| 24 |
import org.eclipse.swt.widgets.Composite; |
29 |
import org.eclipse.swt.layout.GridData; |
| 25 |
import org.eclipse.swt.widgets.Display; |
30 |
import org.eclipse.swt.layout.GridLayout; |
|
|
31 |
import org.eclipse.swt.widgets.*; |
| 26 |
import org.eclipse.ui.contexts.IContextService; |
32 |
import org.eclipse.ui.contexts.IContextService; |
|
|
33 |
import org.eclipse.ui.forms.widgets.Form; |
| 34 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
| 27 |
import org.eclipse.ui.navigator.CommonNavigator; |
35 |
import org.eclipse.ui.navigator.CommonNavigator; |
| 28 |
import org.eclipse.ui.navigator.CommonViewer; |
36 |
import org.eclipse.ui.navigator.CommonViewer; |
|
|
37 |
import org.eclipse.ui.part.PageBook; |
| 29 |
import org.eclipse.wst.server.core.*; |
38 |
import org.eclipse.wst.server.core.*; |
| 30 |
import org.eclipse.wst.server.core.internal.Server; |
39 |
import org.eclipse.wst.server.core.internal.Server; |
| 31 |
import org.eclipse.wst.server.core.internal.UpdateServerJob; |
40 |
import org.eclipse.wst.server.core.internal.UpdateServerJob; |
|
Lines 33-38
Link Here
|
| 33 |
import org.eclipse.wst.server.ui.internal.Messages; |
42 |
import org.eclipse.wst.server.ui.internal.Messages; |
| 34 |
import org.eclipse.wst.server.ui.internal.ServerToolTip; |
43 |
import org.eclipse.wst.server.ui.internal.ServerToolTip; |
| 35 |
import org.eclipse.wst.server.ui.internal.Trace; |
44 |
import org.eclipse.wst.server.ui.internal.Trace; |
|
|
45 |
import org.eclipse.wst.server.ui.internal.wizard.NewServerWizard; |
| 36 |
/** |
46 |
/** |
| 37 |
* A view of servers, their modules, and status. |
47 |
* A view of servers, their modules, and status. |
| 38 |
*/ |
48 |
*/ |
|
Lines 40-45
Link Here
|
| 40 |
private static final String SERVERS_VIEW_CONTEXT = "org.eclipse.ui.serverViewScope"; |
50 |
private static final String SERVERS_VIEW_CONTEXT = "org.eclipse.ui.serverViewScope"; |
| 41 |
|
51 |
|
| 42 |
protected CommonViewer tableViewer; |
52 |
protected CommonViewer tableViewer; |
|
|
53 |
private Control mainPage; |
| 54 |
private Control noServersPage; |
| 55 |
PageBook book; |
| 43 |
|
56 |
|
| 44 |
protected IServerLifecycleListener serverResourceListener; |
57 |
protected IServerLifecycleListener serverResourceListener; |
| 45 |
protected IPublishListener publishListener; |
58 |
protected IPublishListener publishListener; |
|
Lines 60-73
Link Here
|
| 60 |
|
73 |
|
| 61 |
@Override |
74 |
@Override |
| 62 |
public void createPartControl(Composite parent) { |
75 |
public void createPartControl(Composite parent) { |
| 63 |
super.createPartControl(parent); |
76 |
// Add PageBook as parent composite |
|
|
77 |
FormToolkit toolkit = new FormToolkit(parent.getDisplay()); |
| 78 |
book = new PageBook(parent, SWT.NONE); |
| 79 |
super.createPartControl(book); |
| 80 |
// Main page for the Servers tableViewer |
| 81 |
mainPage = getCommonViewer().getControl(); |
| 82 |
// Page prompting to define a new server |
| 83 |
noServersPage = createDefaultPage(toolkit); |
| 84 |
book.showPage(mainPage); |
| 64 |
|
85 |
|
| 65 |
IContextService contextSupport = (IContextService)getSite().getService(IContextService.class); |
86 |
IContextService contextSupport = (IContextService)getSite().getService(IContextService.class); |
| 66 |
contextSupport.activateContext(SERVERS_VIEW_CONTEXT); |
87 |
contextSupport.activateContext(SERVERS_VIEW_CONTEXT); |
| 67 |
|
|
|
| 68 |
deferInitialization(); |
88 |
deferInitialization(); |
| 69 |
} |
89 |
} |
| 70 |
|
90 |
|
|
|
91 |
/** |
| 92 |
* Creates a page displayed when there are no servers defined. |
| 93 |
* |
| 94 |
* @param kit |
| 95 |
* @return Control |
| 96 |
*/ |
| 97 |
private Control createDefaultPage(FormToolkit kit){ |
| 98 |
Form form = kit.createForm(book); |
| 99 |
Composite body = form.getBody(); |
| 100 |
GridLayout layout = new GridLayout(2, false); |
| 101 |
body.setLayout(layout); |
| 102 |
|
| 103 |
Link hlink = new Link(body, SWT.NONE); |
| 104 |
hlink.setText(Messages.ServersView2_noServers); |
| 105 |
hlink.setBackground(book.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
| 106 |
GridData gd = new GridData(SWT.LEFT, SWT.FILL, true, false); |
| 107 |
hlink.setLayoutData(gd); |
| 108 |
hlink.addSelectionListener(new SelectionAdapter() { |
| 109 |
public void widgetSelected(SelectionEvent e) { |
| 110 |
NewServerWizard wizard = new NewServerWizard(); |
| 111 |
WizardDialog wd = new WizardDialog(book.getShell(), wizard); |
| 112 |
if( wd.open() == Window.OK){ |
| 113 |
toggleDefultPage(); |
| 114 |
} |
| 115 |
} |
| 116 |
}); |
| 117 |
|
| 118 |
return form; |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* Switch between the servers and default/empty page. |
| 123 |
* |
| 124 |
*/ |
| 125 |
void toggleDefultPage(){ |
| 126 |
if(tableViewer.getTree().getItemCount() < 1){ |
| 127 |
book.showPage(noServersPage); |
| 128 |
} else{ |
| 129 |
book.showPage(mainPage); |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 71 |
private void deferInitialization() { |
133 |
private void deferInitialization() { |
| 72 |
// TODO Angel Says: Need to do a final check on this line below. I don't think there is anything else |
134 |
// TODO Angel Says: Need to do a final check on this line below. I don't think there is anything else |
| 73 |
// that we need from to port from the old Servers View |
135 |
// that we need from to port from the old Servers View |
|
Lines 121-126
Link Here
|
| 121 |
if (tableViewer.getTree().getItemCount() > 0) { |
183 |
if (tableViewer.getTree().getItemCount() > 0) { |
| 122 |
Object obj = tableViewer.getTree().getItem(0).getData(); |
184 |
Object obj = tableViewer.getTree().getItem(0).getData(); |
| 123 |
tableViewer.setSelection(new StructuredSelection(obj)); |
185 |
tableViewer.setSelection(new StructuredSelection(obj)); |
|
|
186 |
} else{ |
| 187 |
toggleDefultPage(); |
| 124 |
} |
188 |
} |
| 125 |
} |
189 |
} |
| 126 |
}); |
190 |
}); |
|
Lines 267-272
Link Here
|
| 267 |
Display.getDefault().asyncExec(new Runnable() { |
331 |
Display.getDefault().asyncExec(new Runnable() { |
| 268 |
public void run() { |
332 |
public void run() { |
| 269 |
tableViewer.add(tableViewer.getInput(), server); |
333 |
tableViewer.add(tableViewer.getInput(), server); |
|
|
334 |
toggleDefultPage(); |
| 270 |
} |
335 |
} |
| 271 |
}); |
336 |
}); |
| 272 |
} |
337 |
} |
|
Lines 275-280
Link Here
|
| 275 |
Display.getDefault().asyncExec(new Runnable() { |
340 |
Display.getDefault().asyncExec(new Runnable() { |
| 276 |
public void run() { |
341 |
public void run() { |
| 277 |
tableViewer.remove(server); |
342 |
tableViewer.remove(server); |
|
|
343 |
toggleDefultPage(); |
| 278 |
} |
344 |
} |
| 279 |
}); |
345 |
}); |
| 280 |
} |
346 |
} |