use of org.eclipse.jface.fieldassist.ControlDecoration in project azure-tools-for-java by Microsoft.
the class CreateRedisCacheForm method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
resourceBundle = MessageHandler.getResourceBundle(MODULE_NAME);
if (resourceBundle == null) {
return null;
}
setTitle(MessageHandler.getResourceString(resourceBundle, DIALOG_TITLE));
setMessage(MessageHandler.getResourceString(resourceBundle, DIALOG_MESSAGE));
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
GridLayout glContainer = new GridLayout(4, false);
glContainer.horizontalSpacing = LAYOUT_SPACING;
glContainer.verticalSpacing = LAYOUT_SPACING;
container.setLayout(glContainer);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblDnsName = new Label(container, SWT.NONE);
lblDnsName.setText(MessageHandler.getResourceString(resourceBundle, LABEL_DNS_NAME));
txtDnsName = new Text(container, SWT.BORDER);
txtDnsName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
decoratorDnsName = new ControlDecoration(txtDnsName, SWT.CENTER);
decoratorDnsName.setDescriptionText(MessageHandler.getResourceString(resourceBundle, DECORACTOR_DNS));
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
if (fieldDecoration != null) {
Image image = fieldDecoration.getImage();
decoratorDnsName.setImage(image);
}
Label lblDnsSuffix = new Label(container, SWT.NONE);
lblDnsSuffix.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
lblDnsSuffix.setText(MessageHandler.getResourceString(resourceBundle, LABEL_DNS_SUFFIX));
Label lblSubscription = new Label(container, SWT.NONE);
lblSubscription.setText(MessageHandler.getResourceString(resourceBundle, LABEL_SUBSCRIPTION));
cbSubs = new Combo(container, SWT.READ_ONLY);
cbSubs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
Label lblResourceGroup = new Label(container, SWT.NONE);
lblResourceGroup.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
lblResourceGroup.setText(MessageHandler.getResourceString(resourceBundle, LABEL_RESOURCE_GRP));
rdoCreateNew = new Button(container, SWT.RADIO);
rdoCreateNew.setText(MessageHandler.getResourceString(resourceBundle, RADIOBUTTON_NEW_GRP));
rdoCreateNew.setSelection(true);
txtNewResGrpName = new Text(container, SWT.BORDER);
txtNewResGrpName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
txtNewResGrpName.setEnabled(true);
rdoUseExisting = new Button(container, SWT.RADIO);
rdoUseExisting.setText(MessageHandler.getResourceString(resourceBundle, RADIOBUTTON_USE_EXIST_GRP));
rdoUseExisting.setSelection(false);
cbUseExisting = new Combo(container, SWT.READ_ONLY);
cbUseExisting.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
cbUseExisting.add(MessageHandler.getResourceString(resourceBundle, LOADING));
cbUseExisting.select(0);
cbUseExisting.setEnabled(false);
Label lblLocation = new Label(container, SWT.NONE);
lblLocation.setText(MessageHandler.getResourceString(resourceBundle, LABEL_LOCTION));
cbLocations = new Combo(container, SWT.READ_ONLY);
cbLocations.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
cbLocations.add(MessageHandler.getResourceString(resourceBundle, LOADING));
cbLocations.select(0);
cbLocations.setEnabled(false);
Label lblPricingTier = new Label(container, SWT.READ_ONLY);
lblPricingTier.setText(MessageHandler.getResourceString(resourceBundle, LABEL_PRICING));
cbPricetiers = new Combo(container, SWT.READ_ONLY);
cbPricetiers.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
if (skus.keySet().size() > 0) {
for (String price : skus.keySet()) {
cbPricetiers.add(price);
}
cbPricetiers.select(0);
selectedPriceTierValue = cbPricetiers.getText();
}
Link lnkPrice = new Link(container, SWT.NONE);
lnkPrice.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
lnkPrice.setText(MessageHandler.getResourceString(resourceBundle, LINK_PRICE));
lnkPrice.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.text));
} catch (Exception ex) {
LOG.log(MessageHandler.getCommonStr(OPEN_BROWSER_ERROR), ex);
}
}
});
chkUnblockPort = new Button(container, SWT.CHECK);
chkUnblockPort.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
chkUnblockPort.setText(MessageHandler.getResourceString(resourceBundle, CHECKBOX_SSL));
this.setHelpAvailable(false);
txtDnsName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
dnsNameValue = txtDnsName.getText();
if (dnsNameValue.length() > REDIS_CACHE_MAX_NAME_LENGTH || !dnsNameValue.matches(DNS_NAME_REGEX)) {
decoratorDnsName.show();
} else {
decoratorDnsName.hide();
}
validateFields();
}
});
for (SubscriptionDetail sub : selectedSubscriptions) {
cbSubs.add(String.format(SUBS_COMBO_ITEMS_FORMAT, sub.getSubscriptionName(), sub.getSubscriptionId()));
}
cbSubs.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
currentSub = selectedSubscriptions.get(cbSubs.getSelectionIndex());
if (loaded) {
fillLocationsAndResourceGrps(currentSub);
}
validateFields();
}
});
if (selectedSubscriptions.size() > 0) {
cbSubs.select(0);
}
rdoCreateNew.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
txtNewResGrpName.setEnabled(true);
cbUseExisting.setEnabled(false);
newResGrp = true;
selectedResGrpValue = txtNewResGrpName.getText();
validateFields();
}
});
rdoUseExisting.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
txtNewResGrpName.setEnabled(false);
cbUseExisting.setEnabled(true);
if (loaded) {
newResGrp = false;
selectedResGrpValue = sortedGroups.get(cbUseExisting.getSelectionIndex());
validateFields();
}
}
});
txtNewResGrpName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
selectedResGrpValue = txtNewResGrpName.getText();
validateFields();
}
});
cbUseExisting.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedResGrpValue = cbUseExisting.getText();
validateFields();
}
});
cbLocations.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedLocationValue = sortedLocations.get(cbLocations.getSelectionIndex()).name();
validateFields();
}
});
cbPricetiers.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedPriceTierValue = cbPricetiers.getText();
validateFields();
}
});
chkUnblockPort.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button btn = (Button) e.getSource();
if (btn.getSelection()) {
noSSLPort = true;
} else {
noSSLPort = false;
}
}
});
DefaultLoader.getIdeHelper().runInBackground(null, MessageHandler.getResourceString(resourceBundle, LOADING_LOCATION_AND_GRPS), false, true, MessageHandler.getResourceString(resourceBundle, LOADING_LOCATION_AND_GRPS), new Runnable() {
@Override
public void run() {
try {
AzureModelController.updateSubscriptionMaps(null);
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
fillLocationsAndResourceGrps(currentSub);
cbLocations.setEnabled(true);
loaded = true;
validateFields();
}
});
} catch (Exception ex) {
LOG.log(MessageHandler.getCommonStr(LOAD_LOCATION_AND_RESOURCE_ERROR), ex);
}
}
});
return area;
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method decorateContorolAndRegister.
protected ControlDecoration decorateContorolAndRegister(Control c) {
ControlDecoration d = new ControlDecoration(c, SWT.TOP | SWT.LEFT);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
Image img = fieldDecoration.getImage();
d.setImage(img);
d.hide();
decorations.add(d);
return d;
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class ImportBndWorkspaceWizardPageOne method createControl.
@Override
public void createControl(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
Label lblFolder = new Label(container, SWT.NONE);
lblFolder.setText("Root Directory:");
txtFolder = new Text(container, SWT.BORDER | SWT.SINGLE);
txtFolder.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
getWizard().getContainer().updateButtons();
}
});
//Adding the decorator
txtFolderErrorDecorator = new ControlDecoration(txtFolder, SWT.TOP | SWT.RIGHT);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
Image img = fieldDecoration.getImage();
txtFolderErrorDecorator.setImage(img);
txtFolderErrorDecorator.setDescriptionText("Selected folder must contain valid Bnd Workspace configuration project.");
// hiding it initially
txtFolderErrorDecorator.hide();
Button btnOpenDialog = new Button(container, SWT.PUSH);
btnOpenDialog.setText("Browse...");
btnOpenDialog.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dirDialog = new DirectoryDialog(container.getShell());
dirDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
dirDialog.setText("Select the folder containing the project.");
txtFolder.setText(dirDialog.open());
getWizard().getContainer().updateButtons();
}
});
Label lblProjects = new Label(container, SWT.NONE);
lblProjects.setText("Projects:");
tableViewer = new TableViewer(container, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
// configuration project always first
if (e1 instanceof File && e2 instanceof Project) {
return -1;
} else if (e1 instanceof Project && e2 instanceof File) {
return 1;
}
Project p1 = (Project) e1;
Project p2 = (Project) e2;
return super.compare(viewer, p1.getName(), p2.getName());
}
});
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
// Disable selection since the tableviewer should be readonly, but not disabled
if (!event.getSelection().isEmpty()) {
tableViewer.setSelection(StructuredSelection.EMPTY);
}
}
});
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
column.setLabelProvider(new ProjectsColumnLabelProvider());
Button refreshButton = new Button(container, SWT.PUSH);
refreshButton.setText("Refresh");
refreshButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
getWizard().getContainer().updateButtons();
}
});
deleteButton = new Button(container, SWT.CHECK);
deleteButton.setText("Delete existing settings");
inferExecutionEnvironmentButton = new Button(container, SWT.CHECK);
inferExecutionEnvironmentButton.setSelection(true);
inferExecutionEnvironmentButton.setText("Infer execution-environment (J2SE and JavaSE).");
inferExecutionEnvironmentButton.setToolTipText("Uses the 'javac.target' from the Bnd Workspace to infer a Execution Environment to the JRE container. If nothing matches, the default JRE will be used.\nExisting containers will be removed.");
FormLayout layout = new FormLayout();
container.setLayout(layout);
FormData fd_lblFolder = new FormData();
fd_lblFolder.top = new FormAttachment(0, 10);
fd_lblFolder.left = new FormAttachment(0, 10);
lblFolder.setLayoutData(fd_lblFolder);
FormData fd_txtFolder = new FormData();
fd_txtFolder.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
fd_txtFolder.left = new FormAttachment(lblFolder, 10);
fd_txtFolder.right = new FormAttachment(100, -100);
txtFolder.setLayoutData(fd_txtFolder);
FormData fd_btnDialog = new FormData();
fd_btnDialog.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
fd_btnDialog.left = new FormAttachment(txtFolder, 10);
fd_btnDialog.right = new FormAttachment(100, -10);
btnOpenDialog.setLayoutData(fd_btnDialog);
FormData fd_lblProjects = new FormData();
fd_lblProjects.top = new FormAttachment(lblFolder, 20);
fd_lblProjects.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
lblProjects.setLayoutData(fd_lblProjects);
FormData fd_table = new FormData();
fd_table.top = new FormAttachment(lblProjects, 5);
fd_table.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
fd_table.right = new FormAttachment(100, -100);
fd_table.bottom = new FormAttachment(100, -55);
tableViewer.getTable().setLayoutData(fd_table);
FormData fd_btnRefresh = new FormData();
fd_btnRefresh.top = new FormAttachment(tableViewer.getTable(), 0, SWT.TOP);
fd_btnRefresh.left = new FormAttachment(btnOpenDialog, 0, SWT.LEFT);
fd_btnRefresh.right = new FormAttachment(100, -10);
refreshButton.setLayoutData(fd_btnRefresh);
FormData fd_btnDelete = new FormData();
fd_btnDelete.top = new FormAttachment(tableViewer.getTable(), 10);
fd_btnDelete.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
deleteButton.setLayoutData(fd_btnDelete);
FormData fd_btnInfer = new FormData();
fd_btnInfer.top = new FormAttachment(deleteButton, 10);
fd_btnInfer.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
inferExecutionEnvironmentButton.setLayoutData(fd_btnInfer);
getShell().setMinimumSize(470, 450);
// required to avoid an error in the system
setControl(parent);
setPageComplete(false);
txtFolder.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class ResolutionFailurePanel method createControl.
public void createControl(final Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
composite = toolkit.createComposite(parent);
composite.setLayout(new GridLayout(1, false));
GridData gd;
sectProcessingErrors = toolkit.createSection(composite, Section.TITLE_BAR | Section.EXPANDED);
sectProcessingErrors.setText("Processing Errors:");
processingErrorsText = toolkit.createText(sectProcessingErrors, "", SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
sectProcessingErrors.setClient(processingErrorsText);
ControlDecoration controlDecoration = new ControlDecoration(processingErrorsText, SWT.RIGHT | SWT.TOP);
controlDecoration.setMarginWidth(2);
controlDecoration.setDescriptionText("Double-click to view details");
controlDecoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 600;
gd.heightHint = 300;
sectProcessingErrors.setLayoutData(gd);
sectUnresolved = toolkit.createSection(composite, Section.TITLE_BAR | Section.TWISTIE);
sectUnresolved.setText("Unresolved Requirements:");
createUnresolvedViewToolBar(sectUnresolved);
Tree treeUnresolved = toolkit.createTree(sectUnresolved, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL);
sectUnresolved.setClient(treeUnresolved);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.widthHint = 600;
gd.heightHint = 300;
sectUnresolved.setLayoutData(gd);
unresolvedViewer = new TreeViewer(treeUnresolved);
unresolvedViewer.setContentProvider(new UnresolvedRequirementsContentProvider());
unresolvedViewer.setLabelProvider(new RequirementWithResourceLabelProvider());
setFailureViewMode();
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class GeneralInfoPart method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText("Basic Information");
KeyStroke assistKeyStroke = null;
try {
assistKeyStroke = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException x) {
// Ignore
}
FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
toolkit.createLabel(composite, "Version:");
txtVersion = toolkit.createText(composite, "", SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION);
Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE);
txtActivator = toolkit.createText(composite, "", SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR);
toolkit.createLabel(composite, "Declarative Services:");
cmbComponents = new Combo(composite, SWT.READ_ONLY);
// Content Proposal for the Activator field
ContentProposalAdapter activatorProposalAdapter = null;
ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider();
activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters());
activatorProposalAdapter.addContentProposalListener(proposalProvider);
activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider());
activatorProposalAdapter.setAutoActivationDelay(1000);
// Decorator for the Activator field
ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite);
decorActivator.setImage(contentAssistDecoration.getImage());
decorActivator.setMarginWidth(3);
if (assistKeyStroke == null) {
decorActivator.setDescriptionText("Content Assist is available. Start typing to activate");
} else {
decorActivator.setDescriptionText(MessageFormat.format("Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format()));
}
decorActivator.setShowOnlyOnFocus(true);
decorActivator.setShowHover(true);
// Decorator for the Components combo
ControlDecoration decorComponents = new ControlDecoration(cmbComponents, SWT.LEFT | SWT.CENTER, composite);
decorComponents.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decorComponents.setMarginWidth(3);
decorComponents.setDescriptionText("Use Java annotations to detect Declarative Service Components.");
decorComponents.setShowOnlyOnFocus(false);
decorComponents.setShowHover(true);
// Listeners
txtVersion.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
addDirtyProperty(Constants.BUNDLE_VERSION);
}
});
}
});
cmbComponents.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
ComponentChoice old = componentChoice;
int index = cmbComponents.getSelectionIndex();
if (index >= 0 && index < ComponentChoice.values().length) {
componentChoice = ComponentChoice.values()[cmbComponents.getSelectionIndex()];
if (old != componentChoice) {
addDirtyProperty(aQute.bnd.osgi.Constants.SERVICE_COMPONENT);
addDirtyProperty(aQute.bnd.osgi.Constants.DSANNOTATIONS);
if (old == null) {
cmbComponents.remove(ComponentChoice.values().length);
}
}
}
}
});
}
});
txtActivator.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
addDirtyProperty(Constants.BUNDLE_ACTIVATOR);
}
});
}
});
linkActivator.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent ev) {
String activatorClassName = txtActivator.getText();
if (activatorClassName != null && activatorClassName.length() > 0) {
try {
IJavaProject javaProject = getJavaProject();
if (javaProject == null)
return;
IType activatorType = javaProject.findType(activatorClassName);
if (activatorType != null) {
JavaUI.openInEditor(activatorType, true, true);
}
} catch (PartInitException e) {
ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening an editor for activator class '{0}'.", activatorClassName), e));
} catch (JavaModelException e) {
ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error searching for activator class '{0}'.", activatorClassName), e));
}
}
}
});
activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() {
@Override
public void proposalAccepted(IContentProposal proposal) {
if (proposal instanceof JavaContentProposal) {
String selectedPackageName = ((JavaContentProposal) proposal).getPackageName();
if (!model.isIncludedPackage(selectedPackageName)) {
model.addPrivatePackage(selectedPackageName);
}
}
}
});
// Layout
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 15;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
txtVersion.setLayoutData(gd);
txtActivator.setLayoutData(gd);
cmbComponents.setLayoutData(gd);
}
Aggregations