use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class ReposPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginRight = 10;
composite.setLayout(layout);
Group group = new Group(composite, SWT.NONE);
group.setText("Templates Repositories");
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
group.setLayout(new GridLayout(2, false));
final Button btnEnableTemplateRepo = new Button(group, SWT.CHECK);
btnEnableTemplateRepo.setText("Enable templates repositories");
btnEnableTemplateRepo.setSelection(enableTemplateRepo);
btnEnableTemplateRepo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
ControlDecoration decoration = new ControlDecoration(btnEnableTemplateRepo, SWT.RIGHT | SWT.TOP, composite);
decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decoration.setMarginWidth(3);
decoration.setDescriptionText("These repositories are used to load\ntemplates, in addition to repositories\nconfigured in the Bnd OSGi Workspace.");
decoration.setShowHover(true);
decoration.setShowOnlyOnFocus(false);
Label lblRepos = new Label(group, SWT.NONE);
lblRepos.setText("Repository URLs:");
lblRepos.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
final Table tblRepos = new Table(group, SWT.BORDER | SWT.MULTI);
vwrRepos = new TableViewer(tblRepos);
vwrRepos.setContentProvider(ArrayContentProvider.getInstance());
vwrRepos.setLabelProvider(new URLLabelProvider(tblRepos.getDisplay()));
vwrRepos.setInput(templateRepos);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 260;
gd.heightHint = 80;
tblRepos.setLayoutData(gd);
tblRepos.setEnabled(enableTemplateRepo);
final AddRemoveButtonBarPart addRemoveRepoPart = new AddRemoveButtonBarPart();
Control addRemovePanel = addRemoveRepoPart.createControl(group, SWT.FLAT | SWT.VERTICAL);
addRemovePanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addRemoveRepoPart.setRemoveEnabled(false);
addRemoveRepoPart.addListener(new AddRemoveListener() {
@Override
public void addSelected() {
doAddRepo();
}
@Override
public void removeSelected() {
doRemoveRepo();
}
});
vwrRepos.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
addRemoveRepoPart.setRemoveEnabled(!vwrRepos.getSelection().isEmpty());
}
});
tblRepos.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.DEL && e.stateMask == 0)
doRemoveRepo();
}
});
btnEnableTemplateRepo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
enableTemplateRepo = btnEnableTemplateRepo.getSelection();
tblRepos.setEnabled(enableTemplateRepo);
validate();
}
});
return composite;
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class GitCloneURLDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setTitle(title);
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout(2, false));
Label lblRepo = new Label(container, SWT.NONE);
lblRepo.setText("Clone URL:");
txtRepository = new Text(container, SWT.BORDER);
txtRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (cloneUri != null)
txtRepository.setText(cloneUri.toString());
Label lblName = new Label(container, SWT.NONE);
lblName.setText("Name:");
txtName = new Text(container, SWT.BORDER);
txtName.setMessage("optional");
txtName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (name != null)
txtName.setText(name);
new Label(container, SWT.NONE).setText("Branch:");
txtBranch = new Text(container, SWT.BORDER);
txtBranch.setMessage("default: " + GitCloneTemplateParams.DEFAULT_BRANCH);
txtBranch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (branch != null)
txtBranch.setText(branch);
ControlDecoration branchDecor = new ControlDecoration(txtBranch, SWT.LEFT, container);
branchDecor.setDescriptionText("Specify the branch, tag or commit ID you would like to clone from the\nrepository. The default is 'origin/master'.");
branchDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
branchDecor.setShowHover(true);
ModifyListener modifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
updateFromInput();
updateButtons();
}
};
txtRepository.addModifyListener(modifyListener);
txtName.addModifyListener(modifyListener);
txtBranch.addModifyListener(modifyListener);
return area;
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class GitHubRepoDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setTitle(title);
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout(2, false));
Label lblRepo = new Label(container, SWT.NONE);
lblRepo.setText("Repository Name:");
txtRepository = new Text(container, SWT.BORDER);
txtRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
txtRepository.setMessage("username/repository");
if (repository != null)
txtRepository.setText(repository);
new Label(container, SWT.NONE).setText("Branch:");
txtBranch = new Text(container, SWT.BORDER);
txtBranch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
txtBranch.setMessage("default branch");
if (branch != null)
txtBranch.setText(branch);
ControlDecoration branchDecor = new ControlDecoration(txtBranch, SWT.LEFT, container);
branchDecor.setDescriptionText("Specify the branch, tag or commit ID you would like to clone from the\nrepository. We use the default branch specified in GitHub settings.");
branchDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
branchDecor.setShowHover(true);
final Button btnValidate = new Button(container, SWT.PUSH);
btnValidate.setText("Validate");
btnValidate.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
ModifyListener modifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
if (!txtRepository.getText().trim().equals(repository)) {
isValidated = false;
repository = txtRepository.getText().trim();
}
branch = txtBranch.getText().trim();
updateButtons();
}
};
txtRepository.addModifyListener(modifyListener);
txtBranch.addModifyListener(modifyListener);
btnValidate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setMessage(null, IMessageProvider.INFORMATION);
try {
if (repository == null || repository.isEmpty())
throw new GitHubValidationException("No repository name specified");
if (repository.contains(":/"))
throw new GitHubValidationException("Specify GitHub repositories as username/repository");
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
final GithubRepoDetailsDTO dto = new GitHub(cache, executor).loadRepoDetails(repository).getValue();
final URI cloneUri = URI.create(dto.clone_url);
btnValidate.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setMessage(String.format("Validated! Clone URL is '%s'. Default branch 'origin/%s'", cloneUri, dto.default_branch), IMessageProvider.INFORMATION);
isValidated = true;
updateButtons();
}
});
} catch (InvocationTargetException e) {
throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
};
ProgressRunner.execute(false, runnable, new ProgressMonitorDialog(getParentShell()), btnValidate.getDisplay());
setErrorMessage(null);
} catch (InvocationTargetException ex) {
Throwable t = ex.getCause();
if (t instanceof FileNotFoundException)
setErrorMessage("Could not find the requested repository");
else
setErrorMessage(t.getClass().getSimpleName() + ": " + t.getMessage());
} catch (GitHubValidationException ex) {
setErrorMessage(ex.getMessage());
} catch (Exception ex) {
setErrorMessage(ex.getClass().getSimpleName() + ": " + ex.getMessage());
}
}
});
return area;
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class PluginPropertiesPage method resetPropertyFields.
void resetPropertyFields() {
// Remove existing controls
Control[] children = fieldContainer.getChildren();
for (Control child : children) child.dispose();
// Add new ones
if (configElement != null) {
IConfigurationElement[] propertyElements = configElement.getChildren("property");
String path = configElement.getAttribute("path");
String className = configElement.getAttribute("class");
String summaryMessage = MessageFormat.format("Found {0,choice,0#no properties|1#one property|1<{0} properties} for plug-in class {1}.", propertyElements.length, className);
if (path != null) {
properties.put(Constants.PATH_DIRECTIVE, path);
txtPath.setText(path);
}
for (IConfigurationElement propertyElement : propertyElements) {
final String name = propertyElement.getAttribute("name");
String value = properties.get(name);
String propertyType = propertyElement.getAttribute("type");
String defaultStr = propertyElement.getAttribute("default");
if (value == null && defaultStr != null) {
value = defaultStr;
properties.put(name, defaultStr);
}
Label label = new Label(fieldContainer, SWT.NONE);
label.setText(name);
if ("boolean".equals(propertyType)) {
final Button button = new Button(fieldContainer, SWT.CHECK);
button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
button.setSelection("true".equalsIgnoreCase(value));
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
properties.put(name, button.getSelection() ? "true" : "false");
changed = true;
}
});
} else {
final Text text = new Text(fieldContainer, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (value != null)
text.setText(value);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String value = text.getText();
if (value == null || value.length() == 0)
properties.remove(name);
else
properties.put(name, value);
changed = true;
}
});
}
String description = propertyElement.getAttribute("description");
if (description != null) {
ControlDecoration decoration = new ControlDecoration(label, SWT.RIGHT | SWT.CENTER);
decoration.setShowHover(true);
decoration.setDescriptionText(description);
decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
}
String deprecation = propertyElement.getAttribute("deprecated");
if (deprecation != null) {
ControlDecoration decoration = new ControlDecoration(label, SWT.LEFT | SWT.CENTER);
decoration.setShowHover(true);
decoration.setDescriptionText("Property deprecated: " + deprecation);
decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage());
}
}
Label summaryLabel = new Label(fieldContainer, SWT.NONE);
summaryLabel.setText(summaryMessage);
summaryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
}
mainComposite.layout(true, true);
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class RunFrameworkPart method createSection.
final void createSection(Section section, FormToolkit tk) {
section.setText("Core Runtime");
Composite composite = tk.createComposite(section);
section.setClient(composite);
Label lblFramework = new Label(composite, SWT.NONE);
tk.adapt(lblFramework, true, true);
lblFramework.setText("OSGi Framework:");
cmbFramework = new Combo(composite, SWT.DROP_DOWN);
tk.adapt(cmbFramework);
tk.paintBordersFor(cmbFramework);
cmbFramework.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
frameworkViewer = new ComboViewer(cmbFramework);
frameworkViewer.setUseHashlookup(true);
frameworkViewer.setContentProvider(fwkContentProvider);
Label lblExecEnv = tk.createLabel(composite, "Execution Env.:");
cmbExecEnv = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
ControlDecoration eeDecor = new ControlDecoration(cmbExecEnv, SWT.LEFT | SWT.TOP, composite);
eeDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
eeDecor.setDescriptionText("The runtime Java Virtual Machine will be required/assumed " + "\nto support this Execution Environment");
eeViewer = new ComboViewer(cmbExecEnv);
eeViewer.setContentProvider(ArrayContentProvider.getInstance());
eeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((EE) element).getEEName();
}
});
eeViewer.setInput(EE.values());
// Listeners
cmbFramework.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
selectedFramework = cmbFramework.getText();
}
});
}
});
frameworkViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
Object element = ((IStructuredSelection) frameworkViewer.getSelection()).getFirstElement();
if (element instanceof LoadingContentElement) {
return;
}
markDirty();
if (element == null)
selectedFramework = null;
else
selectedFramework = element.toString();
}
});
}
});
eeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
selectedEE = (EE) ((IStructuredSelection) event.getSelection()).getFirstElement();
}
});
}
});
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 10;
composite.setLayout(layout);
lblFramework.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
GridData gd;
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 20;
gd.heightHint = 20;
cmbFramework.setLayoutData(gd);
lblExecEnv.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 20;
gd.heightHint = 20;
cmbExecEnv.setLayoutData(gd);
}
Aggregations