org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider Java Examples

The following examples show how to use org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultEObjectLabelProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetStyledTextFallbackText() throws Exception {
	DefaultEObjectLabelProvider defaultLabelProvider = new DefaultEObjectLabelProvider();
	ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
	parserRule.setName("testCreateStyledString");
	StyledString styledText = defaultLabelProvider.getStyledText(parserRule);
	assertEquals("testCreateStyledString", styledText.getString());
}
 
Example #2
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
	with(new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			return injector;
		}
	});
	treeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(),
			new DefaultLocationInFileProvider());
}
 
Example #3
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testNoNames() throws Exception {
	final DefaultOutlineTreeProvider noNamesTreeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(),
			new DefaultLocationInFileProvider()) {
		@Override
		protected Object _text(Object modelElement) {
			return null;
		}
	};
	final String modelAsText = "element1 { element11 {}} element2 {}";
	IXtextDocument document = createXtextDocument(modelAsText);
	final IOutlineNode rootNode = noNamesTreeProvider.createRoot(document);
	document.readOnly(new IUnitOfWork.Void<XtextResource>() {
		@Override
		public void process(XtextResource state) throws Exception {
			noNamesTreeProvider.createChildren(rootNode, state.getContents().get(0));
			
			assertEquals(1, rootNode.getChildren().size());
			IOutlineNode modelNode = rootNode.getChildren().get(0);
			assertEquals(state.getURI().trimFileExtension().lastSegment(), modelNode.getText());
			assertTrue(modelNode.hasChildren());
			
			assertEquals(1, modelNode.getChildren().size());
			IOutlineNode element1 = modelNode.getChildren().get(0);
			assertEquals("<unnamed>", element1.getText().toString());
			assertEquals(new TextRegion(0, 8), element1.getSignificantTextRegion());
			assertEquals(new TextRegion(0, 24), element1.getFullTextRegion());
			assertEquals(modelNode, element1.getParent());
			// node does not know that its children will be skipped
			assertTrue(element1.hasChildren());
			assertTrue(element1.getChildren().isEmpty());
		}
	});
}
 
Example #4
Source File: XtextContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ISetup doGetSetup() {
	return new XtextStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new XtextRuntimeModule(),new XtextUIModuleInternal(Activator.getDefault()) {
				@Override
				public void configureContentProposalLabelProvider(com.google.inject.Binder binder) {
					binder.bind(ILabelProvider.class).annotatedWith(ContentProposalLabelProvider.class).to(DefaultEObjectLabelProvider.class);
				}
			}, new SharedStateModule()));
		}
	};
}
 
Example #5
Source File: TreeDialogBar.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
private void buildTree(TreeViewer treeViewer) {	
	
	Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy();
	TreeContentProvider contentProvider = new TreeContentProvider(treeViewer);		
	treeViewer.setContentProvider(contentProvider);
	treeViewer.setLabelProvider(new DefaultEObjectLabelProvider());
	treeViewer.setSorter(null);
	if(m.isPresent()) {
		treeViewer.setInput(m.get());
	}
	
}
 
Example #6
Source File: TreeDialogBubble.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
private void buildTree(TreeViewer treeViewer) {	
	
	Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy();
	TreeContentProvider contentProvider = new TreeContentProvider(treeViewer);		
	treeViewer.setContentProvider(contentProvider);
	treeViewer.setLabelProvider(new DefaultEObjectLabelProvider());
	treeViewer.setSorter(null);
	if(m.isPresent())
		treeViewer.setInput(m.get());	
	
}
 
Example #7
Source File: EmfUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ILabelProvider> bindILabelProvider() {
	return DefaultEObjectLabelProvider.class;
}
 
Example #8
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ILabelProvider> bindILabelProvider() {
	return DefaultEObjectLabelProvider.class;
}
 
Example #9
Source File: TaxonomyCheckboxListView.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
@Override
public void createPartControl(Composite parent) {
	Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy();
	contentProvider = new TermContentProvider(viewer);
	viewer = new ContainerCheckedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(contentProvider);
	DecoratingLabelProvider p = new DecoratingLabelProvider(new DefaultEObjectLabelProvider(), new TaxonomyLabelDecorator());
	viewer.setLabelProvider(p);
	viewer.addCheckStateListener(this);
	viewer.setSorter(null);

	cellEditor = new MyTextCellEditor(viewer.getTree());

	TreeViewerEditor.create(
			viewer,
			new ColumnViewerEditorActivationStrategy(viewer){
				protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
					return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION ||
							(event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.F2);
				}
			},
			TreeViewerEditor.DEFAULT
	);
	enableEditing();

	if(m.isPresent()){
		viewer.setInput(m.get());
	}
	viewer.expandAll();

	//Create right-click menu
       MenuManager menuManager = new MenuManager();
       Menu menu = menuManager.createContextMenu(viewer.getTree());
       viewer.getTree().setMenu(menu);
       getSite().registerContextMenu(menuManager, viewer);
	getSite().setSelectionProvider(viewer);
	// Create the help context id for the viewer's control
	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "de.tudresden.slr.model.taxonomy.ui.viewer");
	getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
}