RCP View wird nicht angezeigt

knowledge

Bekanntes Mitglied
Hallo,

ich beginne gerade mit RCP und habe über Extensions eine SampleView hinzugefügt. Wenn ich die Eclipse Anwendung starte erscheint die View jedoch nicht. Was muss ich da noch machen, dass ich was zu sehen bekomme.

Den erzeugten Beispielcode habe ich beigefügt:

Java:
package testplugin;

import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

	private static final String PERSPECTIVE_ID = "testplugin.perspective"; //$NON-NLS-1$

    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }

	public String getInitialWindowPerspectiveId() {
		return PERSPECTIVE_ID;
	}
}

Java:
package testplugin;

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
    
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
        configurer.setInitialSize(new Point(400, 300));
        configurer.setShowCoolBar(false);
        configurer.setShowStatusLine(true);
        configurer.setTitle("Hello RCP"); //$NON-NLS-1$
    }
}

Java:
package testplugin.views;


import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;


/**
 * This sample class demonstrates how to plug-in a new
 * workbench view. The view shows data obtained from the
 * model. The sample creates a dummy model on the fly,
 * but a real implementation would connect to the model
 * available either in this or another plug-in (e.g. the workspace).
 * The view is connected to the model using a content provider.
 * <p>
 * The view uses a label provider to define how model
 * objects should be presented in the view. Each
 * view can present the same model objects using
 * different labels and icons, if needed. Alternatively,
 * a single label provider can be shared between views
 * in order to ensure that objects of the same type are
 * presented in the same way everywhere.
 * <p>
 */

public class SampleView extends ViewPart {

	/**
	 * The ID of the view as specified by the extension.
	 */
	public static final String ID = "testplugin.views.SampleView";

	private TableViewer viewer;
	private Action action1;
	private Action action2;
	private Action doubleClickAction;

	/*
	 * The content provider class is responsible for
	 * providing objects to the view. It can wrap
	 * existing objects in adapters or simply return
	 * objects as-is. These objects may be sensitive
	 * to the current input of the view, or ignore
	 * it and always show the same content 
	 * (like Task List, for example).
	 */
	 
	class ViewContentProvider implements IStructuredContentProvider {
		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
		}
		public void dispose() {
		}
		public Object[] getElements(Object parent) {
			return new String[] { "One", "Two", "Three" };
		}
	}
	class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
		public String getColumnText(Object obj, int index) {
			return getText(obj);
		}
		public Image getColumnImage(Object obj, int index) {
			return getImage(obj);
		}
		public Image getImage(Object obj) {
			return PlatformUI.getWorkbench().
					getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
		}
	}
	class NameSorter extends ViewerSorter {
	}

	/**
	 * The constructor.
	 */
	public SampleView() {
	}

	/**
	 * This is a callback that will allow us
	 * to create the viewer and initialize it.
	 */
	public void createPartControl(Composite parent) {
		viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
		viewer.setContentProvider(new ViewContentProvider());
		viewer.setLabelProvider(new ViewLabelProvider());
		viewer.setSorter(new NameSorter());
		viewer.setInput(getViewSite());

		// Create the help context id for the viewer's control
		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "testplugin.viewer");
		makeActions();
		hookContextMenu();
		hookDoubleClickAction();
		contributeToActionBars();
	}

	private void hookContextMenu() {
		MenuManager menuMgr = new MenuManager("#PopupMenu");
		menuMgr.setRemoveAllWhenShown(true);
		menuMgr.addMenuListener(new IMenuListener() {
			public void menuAboutToShow(IMenuManager manager) {
				SampleView.this.fillContextMenu(manager);
			}
		});
		Menu menu = menuMgr.createContextMenu(viewer.getControl());
		viewer.getControl().setMenu(menu);
		getSite().registerContextMenu(menuMgr, viewer);
	}

	private void contributeToActionBars() {
		IActionBars bars = getViewSite().getActionBars();
		fillLocalPullDown(bars.getMenuManager());
		fillLocalToolBar(bars.getToolBarManager());
	}

	private void fillLocalPullDown(IMenuManager manager) {
		manager.add(action1);
		manager.add(new Separator());
		manager.add(action2);
	}

	private void fillContextMenu(IMenuManager manager) {
		manager.add(action1);
		manager.add(action2);
		// Other plug-ins can contribute there actions here
		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	}
	
	private void fillLocalToolBar(IToolBarManager manager) {
		manager.add(action1);
		manager.add(action2);
	}

	private void makeActions() {
		action1 = new Action() {
			public void run() {
				showMessage("Action 1 executed");
			}
		};
		action1.setText("Action 1");
		action1.setToolTipText("Action 1 tooltip");
		action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
			getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
		
		action2 = new Action() {
			public void run() {
				showMessage("Action 2 executed");
			}
		};
		action2.setText("Action 2");
		action2.setToolTipText("Action 2 tooltip");
		action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
		doubleClickAction = new Action() {
			public void run() {
				ISelection selection = viewer.getSelection();
				Object obj = ((IStructuredSelection)selection).getFirstElement();
				showMessage("Double-click detected on "+obj.toString());
			}
		};
	}

	private void hookDoubleClickAction() {
		viewer.addDoubleClickListener(new IDoubleClickListener() {
			public void doubleClick(DoubleClickEvent event) {
				doubleClickAction.run();
			}
		});
	}
	private void showMessage(String message) {
		MessageDialog.openInformation(
			viewer.getControl().getShell(),
			"Sample View",
			message);
	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		viewer.getControl().setFocus();
	}
}
 

Wildcard

Top Contributor
Du musst die View noch öffnen. Das geht entweder übers Menü mit Show View, oder du musst ein Layout für eine Perspective erstellen das diese View enthält.
 

knowledge

Bekanntes Mitglied
Hallo,

Menü - Show View wird bei der Lösung ja nicht angezeigt. D.h. hier müsst ich wohl dann en Weg über die Perspective gehen.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
T RCP Menubar wird durch OLE-VIEW überschrieben Plattformprogrammierung 4
S RCP Nach erfolgreicher Erstellung der View, wie weitermachen? Plattformprogrammierung 1
G RCP Show View Command bestimmte View nicht erlauben Plattformprogrammierung 2
S RCP ActionBar Icon nur aktiv, wenn Selection in bestimmter View Plattformprogrammierung 6
M Plugin - Property Page - Get IResource in View Plattformprogrammierung 4
R Eclipse RCP Tabellen-View (Anfängerfrage) Plattformprogrammierung 3
L RCP Eigene View für EditorPart? Plattformprogrammierung 3
M RCP TableViewer schrumpft in View nach manueller Resize auf 1 Zeile Plattformprogrammierung 5
M EMF und Tabbed Properties View Plattformprogrammierung 4
Madlip RCP View austauschen/ändern Plattformprogrammierung 9
B RCP View aktualisieren bei Änderung 2. View Plattformprogrammierung 8
F RCP EMF View Plattformprogrammierung 13
L RCP Detached View beim Starten des RCPs? Plattformprogrammierung 3
F Tollbar Items disabled wenn View den Focus verliert Plattformprogrammierung 3
S RCP name einer view ändern Plattformprogrammierung 2
L RCP Help in eine View einbinden? Plattformprogrammierung 3
G RCP Menüpunkt Show View Plattformprogrammierung 7
G EMF -> Leere Elemente sollen in Property View nicht angezeigt werden Plattformprogrammierung 9
E eclipse RCP Properties View: ein Element aus Liste pro Zeile anzeigen Plattformprogrammierung 1
Z Eclipse RCP - UDP Strom in View anzeigen Plattformprogrammierung 4
L RCP Canvas in einer View? Plattformprogrammierung 4
lumo Eclipse + 'Could not create view' Plattformprogrammierung 5
L RCP View in einem Editor öffnen? Plattformprogrammierung 3
D Canvas auf View in Eclipse PlugIn Plattformprogrammierung 3
S Plugin: View beim Button-Klick austauschen Plattformprogrammierung 7
Saxony View als Image Plattformprogrammierung 2
S View Refreshen Plattformprogrammierung 2
T geladene Views / Event wenn View closed Plattformprogrammierung 4
S Steuerung View (Schließen erkennen/Hide anstatt Close) Plattformprogrammierung 2
S View speichern/laden beim schließen Plattformprogrammierung 14
L View schließen Plattformprogrammierung 7
L View nicht bekannt machen Plattformprogrammierung 4
lumo View aktivieren jedesmal wen.... Plattformprogrammierung 7
A Overlay in View eines anderen Plug-Ins zeichnen Plattformprogrammierung 2
A View ansprechen Plattformprogrammierung 5
T GMF Property View Plattformprogrammierung 4
M Command in Toolbar aktiv wenn View nicht aktiv Plattformprogrammierung 2
C RCP: Veraenderungen innerhalb einer View per Extension?! Plattformprogrammierung 7
T JSVGCanvas in RCP View anzeigen Plattformprogrammierung 5
ARadauer Mehrere Gui Elemente in View Plattformprogrammierung 4
B RCP - Zugriff von View auf andere View Plattformprogrammierung 4
Saxony [Eclipse RCP] Von woanders View updaten Plattformprogrammierung 11
S View aus anderen Thread aktualisieren Plattformprogrammierung 15
K Position einer Multiple View speichern Plattformprogrammierung 6
S RCP Anfängerfrage - Zusammenspiel View, Editor, Model Plattformprogrammierung 4
G View Daten übergabe. Plattformprogrammierung 4
N Nicht schließbare View? Plattformprogrammierung 7
C View updaten Teil 2 Plattformprogrammierung 2
B Eclipse RCP: View updaten Plattformprogrammierung 10
dzim Editor aus View öffnen - fehler: unbekannte Editor ID Plattformprogrammierung 11
J Editorfenster von View navigieren lassen? Plattformprogrammierung 5
T Aus einem View in das andere wecheln. Plattformprogrammierung 13
R SWT: nur eine Instanz einer View erlauben Plattformprogrammierung 5
N Update auf JRE 7_71 - Klasse wird nicht gefunden? Plattformprogrammierung 3
E Maven wird nicht mehr gefunden Plattformprogrammierung 3
J Suche ein UiEvent welches mich per Injection benachrichtigt wenn die Applikation geschlossen wird. Plattformprogrammierung 1
S RCP Exportiertes RCP Produkt lädt Datei nicht, bei Start aus Eclipse wird Datei jedoch gefunden Plattformprogrammierung 6
M OSGi Erweiterung über Extension Point wird nicht erkannt Plattformprogrammierung 2
C Ausführbare Jar erzeugen (Datei wird nicht gefunden) Plattformprogrammierung 4
H Datei in eclipse wird nicht erkannt Plattformprogrammierung 3
L RCP WelcomePage wird nicht geöffnet Plattformprogrammierung 2
S RCP Menu Contribution - Menü Button wird als inaktiv angezeigt Plattformprogrammierung 11
J RCP Verhindern, dass Editor geschlossen wird Plattformprogrammierung 5
B RCP eigenes Eclipse Plugin wird nicht aufgelöst Plattformprogrammierung 7
J Plugin wird nicht mit gestartet Plattformprogrammierung 4
hdi Plugin Icon wird nicht angezeigt Plattformprogrammierung 7
S swt Text(feld) wird zu stark aufgebläht Plattformprogrammierung 11
M Plugin wird nicht mehr geladen Plattformprogrammierung 3
byte Equinox - Klasse aus Plug-In wird nicht gefunden Plattformprogrammierung 3
Kirby.exe Tastatur und Maus reagieren nicht auf dem Login Screen Plattformprogrammierung 1
V JRE installieren oder nicht ? Plattformprogrammierung 40
M exe kann .dat nicht richtig lesen/ schreiben Plattformprogrammierung 2
Blender3D Swing Timer läuft unter Windows korrekt nicht aber unter UBUNTU Plattformprogrammierung 11
D Nach Sprachpaket Installation kann eclipse nicht mehr gestartet werden Plattformprogrammierung 4
G Nullpointer im Debugger, jedoch nicht beim normalen Starten Plattformprogrammierung 12
J Maven löst Zertifikatspfad bei HTTPS zum Repository-Server NEXUS nicht auf Plattformprogrammierung 1
P OSGi Maven build startet nicht <Unable to process "BundleTranslationProvider.locale"> Plattformprogrammierung 0
S Maven "mvn" funktioniert nicht Plattformprogrammierung 1
B Mac Installer aus .product Datei - Programm öffnet sich nicht Plattformprogrammierung 1
K Eclipse fährt nicht mehr hoch. Metadatendatei schuld? Plattformprogrammierung 7
R Einfaches Eclipse-Plugin-Beispiel funktioniert nicht Plattformprogrammierung 5
R RCP Application Model - Änderungen erfolgen nicht Plattformprogrammierung 17
R progress bar animation funktioniert nicht Plattformprogrammierung 3
M Krieg Hallo World nicht zum laufen Plattformprogrammierung 2
P RCP Text Editor Example - Missing Bundles lassen sich nicht auffinden. Plattformprogrammierung 6
A Eclipse undo/redo button reagiert nicht auf Änderungen in der OperationHistory Plattformprogrammierung 5
3 Eclipse Editor Plugin selektiert Projekt nicht Plattformprogrammierung 10
M eclipse führt applikationen nicht mehr aus Plattformprogrammierung 6
C Java Editor funktioniert nicht Plattformprogrammierung 9
R Resourcen werden im jar nicht gefunden Plattformprogrammierung 4
A RCP RAP-Bundle nach Installation nicht auffindbar?! Plattformprogrammierung 5
A OSGi Bundle exportieren, importieren und vewenden geht nicht?! Plattformprogrammierung 4
G RCP Die Anwendung {0} konnte nicht in der Registry gefunden werden. Plattformprogrammierung 3
M Eclipse - Dokumentation nicht über das Internet benutzen Plattformprogrammierung 3
D eclipse-RCP von der Konsole baut nicht Plattformprogrammierung 3
lumo RCP libraries werden nach dem export nicht gefunden Plattformprogrammierung 17
M RCP Aktivierung eines CommandHandlers, Änderungen in der plugin.xml wirken sich nicht aus... Plattformprogrammierung 2
W Wahrscheinlich triviales Problem, aber komm nicht weiter Plattformprogrammierung 7
E Common Navigator Framework erste Knoten werden nicht angezeigt Plattformprogrammierung 4
A RCP p2 - manuelles update "check for updates" von core bundle funktioniert nicht Plattformprogrammierung 6

Ähnliche Java Themen

Neue Themen


Oben