Java Code Examples for org.eclipse.jface.viewers.TreeViewer#setContentProvider()

The following examples show how to use org.eclipse.jface.viewers.TreeViewer#setContentProvider() . 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: BusinessObjectList.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createViewer(Composite parent, AbstractBdmFormPage formPage) {
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create());
    formPage.getToolkit().adapt(viewer.getTree());
    viewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, BUSINESS_OBJECT_LIST_VIEWER_ID);
    viewer.addFilter(createSearchFilter());
    viewer.addDoubleClickListener(e -> {
        viewer.setExpandedState(selectionObservable.getValue(),
                !viewer.getExpandedState(selectionObservable.getValue()));
    });

    ColumnViewerToolTipSupport.enableFor(viewer);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    viewer.getTree().setLayout(layout);
    viewer.setUseHashlookup(true);
    createBusinessObjectColumn(viewer, formPage);
    viewer.setContentProvider(new BusinessObjectTreeContentProvider());
    viewer.setComparator(new BusinessObjectViewerComparator());
    viewer.setInput(input);
    addDNDSupport(formPage);
    selectionObservable = ViewerProperties.singleSelection(Object.class).observe(viewer);
}
 
Example 2
Source File: JavaEditorBreadcrumb.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void configureDropDownViewer(TreeViewer viewer, Object input) {
	viewer.setContentProvider(createDropDownContentProvider());
	viewer.setLabelProvider(createDropDownLabelProvider());
	viewer.setComparator(new JavaElementComparator());
	viewer.addFilter(new ViewerFilter() {
		@Override
		public boolean select(Viewer viewer1, Object parentElement, Object element) {
			if (element instanceof IMember) {
				if (((IMember) element).getElementName().startsWith("<")) { //$NON-NLS-1$
					// filter out <clinit>
					return false;
				}
			}

			return true;
		}
	});
	if (SHOW_LIBRARIES_NODE)
		viewer.addFilter(new EmptyLibraryContainerFilter());
	JavaUIHelp.setHelp(viewer, IJavaHelpContextIds.JAVA_EDITOR_BREADCRUMB);
}
 
Example 3
Source File: SVNWizardPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected TreeViewer createResourceSelectionTree(Composite composite, int types, int span) {
	TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
	tree.setUseHashlookup(true);
	tree.setContentProvider(getResourceProvider(types));
	tree.setLabelProvider(
		new DecoratingLabelProvider(
			new WorkbenchLabelProvider(), 
			SVNUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator()));
	tree.setSorter(new ResourceSorter(ResourceSorter.NAME));
	
	GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	data.heightHint = LIST_HEIGHT_HINT;
	data.horizontalSpan = span;
	tree.getControl().setLayoutData(data);
	return tree;
}
 
Example 4
Source File: QueryEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private TreeViewer createQueryViewer(Composite parent) {
    TreeViewer queryViewer = new TreeViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    queryViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(300, SWT.DEFAULT).create());
    queryViewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, QUERY_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(queryViewer.getTree());
    ColumnViewerToolTipSupport.enableFor(queryViewer);
    queryViewer.setUseHashlookup(true);
    queryViewer.addFilter(createSearchFilter());
    queryViewer.addDoubleClickListener(e -> {
        queryViewer.setExpandedState(querySelectedObservable.getValue(),
                !viewer.getExpandedState(querySelectedObservable.getValue()));
    });

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    queryViewer.getTree().setLayout(layout);

    createQueryNameColumn(queryViewer);

    provider = new QueryContentProvider();
    queryViewer.setContentProvider(provider);
    return queryViewer;
}
 
Example 5
Source File: DQInfoSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void statisticsTree(Composite parent, String label, boolean forProcesses) {
	DQSystem system = forProcesses ? dqResult.setup.processSystem : dqResult.setup.exchangeSystem;
	if (system == null)
		return;
	UI.formLabel(parent, toolkit, label);
	UI.formLabel(parent, toolkit, "");
	String[] headers = { M.Indicator, M.Coverage };
	TreeViewer viewer = Trees.createViewer(parent, headers);
	viewer.setContentProvider(new ContentProvider(forProcesses));
	viewer.setLabelProvider(new LabelProvider(forProcesses));
	((GridData) viewer.getTree().getLayoutData()).horizontalSpan = 2;
	viewer.setInput(system.indicators);
	Trees.bindColumnWidths(viewer.getTree(), 0.6, 0.4);
}
 
Example 6
Source File: OutlineDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createOutline(final Composite viewersComposite) {
    outline = new TreeViewer(viewersComposite);
    outline.getTree().setLayoutData(GridDataFactory.fillDefaults().hint(300,200).create());
    outline.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    outline.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    final ViewerFilter[] filters = {new OutlineFilter()};
    outline.setFilters(filters);
    outline.setInput(ModelHelper.getParentProcess((EObject) elementToDisplay.get(0)));
}
 
Example 7
Source File: WorkspaceDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite = (Composite) super.createDialogArea(parent);

	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	composite.setLayout(layout);
	final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
	composite.setLayoutData(data);

	getShell().setText(Messages.getString("dialog.WorkspaceDialog.shell"));

	wsTreeViewer = new TreeViewer(composite, SWT.BORDER);
	final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.widthHint = 550;
	gd.heightHint = 250;
	wsTreeViewer.getTree().setLayoutData(gd);

	wsTreeViewer.setContentProvider(new LocationPageContentProvider());
	wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
	wsTreeViewer.setInput(ResourcesPlugin.getWorkspace());

	final Composite group = new Composite(composite, SWT.NONE);
	layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	group.setLayout(layout);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	final Label label = new Label(group, SWT.NONE);
	label.setLayoutData(new GridData());
	label.setText(Messages.getString("dialog.WorkspaceDialog.label"));

	wsFilenameText = new Text(group, SWT.BORDER);
	wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

	setupListeners();

	return parent;
}
 
Example 8
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Composite createMergeViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    composite.setLayout(GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x, 1).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(composite,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.setUseHashlookup(true);
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.setContentProvider(new SmartImportBdmTreeContentProvider());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);

    createModelColumn();
    createActionColumn();

    IViewerObservableValue singleSelectionObservable = ViewerProperties.singleSelection().observe(viewer);
    viewer.addDoubleClickListener(e -> viewer.setExpandedState(singleSelectionObservable.getValue(),
            !viewer.getExpandedState(singleSelectionObservable.getValue())));
    return composite;
}
 
Example 9
Source File: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeViewer createTreeViewer(Composite parent, int style) {
	Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.heightHint= tree.getItemHeight() * 12;
	tree.setLayoutData(gd);

	final TreeViewer treeViewer= new OutlineTreeViewer(tree);

	// Hard-coded filters
	treeViewer.addFilter(new NamePatternFilter());
	treeViewer.addFilter(new MemberFilter());

	fInnerLabelProvider= new OutlineLabelProvider();
	fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
	IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager();
	if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$
		fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null));

	treeViewer.setLabelProvider(new ColoringLabelProvider(fInnerLabelProvider));

	fLexicalSortingAction= new LexicalSortingAction(treeViewer);
	fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer);
	fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer);
	fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer, getId(), getInputForCategories());

	fOutlineContentProvider= new OutlineContentProvider(false);
	treeViewer.setContentProvider(fOutlineContentProvider);
	fOutlineSorter= new OutlineSorter();
	treeViewer.setComparator(fOutlineSorter);
	treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);


	treeViewer.getTree().addKeyListener(getKeyAdapter());

	return treeViewer;
}
 
Example 10
Source File: TmDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new <code>TreeViewer</code>.
 * @param parent
 *            the parent <code>Composite</code>.
 * @return the <code>TreeViewer</code>.
 */
protected TreeViewer createTreeViewer(Composite parent) {
	final TreeViewer viewer = new TreeViewer(parent, SWT.BORDER);
	addListeners(viewer);
	viewer.setLabelProvider(new TreeLableProvider());
	viewer.setContentProvider(new TreeContentProvider());
	return viewer;
}
 
Example 11
Source File: SelectExamplePage.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void createTreeViewer(Composite container) {
	viewer = new TreeViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
	viewer.setContentProvider(new ExampleContentProvider());
	viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExampleLabelProvider()));
	viewer.addSelectionChangedListener(this);
}
 
Example 12
Source File: TmDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new <code>TreeViewer</code>.
 * @param parent
 *            the parent <code>Composite</code>.
 * @return the <code>TreeViewer</code>.
 */
protected TreeViewer createTreeViewer(Composite parent) {
	final TreeViewer viewer = new TreeViewer(parent, SWT.BORDER);
	addListeners(viewer);
	viewer.setLabelProvider(new TreeLableProvider());
	viewer.setContentProvider(new TreeContentProvider());
	return viewer;
}
 
Example 13
Source File: CubeGroupContent.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void createDataField( )
{
	Composite dataField = new Composite( this, SWT.NONE );
	dataField.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	dataField.setLayout( new GridLayout( ) );

	Label dataLabel = new Label( dataField, SWT.NONE );
	dataLabel.setText( Messages.getString( "GroupsPage.Label.DataField" ) ); //$NON-NLS-1$
	dataFieldsViewer = new TreeViewer( dataField, SWT.SINGLE
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.BORDER );
	cubeLabelProvider = getCubeLabelProvider( );
	cubeLabelProvider.setProivderViewer( true );
	dataFieldsViewer.setLabelProvider( cubeLabelProvider );
	dataFieldsViewer.setContentProvider( dataContentProvider );
	dataFieldsViewer.setAutoExpandLevel( 3 );
	GridData gd = new GridData( GridData.FILL_BOTH );
	dataFieldsViewer.getTree( ).setLayoutData( gd );
	( (GridData) dataFieldsViewer.getTree( ).getLayoutData( ) ).heightHint = 250;
	( (GridData) dataFieldsViewer.getTree( ).getLayoutData( ) ).widthHint = 200;
	dataFieldsViewer.addSelectionChangedListener( new ISelectionChangedListener( ) {

		public void selectionChanged( SelectionChangedEvent event )
		{
			updateButtons( );
		}

	} );

	final DragSource fieldsSource = new DragSource( dataFieldsViewer.getTree( ),
			operations );
	fieldsSource.setTransfer( types );
	fieldsSource.addDragListener( new CustomDragListener( dataFieldsViewer ) );

}
 
Example 14
Source File: CommitEntryViewer.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected TreeViewer createViewer(Composite parent) {
	TreeViewer viewer = Trees.createViewer(parent, getLabelProvider());
	viewer.setContentProvider(new ContentProvider((RepositoryClient) viewerParameters[0]));
	return viewer;
}
 
Example 15
Source File: XPathOperatorEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Composite createOpeartorEditor(Composite parent,final Operator operator,final Expression sourceExpression) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 5).create());

    final XMLData data = (XMLData) sourceExpression.getReferencedElements().get(0) ;
    String namespace = data.getNamespace() ;
    String element = data.getType();
    XSDRepositoryStore xsdStore = (XSDRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(XSDRepositoryStore.class) ;

    XSDElementDeclaration root = xsdStore.findElementDeclaration(namespace, element);
    final XSDContentProvider provider =   new XSDContentProvider(true) ;
    provider.setElement(root);

    xsdViewer = new TreeViewer(composite);
    xsdViewer.setContentProvider(provider);
    XSDLabelProvider labelProvider = new XSDLabelProvider();
    xsdViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
    xsdViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    xsdViewer.setInput(new Object());

    String content = operator.getExpression() ;
    if(content == null){
        content = "" ;
    }
    xsdViewer.setSelection(new StructuredSelection(createTreePath(content, provider)));

    xpathText = new Text(composite, SWT.WRAP | SWT.BORDER);
    xpathText.setLayoutData(GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 40).grab(true, false).create());
    xpathText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            operator.setExpression(xpathText.getText()) ;
        }
    });


    xsdViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ITreeSelection selection = (ITreeSelection) xsdViewer.getSelection();
            String xpath = computeXPath(selection, false);
            if(xpath == null || xpath.isEmpty()){
                xpathText.setText(data.getName());
            }else{
                xpathText.setText(xpath);
            }

            xpathText.redraw();
            fireSelectionChange(event) ;
        }
    });
    return composite ;
}
 
Example 16
Source File: TexOutlinePage.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the control ie. creates all the stuff that matters and
 * is visible in the outline. 
 * 
 * Actions must be created before menus and toolbars.
 * 
 * @param parent
 */
public void createControl(Composite parent) {
    super.createControl(parent);
    
    // create the context actions
    createActions();
    
    // initialize the tree viewer
    TreeViewer viewer = getTreeViewer();		
    filter = new TexOutlineFilter();
    viewer.setContentProvider(new TexContentProvider(filter));
    viewer.setLabelProvider(new TexLabelProvider());
    viewer.setComparer(new TexOutlineNodeComparer());
    
    // get and apply the preferences
    this.getOutlinePreferences();
    viewer.addFilter(filter);
    
    // set the selection listener
    viewer.addSelectionChangedListener(this);
    
    // enable drag'n'drop support
    TexOutlineDNDAdapter dndAdapter = new TexOutlineDNDAdapter(viewer, this);
    int ops = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] {TextTransfer.getInstance()};
    viewer.addDragSupport(ops, transfers, dndAdapter);
    viewer.addDropSupport(ops, transfers, dndAdapter);
    
    // enable copy-paste
    initCopyPaste(viewer);
    
    // create the menu bar and the context menu
    createToolbar();
    resetToolbarButtons();
    createContextMenu();
    
    
    // finally set the input
    if (this.input != null) {
        viewer.setInput(this.input.getRootNodes());
        
        // set update button status and also the context actions
        outlineActions.get(ACTION_UPDATE).setEnabled(false);
        outlineActions.get(ACTION_COPY).setEnabled(true);
        outlineActions.get(ACTION_CUT).setEnabled(true);
        outlineActions.get(ACTION_PASTE).setEnabled(true);
        outlineActions.get(ACTION_DELETE).setEnabled(true);

    }
}
 
Example 17
Source File: CodeRecommendationResultsView.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public CodeRecommendationResultsView() {
	super(SWT.NONE);
	setBackgroundMode(SWT.INHERIT_FORCE);
	setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	setLayout(new FillLayout(SWT.HORIZONTAL));

	treeViewer = new TreeViewer(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	treeViewer.setAutoExpandLevel(3);
	Tree tree = treeViewer.getTree();
	tree.setHeaderVisible(true);

	TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
	TreeColumn trclmnCodeRecommendations = treeViewerColumn.getColumn();
	trclmnCodeRecommendations.setResizable(false);
	trclmnCodeRecommendations.setText("Code recommendations");

	treeViewer.setContentProvider(contentProvider = new TreeContentProvider());
	treeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider = new TreeLabelProvider()));

	tree.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TreeItem item = (TreeItem) e.item;
			Object data = item.getData();

			if (data instanceof ICodeRecommendationElement) {
				ICodeRecommendationElement element = (ICodeRecommendationElement) data;
				eventManager.invoke(l -> l.onCodeRecommendationSelected(element));
			}
		}
	});

	treeViewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event) {
			TreeViewer viewer = (TreeViewer) event.getViewer();
			IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
			Object selectedNode = thisSelection.getFirstElement();
			if (selectedNode instanceof CodeRecommendationTarget) {
				CodeRecommendationTarget target = (CodeRecommendationTarget) selectedNode;

				eventManager.invoke(l -> l.onTargetDoubleClicked(target));
			}
		}
	});

	createContextMenu(treeViewer);
}
 
Example 18
Source File: TSVEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 4 votes vote down vote up
void createPage1() {
	Composite composite = new Composite(getContainer(), SWT.NONE);
	FillLayout layout = new FillLayout();
	composite.setLayout(layout);
	
	Tree tree = new Tree(composite, SWT.BORDER | SWT.H_SCROLL
			| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);
	TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
	column1.setWidth(250);
	column1.setResizable(true);
	TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
	column2.setWidth(40);
	column2.setResizable(true);
	TreeColumn column3 = new TreeColumn(tree, SWT.LEFT);
	column3.setWidth(250);
	column3.setResizable(true);
	TreeColumn column4 = new TreeColumn(tree, SWT.LEFT);
	column4.setWidth(600);
	column4.setResizable(true);
	
	TreeViewer resultsViewer = new TreeViewer(tree);
	resultsViewer.setLabelProvider(new TSVResultsLabelProvider());
	resultsViewer.setContentProvider(new TSVResultsContentProvider(resultMap));
	resultsViewer.setInput(createModel());
	
	resultsViewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event) {
			
			IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
	        if (structuredSelection.isEmpty()) return;

	        Object selection = structuredSelection.getFirstElement();
	        
	        if (selection instanceof TSVResult) {
	        	String fileName = ((TSVResult) selection).getFilename();
	        	int lineNumber = ((TSVResult) selection).getLineNumber();
	        	String extensionName = fileName.replaceAll("-items.xml", "");
	        		
	        	IProject extension = ResourcesPlugin.getWorkspace().getRoot().getProject(extensionName);
	        	IFile itemsxml = extension.getFile("resources/" + fileName);
	        	if (itemsxml.exists()) {
		        	IMarker marker;
		        	try {
						marker = itemsxml.createMarker(IMarker.TEXT);
						HashMap<String, Object> map = new HashMap<String, Object>();
						map.put(IMarker.LINE_NUMBER, lineNumber);
						marker.setAttributes(map);
						IDE.openEditor(getSite().getPage(), marker);
						marker.delete();
					}
		        	catch (CoreException e) {
						e.printStackTrace();
					}
	        	}
	        	else {
	        		MessageBox dialog = new MessageBox(getContainer().getShell(), SWT.ICON_WARNING | SWT.OK);
	        		dialog.setText("Extension not found");
	        		dialog.setMessage("The extension " + extensionName + " was not found in the workspace. Please import it and try again.");
	        		dialog.open();
	        	}
	        }
		}
		
	});

	int index = addPage(composite);
	setPageText(index, "Results");
}
 
Example 19
Source File: DriverSelectionDialog.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
protected void createDataModel ( final TreeViewer viewer )
{
    final DataBindingContext dbc = new DataBindingContext ();

    final IObservableFactory listFactory = new IObservableFactory () {

        @Override
        public IObservable createObservable ( final Object target )
        {
            if ( target instanceof IObservableList )
            {
                return (IObservableList)target;
            }

            else if ( target instanceof World )
            {
                return EMFObservables.observeList ( (EObject)target, InfrastructurePackage.Literals.WORLD__NODES );
            }
            else if ( target instanceof SystemNode )
            {
                return EMFObservables.observeList ( (EObject)target, InfrastructurePackage.Literals.SYSTEM_NODE__DRIVERS );
            }

            return null;
        }
    };

    final AdapterFactory adapterFactory = new InfrastructureItemProviderAdapterFactory ();
    final AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider ( adapterFactory );

    final ObservableListTreeContentProvider cp = new ObservableListTreeContentProvider ( listFactory, null );
    viewer.setContentProvider ( cp );
    viewer.setLabelProvider ( labelProvider );
    viewer.setInput ( EMFObservables.observeList ( this.world, InfrastructurePackage.Literals.WORLD__NODES ) );

    dbc.bindValue ( ViewersObservables.observeSingleSelection ( viewer ), this.driverValue );
    this.driverValue.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            update ();
        }
    } );

    viewer.getControl ().addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            dbc.dispose ();
        }
    } );
}
 
Example 20
Source File: UpdateWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void createControl(final Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		composite.setLayout(gridLayout);
		
		treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
		GridData data = new GridData(GridData.FILL_BOTH);
		Tree tree = treeViewer.getTree();
		tree.setLayoutData(data);
		tree.setHeaderVisible(true);
		
		IUColumnConfig[] columns = getColumnConfig();		
		for (int i = 0; i < columns.length; i++) {
			TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
			tc.setResizable(true);
			tc.setText(columns[i].getColumnTitle());
			tc.setWidth(columns[i].getWidthInPixels(tree));
		}
		
		contentProvider = new ProvElementContentProvider();
		treeViewer.setContentProvider(contentProvider);
		labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
		treeViewer.setLabelProvider(labelProvider);
		
		setControl(composite);
		
		final Runnable runnable = new Runnable() {
			public void run() {				
//				updateStatus(input, operation);
				setDrilldownElements(input, operation);
				treeViewer.setInput(input);
			}
		};
		
		if (operation != null && !operation.hasResolved()) {
			try {
				getContainer().run(true, false, new IRunnableWithProgress() {
					public void run(IProgressMonitor monitor) {
						operation.resolveModal(monitor);
						parent.getDisplay().asyncExec(runnable);
					}
				});
			} catch (Exception e) {
				StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
			}
		} else {
			runnable.run();
		}
	}