| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2 | |||
| 3 | 3 | Bundle-Name: Popup Plug-in | |
| 4 | 4 | Bundle-SymbolicName: de.vogella.rcp.intro.commands.popup; singleton:=true | |
| 5 | 5 | Bundle-Version: 1.0.0 | |
| 6 | - Bundle-Activator: de.vogella.rcp.intro.commands.popup.Activator | ||
| 7 | 6 | Require-Bundle: org.eclipse.ui, | |
| 8 | 7 | org.eclipse.core.runtime | |
| 9 | 8 | Bundle-ActivationPolicy: lazy | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ public class Application implements IApplication { | |||
| 14 | 14 | /* (non-Javadoc) | |
| 15 | 15 | * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) | |
| 16 | 16 | */ | |
| 17 | + @Override | ||
| 17 | 18 | public Object start(IApplicationContext context) { | |
| 18 | 19 | Display display = PlatformUI.createDisplay(); | |
| 19 | 20 | try { | |
@@ -30,12 +31,14 @@ public Object start(IApplicationContext context) { | |||
| 30 | 31 | /* (non-Javadoc) | |
| 31 | 32 | * @see org.eclipse.equinox.app.IApplication#stop() | |
| 32 | 33 | */ | |
| 34 | + @Override | ||
| 33 | 35 | public void stop() { | |
| 34 | 36 | final IWorkbench workbench = PlatformUI.getWorkbench(); | |
| 35 | 37 | if (workbench == null) | |
| 36 | 38 | return; | |
| 37 | 39 | final Display display = workbench.getDisplay(); | |
| 38 | 40 | display.syncExec(new Runnable() { | |
| 41 | + @Override | ||
| 39 | 42 | public void run() { | |
| 40 | 43 | if (!display.isDisposed()) | |
| 41 | 44 | workbench.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { | |||
| 26 | 26 | super(configurer); | |
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | + @Override | ||
| 29 | 30 | protected void makeActions(final IWorkbenchWindow window) { | |
| 30 | 31 | // Creates the actions and registers them. | |
| 31 | 32 | // Registering is needed to ensure that key bindings work. | |
@@ -38,6 +39,7 @@ protected void makeActions(final IWorkbenchWindow window) { | |||
| 38 | 39 | register(exitAction); | |
| 39 | 40 | } | |
| 40 | 41 | ||
| 42 | + @Override | ||
| 41 | 43 | protected void fillMenuBar(IMenuManager menuBar) { | |
| 42 | 44 | MenuManager fileMenu = new MenuManager("&File", | |
| 43 | 45 | IWorkbenchActionConstants.M_FILE); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,11 +8,13 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { | |||
| 8 | 8 | ||
| 9 | 9 | private static final String PERSPECTIVE_ID = "de.vogella.rcp.intro.commands.popup.perspective"; | |
| 10 | 10 | ||
| 11 | + @Override | ||
| 11 | 12 | public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( | |
| 12 | 13 | IWorkbenchWindowConfigurer configurer) { | |
| 13 | 14 | return new ApplicationWorkbenchWindowAdvisor(configurer); | |
| 14 | 15 | } | |
| 15 | 16 | ||
| 17 | + @Override | ||
| 16 | 18 | public String getInitialWindowPerspectiveId() { | |
| 17 | 19 | return PERSPECTIVE_ID; | |
| 18 | 20 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,11 +12,13 @@ public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) | |||
| 12 | 12 | super(configurer); | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | + @Override | ||
| 15 | 16 | public ActionBarAdvisor createActionBarAdvisor( | |
| 16 | 17 | IActionBarConfigurer configurer) { | |
| 17 | 18 | return new ApplicationActionBarAdvisor(configurer); | |
| 18 | 19 | } | |
| 19 | 20 | ||
| 21 | + @Override | ||
| 20 | 22 | public void preWindowOpen() { | |
| 21 | 23 | IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); | |
| 22 | 24 | configurer.setInitialSize(new Point(400, 300)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | public class Perspective implements IPerspectiveFactory { | |
| 7 | 7 | ||
| 8 | + @Override | ||
| 8 | 9 | public void createInitialLayout(IPageLayout layout) { | |
| 9 | 10 | String editorArea = layout.getEditorArea(); | |
| 10 | 11 | layout.setEditorAreaVisible(false); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,12 @@ | |||
| 1 | 1 | package de.vogella.rcp.intro.commands.popup; | |
| 2 | 2 | ||
| 3 | + import java.util.ArrayList; | ||
| 4 | + import java.util.List; | ||
| 5 | + | ||
| 3 | 6 | 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; | ||
| 6 | 8 | import org.eclipse.jface.viewers.LabelProvider; | |
| 7 | 9 | import org.eclipse.jface.viewers.TableViewer; | |
| 8 | - import org.eclipse.jface.viewers.Viewer; | ||
| 9 | 10 | import org.eclipse.swt.SWT; | |
| 10 | 11 | import org.eclipse.swt.graphics.Image; | |
| 11 | 12 | import org.eclipse.swt.widgets.Composite; | |
@@ -15,70 +16,48 @@ | |||
| 15 | 16 | import org.eclipse.ui.part.ViewPart; | |
| 16 | 17 | ||
| 17 | 18 | public class View extends ViewPart { | |
| 18 | - public static final String ID = "de.vogella.rcp.intro.commands.popup.view"; | ||
| 19 | 19 | ||
| 20 | 20 | private TableViewer viewer; | |
| 21 | 21 | ||
| 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 | ||
| 51 | 24 | 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); | ||
| 54 | 26 | } | |
| 55 | 27 | } | |
| 56 | 28 | ||
| 57 | - /** | ||
| 58 | - * This is a callback that will allow us to create the viewer and initialize | ||
| 59 | - * it. | ||
| 60 | - */ | ||
| 29 | + @Override | ||
| 61 | 30 | 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()); | ||
| 65 | 33 | 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 | ||
| 69 | 37 | MenuManager menuManager = new MenuManager(); | |
| 70 | 38 | Menu menu = menuManager.createContextMenu(viewer.getTable()); | |
| 71 | - // Set the MenuManager | ||
| 39 | + // set the menu on the SWT widget | ||
| 72 | 40 | viewer.getTable().setMenu(menu); | |
| 41 | + // register the menu with the framework | ||
| 73 | 42 | getSite().registerContextMenu(menuManager, viewer); | |
| 74 | - // Make the selection available | ||
| 43 | + | ||
| 44 | + // make the viewer selection available | ||
| 75 | 45 | getSite().setSelectionProvider(viewer); | |
| 76 | 46 | } | |
| 77 | 47 | ||
| 78 | 48 | /** | |
| 79 | 49 | * Passing the focus request to the viewer's control. | |
| 80 | 50 | */ | |
| 51 | + @Override | ||
| 81 | 52 | public void setFocus() { | |
| 82 | 53 | viewer.getControl().setFocus(); | |
| 83 | 54 | } | |
| 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 | + } | ||
| 84 | 63 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments