问题
After taking cue from this ques. I ended up here but the problem is, view is coming on right hand side of the screen and not occupying the full space. Here is the current screenshot .
and the code is
public class MonitorView extends CoreView
{
public MonitorView(final Composite parent)
{
super(parent);
setDisplayName(I18N("Visual Monitoring of iCommand"));
// setLayout(new FillLayout());
final Composite composite=GUIToolkit.newComposite(parent, SWT.FILL, new GridData(SWT.TOP,SWT.LEFT,true,true,1,1));
FillLayout layout=new FillLayout();
composite.setLayout(layout);
CreatePartControl(composite);
}
private void CreatePartControl(Composite parent)
{
// TODO Auto-generated method stub
final Canvas canvas=new Canvas(parent,SWT.NONE);
Color white = display.getSystemColor(SWT.COLOR_WHITE);
canvas.setBackground(white);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event)
{
int offset_x=130;
int offset_y=70;
int j=0,i=0,n=3,x,y;
DrawRoundedRectangle d= new DrawRoundedRectangle();
//for loop for column 1.Placing elements column wise.
for(i=0;i<n;i++)
{ x=0;y=offset_y*j;
d.drawrectangle(event, x, y, j);
j++;
x=0;y=offset_y*j;
d.drawrectangle(event, x, y, j);
j++;
}
j=0;int flag=6;
//for loop for drawing column 2
for(i=0;i<n;i++)
{
x=offset_x; y=offset_y*j;
d.drawrectangle(event, x, y, flag);
j++;flag++;
x=offset_x;y=offset_y*j;
d.drawrectangle(event, x, y, flag);
flag++;
j++;
}
}
});
}
}
How do i bring the view on the left hand side and onto full screen
Solution. See comment thread of question for discussion
public MonitorView(final Composite parent)
{
super(parent);
setDisplayName(I18N("Visual Monitoring of iCommand"));
setLayout(new FillLayout());
CreatePartControl(this);
}
Rest everything is same for above. Hope it helps :)
来源:https://stackoverflow.com/questions/29385501/eclipse-rcp-view-not-coming-on-the-left-side-on-the-screen