X Tutup
Skip to content

Commit 929ec09

Browse files
committed
Eclipse 3.x commands update
1 parent 67d6912 commit 929ec09

File tree

8 files changed

+36
-109
lines changed

8 files changed

+36
-109
lines changed

de.vogella.rcp.intro.commands.popup/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: Popup Plug-in
44
Bundle-SymbolicName: de.vogella.rcp.intro.commands.popup; singleton:=true
55
Bundle-Version: 1.0.0
6-
Bundle-Activator: de.vogella.rcp.intro.commands.popup.Activator
76
Require-Bundle: org.eclipse.ui,
87
org.eclipse.core.runtime
98
Bundle-ActivationPolicy: lazy

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/Activator.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/Application.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Application implements IApplication {
1414
/* (non-Javadoc)
1515
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
1616
*/
17+
@Override
1718
public Object start(IApplicationContext context) {
1819
Display display = PlatformUI.createDisplay();
1920
try {
@@ -30,12 +31,14 @@ public Object start(IApplicationContext context) {
3031
/* (non-Javadoc)
3132
* @see org.eclipse.equinox.app.IApplication#stop()
3233
*/
34+
@Override
3335
public void stop() {
3436
final IWorkbench workbench = PlatformUI.getWorkbench();
3537
if (workbench == null)
3638
return;
3739
final Display display = workbench.getDisplay();
3840
display.syncExec(new Runnable() {
41+
@Override
3942
public void run() {
4043
if (!display.isDisposed())
4144
workbench.close();

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/ApplicationActionBarAdvisor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
2626
super(configurer);
2727
}
2828

29+
@Override
2930
protected void makeActions(final IWorkbenchWindow window) {
3031
// Creates the actions and registers them.
3132
// Registering is needed to ensure that key bindings work.
@@ -38,6 +39,7 @@ protected void makeActions(final IWorkbenchWindow window) {
3839
register(exitAction);
3940
}
4041

42+
@Override
4143
protected void fillMenuBar(IMenuManager menuBar) {
4244
MenuManager fileMenu = new MenuManager("&File",
4345
IWorkbenchActionConstants.M_FILE);

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/ApplicationWorkbenchAdvisor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
88

99
private static final String PERSPECTIVE_ID = "de.vogella.rcp.intro.commands.popup.perspective";
1010

11+
@Override
1112
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
1213
IWorkbenchWindowConfigurer configurer) {
1314
return new ApplicationWorkbenchWindowAdvisor(configurer);
1415
}
1516

17+
@Override
1618
public String getInitialWindowPerspectiveId() {
1719
return PERSPECTIVE_ID;
1820
}

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/ApplicationWorkbenchWindowAdvisor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
1212
super(configurer);
1313
}
1414

15+
@Override
1516
public ActionBarAdvisor createActionBarAdvisor(
1617
IActionBarConfigurer configurer) {
1718
return new ApplicationActionBarAdvisor(configurer);
1819
}
1920

21+
@Override
2022
public void preWindowOpen() {
2123
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
2224
configurer.setInitialSize(new Point(400, 300));

de.vogella.rcp.intro.commands.popup/src/de/vogella/rcp/intro/commands/popup/Perspective.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
public class Perspective implements IPerspectiveFactory {
77

8+
@Override
89
public void createInitialLayout(IPageLayout layout) {
910
String editorArea = layout.getEditorArea();
1011
layout.setEditorAreaVisible(false);
Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package de.vogella.rcp.intro.commands.popup;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import org.eclipse.jface.action.MenuManager;
4-
import org.eclipse.jface.viewers.IStructuredContentProvider;
5-
import org.eclipse.jface.viewers.ITableLabelProvider;
7+
import org.eclipse.jface.viewers.ArrayContentProvider;
68
import org.eclipse.jface.viewers.LabelProvider;
79
import org.eclipse.jface.viewers.TableViewer;
8-
import org.eclipse.jface.viewers.Viewer;
910
import org.eclipse.swt.SWT;
1011
import org.eclipse.swt.graphics.Image;
1112
import org.eclipse.swt.widgets.Composite;
@@ -15,70 +16,48 @@
1516
import org.eclipse.ui.part.ViewPart;
1617

1718
public class View extends ViewPart {
18-
public static final String ID = "de.vogella.rcp.intro.commands.popup.view";
1919

2020
private TableViewer viewer;
2121

22-
/**
23-
* The content provider class is responsible for providing objects to the
24-
* view. It can wrap existing objects in adapters or simply return objects
25-
* as-is. These objects may be sensitive to the current input of the view,
26-
* or ignore it and always show the same content (like Task List, for
27-
* example).
28-
*/
29-
class ViewContentProvider implements IStructuredContentProvider {
30-
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
31-
}
32-
33-
public void dispose() {
34-
}
35-
36-
public Object[] getElements(Object parent) {
37-
return new String[] { "One", "Two", "Three" };
38-
}
39-
}
40-
41-
class ViewLabelProvider extends LabelProvider implements
42-
ITableLabelProvider {
43-
public String getColumnText(Object obj, int index) {
44-
return getText(obj);
45-
}
46-
47-
public Image getColumnImage(Object obj, int index) {
48-
return getImage(obj);
49-
}
50-
22+
class ViewLabelProvider extends LabelProvider {
23+
@Override
5124
public Image getImage(Object obj) {
52-
return PlatformUI.getWorkbench().getSharedImages().getImage(
53-
ISharedImages.IMG_OBJ_ELEMENT);
25+
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
5426
}
5527
}
5628

57-
/**
58-
* This is a callback that will allow us to create the viewer and initialize
59-
* it.
60-
*/
29+
@Override
6130
public void createPartControl(Composite parent) {
62-
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
63-
| SWT.V_SCROLL);
64-
viewer.setContentProvider(new ViewContentProvider());
31+
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
32+
viewer.setContentProvider(ArrayContentProvider.getInstance());
6533
viewer.setLabelProvider(new ViewLabelProvider());
66-
viewer.setInput(getViewSite());
67-
// This is new code
68-
// First we create a menu Manager
34+
35+
viewer.setInput(getData());
36+
// Create a menu manager and create context menu
6937
MenuManager menuManager = new MenuManager();
7038
Menu menu = menuManager.createContextMenu(viewer.getTable());
71-
// Set the MenuManager
39+
// set the menu on the SWT widget
7240
viewer.getTable().setMenu(menu);
41+
// register the menu with the framework
7342
getSite().registerContextMenu(menuManager, viewer);
74-
// Make the selection available
43+
44+
// make the viewer selection available
7545
getSite().setSelectionProvider(viewer);
7646
}
7747

7848
/**
7949
* Passing the focus request to the viewer's control.
8050
*/
51+
@Override
8152
public void setFocus() {
8253
viewer.getControl().setFocus();
8354
}
55+
56+
private List<String> getData() {
57+
List<String> list = new ArrayList<String>();
58+
list.add("One");
59+
list.add("Two");
60+
list.add("Three");
61+
return list;
62+
}
8463
}

0 commit comments

Comments
 (0)
X Tutup