Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Getting the Parent View of a control.
Getting the Parent View of a control. [message #1759783] Tue, 18 April 2017 13:24
Naveen Sabapathy is currently offline Naveen SabapathyFriend
Messages: 46
Registered: July 2016
Member
I would like to get the control of a Part. i.e. I have created a View and that view contains a Combo Widget and a Contol.

            <control class="com.test.rac.actions.V4BPCColumnControlContribution"
            		 id="com.test.rac.actions.ColumnControlContribution">
               <visibleWhen>
                  <with
                        variable="rac_command_suppression">
                     <not>
                        <iterate
                              operator="or">
                           <equals
                                 value="com.test.rac.ptiview.row">
                           </equals>
                        </iterate>
                     </not>
                  </with>
               </visibleWhen>
            </control>


I would like to get the control from my view class.

else, I would like to get the view from the control class.
package com.test.rac.actions;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;

import com.test.rac.V4BPCMessages;
import com.test.rac.V4BPCPtiNatView;
import com.test.rac.V4BPCPtiTableViewer;
import com.test.rac.util.V4BPCGeneralUtils;

public class V4BPCColumnControlContribution extends WorkbenchWindowControlContribution {

	private static Combo columnCombo = null;
	
	@Override
	protected Control createControl(Composite paramComposite) {
		Composite viewPanel = new Composite(paramComposite, SWT.LEFT_TO_RIGHT);
		GridLayout viewPanelLayout = new GridLayout(2,false);
		viewPanelLayout.marginBottom = 1;
		viewPanelLayout.marginTop = 1;
		viewPanelLayout.marginHeight = 0;
		viewPanel.setLayout(viewPanelLayout);
		addComponents(viewPanel);
		return viewPanel;
	}

	/**
	 * Adds the components to the View Panel.
	 * @param viewPanel
	 */
	private void addComponents(Composite viewPanel) {
		Label label = new Label(viewPanel,SWT.CENTER);
		label.setText(V4BPCMessages.LABEL_VIEW+":");
		columnCombo=new Combo(viewPanel, SWT.READ_ONLY | SWT.DROP_DOWN );
		GridData gd = new GridData();
		gd.widthHint=100;
		columnCombo.setLayoutData(gd);
		
		// Naveen 24.01.2017
		// #160 - Prevent changing of cell values in cell editor when using the mouse wheel
		V4BPCGeneralUtils.createInstance().removeComboWheelListener(columnCombo);

		
        //getColumnCombo().setItems(V4BPCViewColumnConfiguration.getPredefinedViewNames());
        getTableViewer().setViewCombo(columnCombo);
	}

	private V4BPCPtiTableViewer getTableViewer(){
		IWorkbenchPart part = getWorkbenchWindow().getActivePage().getActivePart();
		if(part!=null && part instanceof V4BPCPtiNatView) {
			return ((V4BPCPtiNatView)part).getTableViewer();
		}
		
		return null;
	}
}


If I'm tring to get the part using "IWorkbenchPart part = getWorkbenchWindow().getActivePage().getActivePart();" I'm getting the source part, Not the newly created part. Whats the method to get the parent part of any control?
Previous Topic:neon nightmare
Next Topic:Add custom wizards to new menu in eclipse plugin
Goto Forum:
  


Current Time: Fri Nov 16 05:06:17 GMT 2018

Powered by FUDForum. Page generated in 0.02437 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top