specifyAsLink = toolkit.createButton(composite, CommonMessages.useResourceLink, SWT.RADIO);
GridData data = new GridData();
data.horizontalSpan = 2;
specifyAsLink.setLayoutData(data);
ResourceLocatorType locator = plan.getCmpConnectionFactory();
toolkit.createLabel(composite, CommonMessages.resourceLink);
String value = locator != null ? locator.getResourceLink() : null;
resourceLink = toolkit.createText(composite, value, SWT.BORDER);
resourceLink.setLayoutData(createTextFieldGridData());
resourceLink.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getResourceLocator().setResourceLink(resourceLink.getText());
markDirty();
}
});
specifyAsUrl = toolkit.createButton(composite, CommonMessages.useUrl, SWT.RADIO);
data = new GridData();
data.horizontalSpan = 2;
specifyAsUrl.setLayoutData(data);
toolkit.createLabel(composite, CommonMessages.url);
value = locator != null ? locator.getUrl() : null;
url = toolkit.createText(composite, value, SWT.BORDER);
url.setLayoutData(createTextFieldGridData());
url.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getResourceLocator().setUrl(url.getText());
markDirty();
}
});
specifyAsPattern = toolkit.createButton(composite, CommonMessages.useResourcePattern, SWT.RADIO);
specifyAsPattern.setLayoutData(data);
toolkit.createLabel(composite, CommonMessages.groupId);
value = locator != null && locator.getPattern() != null ? locator.getPattern().getGroupId()
: null;
group = toolkit.createText(composite, value, SWT.BORDER);
group.setLayoutData(createTextFieldGridData());
group.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getPattern().setGroupId(group.getText());
markDirty();
}
});
toolkit.createLabel(composite, CommonMessages.artifactId);
value = locator != null && locator.getPattern() != null ? locator.getPattern().getArtifactId()
: null;
artifact = toolkit.createText(composite, value, SWT.BORDER);
artifact.setLayoutData(createTextFieldGridData());
artifact.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getPattern().setArtifactId(artifact.getText());
markDirty();
}
});
toolkit.createLabel(composite, CommonMessages.moduleId);
value = locator != null && locator.getPattern() != null ? locator.getPattern().getModule()
: null;
module = toolkit.createText(composite, value, SWT.BORDER);
module.setLayoutData(createTextFieldGridData());
module.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getPattern().setModule(module.getText());
markDirty();
}
});
toolkit.createLabel(composite, CommonMessages.name);
value = locator != null && locator.getPattern() != null ? locator.getPattern().getName()
: null;
name = toolkit.createText(composite, value, SWT.BORDER);
name.setLayoutData(createTextFieldGridData());
name.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getPattern().setName(name.getText());
markDirty();
}
});
toolkit.createLabel(composite, CommonMessages.version);
value = locator != null && locator.getPattern() != null ? locator.getPattern().getVersion()
: null;
version = toolkit.createText(composite, value, SWT.BORDER);
version.setLayoutData(createTextFieldGridData());
version.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getPattern().setVersion(version.getText());
markDirty();
}
});
specifyAsLink.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (specifyAsLink.getSelection()) {
getResourceLocator().setUrl(null);
getResourceLocator().setPattern(null);
if (resourceLink.getText().length() > 0) {
getResourceLocator().setResourceLink(resourceLink.getText());
}
markDirty();
toggle();
}
}
});
specifyAsUrl.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (specifyAsUrl.getSelection()) {
getResourceLocator().setResourceLink(null);
getResourceLocator().setPattern(null);
if (url.getText().length() > 0) {
getResourceLocator().setUrl(url.getText());
}
markDirty();
toggle();
}
}
});
specifyAsPattern.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (specifyAsPattern.getSelection()) {
getResourceLocator().setResourceLink (null);
getResourceLocator().setUrl (null);
if (group.getText().length() > 0) {
getPattern().setGroupId(group.getText());
}
if (artifact.getText().length() > 0) {
getPattern().setArtifactId(artifact.getText());
}
if (module.getText().length() > 0) {
getPattern().setModule(module.getText());
}
if (name.getText().length() > 0) {
getPattern().setName(name.getText());
}
if (version.getText().length() > 0) {
getPattern().setVersion(version.getText());
}
markDirty();
toggle();
}
}
});
if (locator != null) {
if (locator.getResourceLink() != null) {
specifyAsLink.setSelection(true);
} else if (locator.getUrl() != null) {
specifyAsUrl.setSelection(true);
} else if (locator.getPattern() != null) {
specifyAsPattern.setSelection(true);
}
}
toggle();