azureus_core = _azureus_core;
this.range = _range;
if (range == null) {
newRange = true;
range = azureus_core.getIpFilterManager().getIPFilter().createRange(false);
}
final Shell shell = ShellFactory.createShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
Messages.setLanguageText(shell,"ConfigView.section.ipfilter.editFilter");
if(! Constants.isOSX) {
shell.setImage(ImageRepository.getImage("ipfilter"));
}
GridLayout layout = new GridLayout();
layout.numColumns = 2;
shell.setLayout(layout);
Label label = new Label(shell, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.ipfilter.description");
final Text textDescription = new Text(shell, SWT.BORDER);
GridData gridData = new GridData();
gridData.widthHint = 300;
textDescription.setLayoutData(gridData);
label = new Label(shell, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.ipfilter.start");
final Text textStartIp = new Text(shell, SWT.BORDER);
gridData = new GridData();
gridData.widthHint = 120;
textStartIp.setLayoutData(gridData);
label = new Label(shell, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.ipfilter.end");
final Text textEndIp = new Text(shell, SWT.BORDER);
gridData = new GridData();
gridData.widthHint = 120;
textEndIp.setLayoutData(gridData);
final Button ok = new Button(shell, SWT.PUSH);
Messages.setLanguageText(ok, "Button.ok");
shell.setDefaultButton(ok);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
gridData.widthHint = 100;
ok.setLayoutData(gridData);
ok.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
range.setDescription( textDescription.getText());
range.setStartIp( textStartIp.getText());
range.setEndIp( textEndIp.getText());
range.checkValid();
if (newRange) {
azureus_core.getIpFilterManager().getIPFilter().addRange(range);
}
shell.dispose();
}
});
textStartIp.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
range.setStartIp( textStartIp.getText());
range.checkValid();
if(range.isValid())
ok.setEnabled(true);
else
ok.setEnabled(false);
}
});
textEndIp.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
range.setEndIp( textEndIp.getText());
range.checkValid();
if(range.isValid())
ok.setEnabled(true);
else
ok.setEnabled(false);
}
});
if (range != null) {
textDescription.setText(range.getDescription());
textStartIp.setText(range.getStartIp());
textEndIp.setText(range.getEndIp());
}
shell.pack();
Utils.centerWindowRelativeTo(shell, parent);
shell.open();