List of usage examples for org.eclipse.jface.resource JFaceResources getImage
public static Image getImage(String key)
null
if none. From source file:org.ow2.petals.client.swt.tabs.RequestTab.java
License:Open Source License
/** * Updates the message being displayed./*from w w w. j a va 2s . c o m*/ * @param msg a message (null to display nothing) * @param status an IStatus constant for the message's severity */ private void updateMessage(String msg, int status) { Color color = null; Image img = null; if (msg != null) { if (status == IStatus.INFO) { img = JFaceResources.getImage(ImageIds.INFO_16x16); color = getDisplay().getSystemColor(SWT.COLOR_BLACK); } else if (status == IStatus.OK) { img = null; color = getDisplay().getSystemColor(SWT.COLOR_BLACK); } else if (status == IStatus.WARNING) { img = JFaceResources.getImage(ImageIds.WARNING_16x16); color = this.clientApp.getColorManager().getOrangeColor(); } else if (status == IStatus.ERROR) { img = JFaceResources.getImage(ImageIds.ERROR_16x16); color = getDisplay().getSystemColor(SWT.COLOR_RED); } } this.reportingImageLabel.setImage(img); if (msg == null || color == null) this.reportingStyledText.setText(""); else { this.reportingStyledText.setText(msg); StyleRange sr = new StyleRange(); sr.foreground = color; sr.start = 0; sr.length = msg.length(); this.reportingStyledText.setStyleRange(sr); } this.reportingImageLabel.getParent().layout(); }
From source file:org.ow2.petals.client.swt.viewers.ServiceRegistryLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { Image result = null;/* w w w . j av a 2 s . co m*/ if (element instanceof ItfBean) result = JFaceResources.getImage(ImageIds.CONTRACT_16x16); else if (element instanceof SrvBean) result = JFaceResources.getImage(ImageIds.SERVICE_16x16); else if (element instanceof EdptBean) result = JFaceResources.getImage(ImageIds.ENDPOINT_16x16); return result; }
From source file:org.polarsys.reqcycle.jdt.model.JDTLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { Image image = JFaceResources.getImage(Activator.PLUGIN_ID + ICONS_JMETH_OBJ_GIF); if (image == null) { JFaceResources.getImageRegistry().put(Activator.PLUGIN_ID + ICONS_JMETH_OBJ_GIF, desc); image = JFaceResources.getImage(Activator.PLUGIN_ID + ICONS_JMETH_OBJ_GIF); }//from w ww . java2 s . c o m return image; }
From source file:org.pwsafe.passwordsafeswt.dialog.EditDialog.java
License:Open Source License
protected void createContents() { shell = new Shell(getParent(), SWT.RESIZE | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); shell.setImage(JFaceResources.getImage(PasswordSafeJFace.JPW_ICON)); shell.setSize(600, 603);//from ww w . j ava2s .c om shell.setText(Messages.getString("EditDialog.Title")); //$NON-NLS-1$ final GridLayout gridLayout_2 = new GridLayout(); gridLayout_2.marginWidth = 5; gridLayout_2.marginHeight = 5; shell.setLayout(gridLayout_2); shell.setMinimumSize(300, 400); // Setup adapter to catch any keypress and mark dialog dirty final KeyAdapter dirtyKeypress = new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { setDirty(true); } }; // use a modify listener as the password field drops letter key events // on Linux final ModifyListener entryEdited = new ModifyListener() { public void modifyText(final ModifyEvent e) { setDirty(true); } }; final Composite compositeLabel = new Composite(shell, SWT.NONE); final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.widthHint = 550; compositeLabel.setLayoutData(gridData); compositeLabel.setLayout(new GridLayout()); final Label labelInfo = new Label(compositeLabel, SWT.WRAP); final GridData gridData_1 = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); gridData_1.widthHint = 550; labelInfo.setLayoutData(gridData_1); labelInfo.setText(Messages.getString("EditDialog.Info")); //$NON-NLS-1$ final Composite compositeFields = new Composite(shell, SWT.NONE); compositeFields.setLayout(new FormLayout()); final GridData gridData_c = new GridData(SWT.FILL, SWT.FILL, true, true); gridData_c.widthHint = 550; compositeFields.setLayoutData(gridData_c); final Label lblGroup = new Label(compositeFields, SWT.NONE); final FormData formData = new FormData(); formData.top = new FormAttachment(0, 10); formData.left = new FormAttachment(0, 17); lblGroup.setLayoutData(formData); lblGroup.setText(Messages.getString("EditDialog.Group")); //$NON-NLS-1$ txtGroup = new Text(compositeFields, SWT.BORDER); txtGroup.addKeyListener(dirtyKeypress); final FormData formData_1 = new FormData(); // this sets the effective width of the labels column formData_1.left = new FormAttachment(lblGroup, 40, SWT.RIGHT); formData_1.top = new FormAttachment(lblGroup, 0, SWT.TOP); formData_1.right = new FormAttachment(43, 0); txtGroup.setLayoutData(formData_1); if (entryToEdit.getGroup() != null) txtGroup.setText(entryToEdit.getGroup()); final Label lblTitle = new Label(compositeFields, SWT.NONE); final FormData formData_2 = new FormData(); formData_2.top = new FormAttachment(txtGroup, 10, SWT.BOTTOM); formData_2.left = new FormAttachment(lblGroup, 0, SWT.LEFT); lblTitle.setLayoutData(formData_2); lblTitle.setText(Messages.getString("EditDialog.TitleLabel")); //$NON-NLS-1$ txtTitle = new Text(compositeFields, SWT.BORDER); final FormData formData_3 = new FormData(); formData_3.top = new FormAttachment(txtGroup, 10, SWT.BOTTOM); formData_3.left = new FormAttachment(txtGroup, 0, SWT.LEFT); formData_3.right = new FormAttachment(txtGroup, 0, SWT.RIGHT); txtTitle.setLayoutData(formData_3); txtTitle.addKeyListener(dirtyKeypress); if (entryToEdit.getTitle() != null) txtTitle.setText(entryToEdit.getTitle()); final Label lblUsername = new Label(compositeFields, SWT.NONE); final FormData formData_4 = new FormData(); formData_4.top = new FormAttachment(txtTitle, 10, SWT.BOTTOM); formData_4.left = new FormAttachment(lblTitle, 0, SWT.LEFT); lblUsername.setLayoutData(formData_4); lblUsername.setText(Messages.getString("EditDialog.Username")); //$NON-NLS-1$ txtUsername = new Text(compositeFields, SWT.BORDER); final FormData formData_5 = new FormData(); formData_5.top = new FormAttachment(txtTitle, 10); formData_5.left = new FormAttachment(txtTitle, 0, SWT.LEFT); formData_5.right = new FormAttachment(txtTitle, 0, SWT.RIGHT); txtUsername.setLayoutData(formData_5); txtUsername.addKeyListener(dirtyKeypress); if (entryToEdit.getUsername() != null) txtUsername.setText(entryToEdit.getUsername()); final Label lblPassword = new Label(compositeFields, SWT.NONE); final FormData formData_6 = new FormData(); formData_6.top = new FormAttachment(txtUsername, 10, SWT.BOTTOM); formData_6.left = new FormAttachment(lblUsername, 0, SWT.LEFT); lblPassword.setLayoutData(formData_6); lblPassword.setText(Messages.getString("EditDialog.Password")); //$NON-NLS-1$ txtPassword = new Text(compositeFields, SWT.BORDER); final FormData formData_7 = new FormData(); formData_7.top = new FormAttachment(txtUsername, 10, SWT.BOTTOM); formData_7.left = new FormAttachment(txtUsername, 0, SWT.LEFT); formData_7.right = new FormAttachment(txtUsername, 0, SWT.RIGHT); txtPassword.setLayoutData(formData_7); txtPassword.addKeyListener(dirtyKeypress); if (!UserPreferences.getInstance().getBoolean(JpwPreferenceConstants.SHOW_PASSWORD_IN_EDIT_MODE)) { txtPassword.setEchoChar('*'); } if (entryToEdit.getPassword() != null) txtPassword.setText(entryToEdit.getPassword().toString()); txtPassword.addModifyListener(entryEdited);// important: add after // setting content final Button btnShowPassword = new Button(compositeFields, SWT.NONE); btnShowPassword.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (txtPassword.getEchoChar() != '\0') { txtPassword.setEchoChar('\0'); btnShowPassword.setText(Messages.getString("EditDialog.HidePasswordButton")); //$NON-NLS-1$ } else { btnShowPassword.setText(Messages.getString("EditDialog.ShowPasswordButton")); //$NON-NLS-1$ txtPassword.setEchoChar('*'); } } }); final FormData formData_8 = new FormData(); formData_8.left = new FormAttachment(txtPassword, 10); formData_8.top = new FormAttachment(txtUsername, 10, SWT.BOTTOM); formData_8.right = new FormAttachment(PERCENT_NOTES_WIDTH, 0); btnShowPassword.setLayoutData(formData_8); if (UserPreferences.getInstance().getBoolean(JpwPreferenceConstants.SHOW_PASSWORD_IN_EDIT_MODE)) { btnShowPassword.setText(Messages.getString("EditDialog.HidePasswordButton")); //$NON-NLS-1$ } else { btnShowPassword.setText(Messages.getString("EditDialog.ShowPasswordButton")); //$NON-NLS-1$ } final Label lblNotes = new Label(compositeFields, SWT.NONE); final FormData formData_9 = new FormData(); formData_9.top = new FormAttachment(txtPassword, 5, SWT.BOTTOM); formData_9.left = new FormAttachment(lblPassword, 0, SWT.LEFT); lblNotes.setLayoutData(formData_9); lblNotes.setText(Messages.getString("EditDialog.Notes")); //$NON-NLS-1$ txtNotes = new Text(compositeFields, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP); final FormData formData_10 = new FormData(SWT.DEFAULT, 100); txtNotes.setSize(100, 100); formData_10.bottom = new FormAttachment(100, -112); formData_10.top = new FormAttachment(txtPassword, 5, SWT.BOTTOM); formData_10.right = new FormAttachment(btnShowPassword, 0, SWT.RIGHT); formData_10.left = new FormAttachment(txtPassword, 0, SWT.LEFT); txtNotes.setLayoutData(formData_10); txtNotes.addKeyListener(dirtyKeypress); if (entryToEdit.getNotes() != null) txtNotes.setText(entryToEdit.getNotes()); // New fields for V3 Files final Label lblUrl = new Label(compositeFields, SWT.NONE); FormData formDataTemp = new FormData(); formDataTemp.top = new FormAttachment(txtNotes, 10, SWT.BOTTOM); formDataTemp.left = new FormAttachment(lblNotes, 0, SWT.LEFT); lblUrl.setLayoutData(formDataTemp); lblUrl.setText(Messages.getString("EditDialog.Url")); //$NON-NLS-1$ txtUrl = new Text(compositeFields, SWT.BORDER); formDataTemp = new FormData(); formDataTemp.top = new FormAttachment(txtNotes, 10, SWT.BOTTOM); formDataTemp.left = new FormAttachment(txtNotes, 0, SWT.LEFT); formDataTemp.right = new FormAttachment(txtNotes, 0, SWT.RIGHT); txtUrl.setLayoutData(formDataTemp); txtUrl.addKeyListener(dirtyKeypress); if (entryToEdit.getUrl() != null) txtUrl.setText(entryToEdit.getUrl()); final Label lblAutotype = new Label(compositeFields, SWT.NONE); formDataTemp = new FormData(); formDataTemp.top = new FormAttachment(txtUrl, 10, SWT.BOTTOM); formDataTemp.left = new FormAttachment(lblUrl, 0, SWT.LEFT); lblAutotype.setLayoutData(formDataTemp); lblAutotype.setText(Messages.getString("EditDialog.Autotype")); //$NON-NLS-1$ txtAutotype = new Text(compositeFields, SWT.BORDER); formDataTemp = new FormData(); formDataTemp.top = new FormAttachment(txtUrl, 10, SWT.BOTTOM); formDataTemp.left = new FormAttachment(txtUrl, 0, SWT.LEFT); formDataTemp.right = new FormAttachment(txtPassword, 0, SWT.RIGHT); txtAutotype.setLayoutData(formDataTemp); txtAutotype.addKeyListener(dirtyKeypress); if (entryToEdit.getAutotype() != null) txtAutotype.setText(entryToEdit.getAutotype()); final Label lblPasswordExpire = new Label(compositeFields, SWT.NONE); final FormData fd_lblPasswordExpire = new FormData(); fd_lblPasswordExpire.top = new FormAttachment(txtAutotype, 10, SWT.BOTTOM); fd_lblPasswordExpire.left = new FormAttachment(lblAutotype, 0, SWT.LEFT); lblPasswordExpire.setLayoutData(fd_lblPasswordExpire); lblPasswordExpire.setText(Messages.getString("EditDialog.PasswordExpires")); //$NON-NLS-1$ txtPasswordExpire = new Text(compositeFields, SWT.BORDER); final FormData fd_txtPasswordExpire = new FormData(); fd_txtPasswordExpire.left = new FormAttachment(txtAutotype, 0, SWT.LEFT); fd_txtPasswordExpire.right = new FormAttachment(txtAutotype, 0, SWT.RIGHT); fd_txtPasswordExpire.top = new FormAttachment(txtAutotype, 10, SWT.BOTTOM); txtPasswordExpire.setLayoutData(fd_txtPasswordExpire); txtPasswordExpire.addModifyListener(new ModifyListener() { Color red = null; Color normal = null; final Date now = new Date(); public void modifyText(final ModifyEvent e) { final Text widget = ((Text) e.widget); final String dateText = widget.getText(); if (dateText != null && dateText.length() > 0) { if (red == null) { red = shell.getDisplay().getSystemColor(SWT.COLOR_RED); normal = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); } try { final Date date = convertTextToDate(dateText); if (now.after(date)) { widget.setForeground(red); } else { widget.setForeground(normal); } } catch (final ParseException e1) { // no prob } } } }); txtPasswordExpire.setText(format(entryToEdit.getExpires())); txtPasswordExpire.addKeyListener(dirtyKeypress); addDateChooser(compositeFields); shell.setDefaultButton(createButtons(compositeFields, btnShowPassword)); if (entryToEdit.getTitle() != null && entryToEdit.getTitle().length() > 0) { createTimesComposite(shell); } }
From source file:org.pwsafe.passwordsafeswt.dialog.PasswordDialog.java
License:Open Source License
protected void createContents() { shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); shell.setImage(JFaceResources.getImage(PasswordSafeJFace.JPW_ICON)); shell.setLayout(new FormLayout()); int heigth = verified ? 230 : 170; shell.setSize(380, heigth);/* w w w.j a v a 2 s . co m*/ shell.setText(windowTitle); final Label label = new Label(shell, SWT.WRAP); final FormData formData = new FormData(); formData.top = new FormAttachment(0, 5); formData.right = new FormAttachment(100, -5); formData.left = new FormAttachment(0, 5); formData.width = 360; label.setLayoutData(formData); label.setText(purposeText + " " + shortFileName); //$NON-NLS-1$; label.setToolTipText(fileName); final Label lblCombination = new Label(shell, SWT.NONE); final FormData formData_1 = new FormData(); formData_1.top = new FormAttachment(label, 20, SWT.BOTTOM); formData_1.left = new FormAttachment(10, 0); lblCombination.setLayoutData(formData_1); lblCombination.setText(Messages.getString("PasswordDialog.SafeCombination")); //$NON-NLS-1$; txtCombination = new Text(shell, SWT.PASSWORD | SWT.BORDER); final FormData formData_2 = new FormData(); formData_2.top = new FormAttachment(lblCombination, 0, SWT.TOP); formData_2.left = new FormAttachment(lblCombination, 5); formData_2.right = new FormAttachment(85, 0); txtCombination.setLayoutData(formData_2); Control buttonOrientation = txtCombination; if (verified) { final Label lblVerify = new Label(shell, SWT.NONE); final FormData formData_3 = new FormData(); formData_3.top = new FormAttachment(txtCombination, 10); formData_3.right = new FormAttachment(lblCombination, 0, SWT.RIGHT); lblVerify.setLayoutData(formData_3); lblVerify.setText(Messages.getString("PasswordDialog.Verify")); //$NON-NLS-1$ txtVerify = new Text(shell, SWT.PASSWORD | SWT.BORDER); final FormData formData_4 = new FormData(); formData_4.top = new FormAttachment(lblVerify, 0, SWT.TOP); formData_4.left = new FormAttachment(txtCombination, 0, SWT.LEFT); formData_4.right = new FormAttachment(txtCombination, 0, SWT.RIGHT); txtVerify.setLayoutData(formData_4); buttonOrientation = txtVerify; } final Button btnCancel = new Button(shell, SWT.NONE); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shell.dispose(); } }); final FormData formData_7 = new FormData(); formData_7.width = 80; formData_7.top = new FormAttachment(buttonOrientation, 20); formData_7.bottom = new FormAttachment(100, -10); formData_7.left = new FormAttachment(50, -5); btnCancel.setLayoutData(formData_7); btnCancel.setText(Messages.getString("PasswordDialog.CancelButton")); //$NON-NLS-1$ final Button btnOk = new Button(shell, SWT.NONE); shell.setDefaultButton(btnOk); if (verified) { btnOk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (txtCombination.getText().equals(txtVerify.getText())) { result = new StringBuilder(txtCombination.getText()); shell.dispose(); } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText(Messages.getString("PasswordDialog.PasswordMismatchMessage.Title")); //$NON-NLS-1$ mb.setMessage(Messages.getString("PasswordDialog.PasswordMismatchMessage.Text")); //$NON-NLS-1$ mb.open(); } } }); } else { // TODO: On Mac Carbon dispose leads to a recall of Main Window // shellActivated - check this btnOk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = new StringBuilder(txtCombination.getText()); shell.dispose(); } }); } final FormData formData_6 = new FormData(); formData_6.width = 80; formData_6.top = new FormAttachment(btnCancel, 0, SWT.TOP); formData_6.right = new FormAttachment(btnCancel, -10, SWT.LEFT); btnOk.setLayoutData(formData_6); btnOk.setText(Messages.getString("PasswordDialog.OkButton")); //$NON-NLS-1$ /* * final Button btnHelp = new Button(shell, SWT.NONE); final FormData * formData_8 = new FormData(); formData_8.width = 80; formData_8.top = * new FormAttachment(btnCancel, 0, SWT.TOP); formData_8.left = new * FormAttachment(btnCancel, 10, SWT.RIGHT); * btnHelp.setLayoutData(formData_8); * btnHelp.setText(Messages.getString("PasswordDialog.HelpButton")); * //$NON-NLS-1$ */ }
From source file:org.seasar.s2junit4plugin.wizard.NewS2JUnit4TestCaseWizardPageOne.java
License:Apache License
/** * Creates the controls for the JUnit 4 toggle control. Expects a <code>GridLayout</code> with * at least 3 columns./* w w w.jav a 2 s . com*/ * * @param composite the parent composite * @param nColumns number of columns to span * * @since 3.2 */ protected void createBuildPathConfigureControls(Composite composite, int nColumns) { Composite inner = new Composite(composite, SWT.NONE); inner.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, nColumns, 1)); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; inner.setLayout(layout); fImage = new Label(inner, SWT.NONE); fImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); fImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1)); fLink = new Link(inner, SWT.WRAP); fLink.setText("\n\n"); //$NON-NLS-1$ fLink.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performBuildpathConfiguration(e.text); } }); GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1); gd.widthHint = convertWidthInCharsToPixels(60); fLink.setLayoutData(gd); updateBuildPathMessage(); }
From source file:org.sf.feeling.swt.win32.extension.example.provider.FileTableLabelProvider.java
License:Open Source License
public Image getColumnImage(Object element, int index) { if (element instanceof String && desktop != null && !desktop.isDisposed()) { if (index == 0) { String path = (String) element; Image image = null;/*from w w w . j a v a2 s .com*/ File file = new File(path); int extIndex = file.getAbsolutePath().lastIndexOf('.'); if (file.exists()) { if (file.isFile() && extIndex >= 0) { String extension = file.getAbsolutePath().substring(extIndex); if (".exe".equals(extension.toLowerCase()) && file.length() < 1024 * 1024 * 50) { CanonicalPIDL handle = IShellFolder.getCanonicalPIDL(desktop, path); Image fileImage = IShellFolder.getIcon(handle, false); if (fileImage != null) { image = ImageUtil.getExeImage(); if (image != null && fileImage != null) { if (!ImageUtil.compareImageData(fileImage.getImageData(), image.getImageData())) { image = ImageUtil.getProgramImage(path, fileImage.getImageData()); } } fileImage.dispose(); } handle.dispose(); } else if (".ico".equals(extension.toLowerCase())) { Image[] fileImage = ShellIcon.getFileIcons(file, ShellIcon.ICON_SMALL); if (fileImage != null && fileImage.length > 0 && fileImage[0] != null && fileImage[0].getImageData() != null) { image = ImageUtil.getProgramImage(path, fileImage[0].getImageData()); } } else if (file.length() < 1024 * 5) { CanonicalPIDL handle = IShellFolder.getCanonicalPIDL(desktop, path); if (IShellFolder.isLinkFile(handle)) { Image fileImage = IShellFolder.getIcon(handle, false); if (fileImage != null) { image = ImageUtil.getProgramImage(path, fileImage.getImageData()); fileImage.dispose(); } } handle.dispose(); } if (image == null) image = ImageUtil.getProgramImage(extension); if (image == null) { Program program = Program.findProgram(extension); if (program != null) { ImageData programImageData = program.getImageData(); image = ImageUtil.getProgramImage(extension, programImageData); } else { if (!".exe".equals(extension.toLowerCase())) { CanonicalPIDL handle = IShellFolder.getCanonicalPIDL(desktop, path); Image fileImage = IShellFolder.getIcon(handle, false); if (fileImage != null) { image = ImageUtil.getProgramImage(extension, fileImage.getImageData()); fileImage.dispose(); } handle.dispose(); } } } } if (file.isFile() && image == null) { image = ImageUtil.getFileImage(); } if (file.isDirectory()) { image = ImageUtil.getDirectoryImage(); } } else { image = JFaceResources.getImage(path); if (image == null) { CanonicalPIDL handle = IShellFolder.getCanonicalPIDL(desktop, path); if (handle != null) { Image fileImage = IShellFolder.getIcon(handle, false); image = ImageUtil.getProgramImage(path, fileImage == null ? null : fileImage.getImageData()); if (fileImage != null) fileImage.dispose(); handle.dispose(); } } } return image; } } return null; }
From source file:org.springframework.ide.eclipse.wizard.ui.BeanChildDialog.java
License:Open Source License
protected void updateMessage() { String message = getMessage(); if (message != null) { if (BeanWizard.getIgnoreError()) { messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); } else {//from ww w.j ava 2 s . c o m messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); } messageLabel.setText(message); } else { messageLabel.setImage(null); messageLabel.setText(getDefaultMessage()); } messageLabel.redraw(); }
From source file:org.summer.sdt.internal.ui.preferences.ComplianceConfigurationBlock.java
License:Open Source License
private Composite createComplianceTabContent(Composite folder) { String[] values3456 = new String[] { VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 };//from w w w .j av a2 s . c o m String[] values3456Labels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, PreferencesMessages.ComplianceConfigurationBlock_version15, PreferencesMessages.ComplianceConfigurationBlock_version16, PreferencesMessages.ComplianceConfigurationBlock_version17, PreferencesMessages.ComplianceConfigurationBlock_version18, }; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); Composite composite = sc1.getBody(); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); fControlsComposite = new Composite(composite, SWT.NONE); fControlsComposite.setFont(composite.getFont()); fControlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; fControlsComposite.setLayout(layout); int nColumns = 3; layout = new GridLayout(); layout.numColumns = nColumns; Group group = new Group(fControlsComposite, SWT.NONE); group.setFont(fControlsComposite.getFont()); group.setText(PreferencesMessages.ComplianceConfigurationBlock_compliance_group_label); group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); group.setLayout(layout); String[] defaultUserValues = new String[] { DEFAULT_CONF, USER_CONF }; Control[] otherChildren = group.getChildren(); if (fProject != null) { String label = PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label; int widthHint = fPixelConverter.convertWidthInCharsToPixels(40); addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint, new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openBuildPathPropertyPage(); } }); } Control[] allChildren = group.getChildren(); fComplianceFollowsEEControls.addAll(Arrays.asList(allChildren)); fComplianceFollowsEEControls.removeAll(Arrays.asList(otherChildren)); otherChildren = allChildren; String label = PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label; addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0); label = PreferencesMessages.ComplianceConfigurationBlock_default_settings_label; addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0); allChildren = group.getChildren(); fComplianceControls.addAll(Arrays.asList(allChildren)); fComplianceControls.removeAll(Arrays.asList(otherChildren)); otherChildren = allChildren; int indent = LayoutUtil.getIndent(); String[] versions = new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 }; String[] versionsLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11, PreferencesMessages.ComplianceConfigurationBlock_version11, PreferencesMessages.ComplianceConfigurationBlock_version12, PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, PreferencesMessages.ComplianceConfigurationBlock_version15, PreferencesMessages.ComplianceConfigurationBlock_version16, PreferencesMessages.ComplianceConfigurationBlock_version17, PreferencesMessages.ComplianceConfigurationBlock_version18 }; boolean showJsr14 = ComplianceConfigurationBlock.VERSION_JSR14 .equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)); if (showJsr14) { versions = append(versions, ComplianceConfigurationBlock.VERSION_JSR14); versionsLabels = append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14); } label = PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label; addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent); label = PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label; addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent); String[] errorWarningIgnore = new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_error, PreferencesMessages.ComplianceConfigurationBlock_warning, PreferencesMessages.ComplianceConfigurationBlock_ignore }; label = PreferencesMessages.ComplianceConfigurationBlock_pb_assert_as_identifier_label; addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); label = PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label; addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); allChildren = group.getChildren(); fComplianceChildControls.addAll(Arrays.asList(allChildren)); fComplianceChildControls.removeAll(Arrays.asList(otherChildren)); layout = new GridLayout(); layout.numColumns = nColumns; group = new Group(fControlsComposite, SWT.NONE); group.setFont(fControlsComposite.getFont()); group.setText(PreferencesMessages.ComplianceConfigurationBlock_classfiles_group_label); group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); group.setLayout(layout); String[] generateValues = new String[] { GENERATE, DO_NOT_GENERATE }; String[] enableDisableValues = new String[] { ENABLED, DISABLED }; label = PreferencesMessages.ComplianceConfigurationBlock_variable_attr_label; addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); label = PreferencesMessages.ComplianceConfigurationBlock_line_number_attr_label; addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0); label = PreferencesMessages.ComplianceConfigurationBlock_source_file_attr_label; addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0); label = PreferencesMessages.ComplianceConfigurationBlock_codegen_unused_local_label; addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0); label = PreferencesMessages.ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label; addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0); label = PreferencesMessages.ComplianceConfigurationBlock_codegen_method_parameters_attr; addCheckBox(group, label, PREF_CODEGEN_METHOD_PARAMETERS_ATTR, generateValues, 0); Composite infoComposite = new Composite(fControlsComposite, SWT.NONE); infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); infoComposite.setLayout(new GridLayout(2, false)); fJRE50InfoImage = new Label(infoComposite, SWT.NONE); fJRE50InfoImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); GridData gd = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false); fJRE50InfoImage.setLayoutData(gd); fJRE50InfoText = new Link(infoComposite, SWT.WRAP); fJRE50InfoText.setFont(composite.getFont()); // set a text: not the real one, just for layouting fJRE50InfoText.setText( Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { getVersionLabel(VERSION_1_3), getVersionLabel(VERSION_1_3) })); fJRE50InfoText.setVisible(false); fJRE50InfoText.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { if ("1".equals(e.text)) { //$NON-NLS-1$ openJREInstallPreferencePage(false); } else if ("2".equals(e.text)) { //$NON-NLS-1$ openJREInstallPreferencePage(true); } else { openBuildPathPropertyPage(); } } public void widgetSelected(SelectionEvent e) { widgetDefaultSelected(e); } }); gd = new GridData(GridData.FILL, GridData.FILL, true, true); gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(50); fJRE50InfoText.setLayoutData(gd); validateComplianceStatus(); return sc1; }
From source file:org.summer.sdt.internal.ui.preferences.ComplianceConfigurationBlock.java
License:Open Source License
private void validateComplianceStatus() { if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) { boolean isVisible = false; String compliance = getStoredValue(PREF_COMPLIANCE); // get actual value IVMInstall install = null;//from w w w.ja v a2s. c o m if (fProject != null) { // project specific settings: only test if a 50 JRE is installed try { install = JavaRuntime.getVMInstall(JavaCore.create(fProject)); } catch (CoreException e) { JavaPlugin.log(e); } } else { install = JavaRuntime.getDefaultVMInstall(); } if (install instanceof IVMInstall2) { String compilerCompliance = JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance); if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance String[] args = { getVersionLabel(compliance), getVersionLabel(compilerCompliance) }; if (fProject == null) { fJRE50InfoText.setText(Messages .format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args)); } else { fJRE50InfoText.setText(Messages.format( PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args)); } isVisible = true; } } // String source= getValue(PREF_SOURCE_COMPATIBILITY); // if (VERSION_1_8.equals(source)) { // fJRE50InfoText.setText("This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."); //$NON-NLS-1$ // isVisible= true; // } fJRE50InfoText.setVisible(isVisible); fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null); fJRE50InfoImage.getParent().layout(); } }