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?