我在SWT Composite
块上有一个问题..我构建了一个Composite
块,我将会读取我的数据,但问题是我现在有几个相同的日期.xml文件,我希望复合更新,以便在我打开GUI时显示新数据..
如何让Composite
阻止在另一个下方绘制新数据。
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.GridData;
import org.eclipse.wb.swt.SWTResourceManager;
import testic.CurrentData;
import testic.NODE;
import testic.ReadWrite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
public class MNode extends Composite {
private Text text;
private Text text_1;
private Text text_2;
private static CurrentData currentData = null;
static ReadWrite userinterface;
/**
* Create the composite.
* @param parent
* @param style
*/
public MGWSIMNode(Composite parent, int style) {
super(parent, style);
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
setLayout(new FormLayout());
currentData = new CurrentData();
userinterface = new ReadWrite(currentData) ;
userinterface.readXML();
for(NODE Node:currentData.getNodes()){
Composite composite = new Composite(this, SWT.BORDER);
composite.setLayout(new GridLayout(7, false));
FormData fd_composite = new FormData();
fd_composite.top = new FormAttachment(0, 10);
fd_composite.left = new FormAttachment(0, 10);
fd_composite.bottom = new FormAttachment(0, 96);
fd_composite.right = new FormAttachment(0, 1461);
composite.setLayoutData(fd_composite);
Label lblMgw = new Label(composite, SWT.NONE);
lblMgw.setText("MGWSIM");
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
Button btnNewButton_1 = new Button(composite, SWT.FLAT | SWT.CENTER);
GridData gd_btnNewButton_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_btnNewButton_1.widthHint = 24;
gd_btnNewButton_1.heightHint = 24;
btnNewButton_1.setLayoutData(gd_btnNewButton_1);
btnNewButton_1.setImage(SWTResourceManager.getImage("C:\\Users\\bebehind\\Pictures\\remove-button.png"));
btnNewButton_1.setText("\r\n");
btnNewButton_1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
dispose();
}
});
Label lblHost = new Label(composite, SWT.NONE);
GridData gd_lblHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblHost.widthHint = 36;
lblHost.setLayoutData(gd_lblHost);
lblHost.setText("Host:");
text = new Text(composite, SWT.BORDER);
GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_text.widthHint = 375;
text.setLayoutData(gd_text);
text.setText(Node.getHost());
Label lblType = new Label(composite, SWT.NONE);
GridData gd_lblType = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblType.widthHint = 79;
lblType.setLayoutData(gd_lblType);
lblType.setText("Type:");
text_1 = new Text(composite, SWT.BORDER);
GridData gd_text_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_text_1.widthHint = 375;
text_1.setLayoutData(gd_text_1);
text_1.setText(Node.getType());
Label lblIdentifier = new Label(composite, SWT.NONE);
GridData gd_lblIdentifier = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblId.widthHint = 58;
lblId.setLayoutData(gd_lblId);
lblId.setText("Id:");
text_2 = new Text(composite, SWT.BORDER);
GridData gd_text_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_text_2.widthHint = 375;
text_2.setLayoutData(gd_text_2);
text_2.setText(Node.getId());
Node.setId(text_2.getText());
new Label(composite, SWT.NONE);
}
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}