blob: e5d7cfc697bf600842637905e7edc29bced7f48b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/********************************************************************************
* Copyright (c) 2006, 2007 Versant. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Versant and Others. - initial API and implementation
********************************************************************************/
package org.eclipse.jpt.ui.internal.views;
import org.eclipse.jpt.ui.internal.selection.ISelectionManager;
import org.eclipse.jpt.ui.internal.selection.Selection;
import org.eclipse.jpt.ui.internal.selection.SelectionManagerFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
public abstract class AbstractJpaView extends ViewPart
{
protected PageBook pageBook;
protected Composite defaultComposite;
/**
* The string to display when there is no view content
*/
private String defaultLabel;
private TabbedPropertySheetWidgetFactory widgetFactory;
public AbstractJpaView(String aDefaultLabel) {
super();
defaultLabel = aDefaultLabel;
this.widgetFactory = new TabbedPropertySheetWidgetFactory();
}
/* @see IWorkbenchPart#createPartControl(Composite) */
public final void createPartControl(Composite parent) {
pageBook = new PageBook(parent, SWT.NONE);
defaultComposite = buildDefaultComposite();
pageBook.showPage(defaultComposite);
subcreatePartControl(parent);
ISelectionManager selectionManager =
SelectionManagerFactory.getSelectionManager(getViewSite().getWorkbenchWindow());
selectionManager.register(this);
select(selectionManager.getCurrentSelection());
}
protected void subcreatePartControl(Composite parent) {
// no op - for subclasses to override if wished
}
private Composite buildDefaultComposite() {
Composite composite = getWidgetFactory().createComposite(pageBook, SWT.NONE);
composite.setLayout(new FillLayout(SWT.VERTICAL));
Label label = getWidgetFactory().createLabel(composite, defaultLabel);
return composite;
}
public abstract void select(Selection aSelection);
protected void showDefaultPage() {
pageBook.showPage(defaultComposite);
}
/* @see IWorkbenchPart#setFocus() */
public void setFocus() {
pageBook.setFocus();
}
public TabbedPropertySheetWidgetFactory getWidgetFactory() {
return this.widgetFactory;
}
}
|