org.eclipse.ui.ide.IDEEncoding Java Examples
The following examples show how to use
org.eclipse.ui.ide.IDEEncoding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EncodingLabel.java From eclipse-encoding-plugin with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") private List<EncodingItem> getEncodingItemList(final ActiveDocument doc) { List<String> encodingList = IDEEncoding.getIDEEncodings(); Charsets.add(encodingList, doc.getCurrentEncoding()); Charsets.add(encodingList, doc.getInheritedEncoding()); Charsets.add(encodingList, doc.getContentTypeEncoding()); Charsets.add(encodingList, doc.getContentCharset()); Charsets.add(encodingList, doc.getDetectedCharset()); Charsets.add(encodingList, creationEncoding); final List<EncodingItem> encodingItemList = new ArrayList<EncodingItem>(); for (final String encoding : encodingList) { EncodingItem i = new EncodingItem(); encodingItemList.add(i); i.encoding = encoding; List<String> noteList = new ArrayList<String>() { { add(Charsets.equals(encoding, doc.getContentCharset()), "Content"); add(Charsets.equals(encoding, doc.getContentTypeEncoding()), "Content Type"); add(Charsets.equals(encoding, doc.getInheritedEncoding()), "Inheritance"); add(Charsets.equals(encoding, doc.getDetectedCharset()), "Autodetect"); add(Charsets.equals(encoding, creationEncoding), "Creation"); } public void add(boolean enable, String text) { if (enable) { super.add(text); } } }; i.menuText = formatLabel(i.encoding, noteList); } return encodingItemList; }
Example #2
Source File: EditSdkToolPage.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initializeControls() { textSdkToolName.setText(editedTool.getToolName()); textSdkToolLocation.setText(editedTool.getLocation()); textMenuItem.setText(editedTool.getMenuItem()); textInactiveMenuItem.setText(editedTool.getInactiveMenuItem()); boolean isFileExtensionsEnabled = !StringUtils.isBlank(editedTool.getFileExtensions()); btnRunOnFiles.setSelection( isFileExtensionsEnabled ); if (isFileExtensionsEnabled) { textExtensions.setText(editedTool.getFileExtensions()); } textExtensions.setEnabled(isFileExtensionsEnabled); int idx = 0; switch (editedTool.getSourceRoot()) { case PRJ_FILE: idx = 2; break; case MAIN_MODULE: idx = 3; break; case ANY_TYPE_OWN_SETTINGS: idx = 1; break; default: break; } cboxAvailability.select(idx); handleAvailabilitySelection(); for (ToolTab t : tabs) { t.initializeControls(); } // Encoding selector: List encodings = IDEEncoding.getIDEEncodings(); addEncIfNeed(encodings, "Cp1251"); //$NON-NLS-1$ addEncIfNeed(encodings, "Cp866"); //$NON-NLS-1$ String curEnc = editedTool.getPropertyValue(SdkTool.Property.CONSOLE_CODEPAGE); if (!TextEncoding.isCodepageSupported(curEnc)) { curEnc = WorkbenchEncoding.getWorkbenchDefaultEncoding(); } String[] encodingStrings = new String[encodings.size()]; encodings.toArray(encodingStrings); cboxEncoding.setItems(encodingStrings); cboxEncoding.setText(curEnc); }
Example #3
Source File: SourceAttachmentBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * @param context listeners for status updates * @param entry The entry to edit * @param canEditEncoding whether the source attachment encoding can be edited */ public SourceAttachmentBlock(IStatusChangeListener context, IClasspathEntry entry, boolean canEditEncoding) { Assert.isNotNull(entry); fContext= context; fEntry= entry; fCanEditEncoding= canEditEncoding; try { String defaultEncoding = ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset(); fDefaultEncodingName= Messages.format(NewWizardMessages.SourceAttachmentBlock_encoding_default, defaultEncoding); } catch (CoreException e) { //do nothing } int kind= entry.getEntryKind(); Assert.isTrue(kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE); fWorkspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); fWorkspaceNameStatus= new StatusInfo(); fExternalNameStatus= new StatusInfo(); fVariableNameStatus= new StatusInfo(); SourceAttachmentAdapter adapter= new SourceAttachmentAdapter(); // create the dialog fields (no widgets yet) if (isVariableEntry()) { fVariableFileNameField= new VariablePathDialogField(adapter); fVariableFileNameField.setDialogFieldListener(adapter); fVariableFileNameField.setLabelText(NewWizardMessages.SourceAttachmentBlock_filename_varlabel); fVariableFileNameField.setButtonLabel(NewWizardMessages.SourceAttachmentBlock_filename_external_varbutton); ((VariablePathDialogField) fVariableFileNameField).setVariableButtonLabel(NewWizardMessages.SourceAttachmentBlock_filename_variable_button); } else { fWorkspaceRadio= new SelectionButtonDialogField(SWT.RADIO); fWorkspaceRadio.setDialogFieldListener(adapter); fWorkspaceRadio.setLabelText(NewWizardMessages.SourceAttachmentBlock_workspace_radiolabel); fWorkspaceFileNameField= new StringButtonDialogField(adapter); fWorkspaceFileNameField.setDialogFieldListener(adapter); fWorkspaceFileNameField.setLabelText(NewWizardMessages.SourceAttachmentBlock_filename_workspace_label); fWorkspaceFileNameField.setButtonLabel(NewWizardMessages.SourceAttachmentBlock_filename_workspace_browse); fExternalRadio= new SelectionButtonDialogField(SWT.RADIO); fExternalRadio.setDialogFieldListener(adapter); fExternalRadio.setLabelText(NewWizardMessages.SourceAttachmentBlock_external_radiolabel); fExternalFileNameField= new StringButtonDialogField(adapter); fExternalFileNameField.setDialogFieldListener(adapter); fExternalFileNameField.setLabelText(NewWizardMessages.SourceAttachmentBlock_filename_external_label); fExternalFileNameField.setButtonLabel(NewWizardMessages.SourceAttachmentBlock_filename_externalfile_button); fExternalFolderButton= new SelectionButtonDialogField(SWT.PUSH); fExternalFolderButton.setDialogFieldListener(adapter); fExternalFolderButton.setLabelText(NewWizardMessages.SourceAttachmentBlock_filename_externalfolder_button); } fEncodingCombo= new ComboDialogField(SWT.DROP_DOWN); fEncodingCombo.setDialogFieldListener(adapter); fEncodingCombo.setLabelText(NewWizardMessages.SourceAttachmentBlock_encoding_label); List<String> encodings= IDEEncoding.getIDEEncodings(); String[] encodingsArray= encodings.toArray(new String[encodings.size() + 1]); System.arraycopy(encodingsArray, 0, encodingsArray, 1, encodingsArray.length - 1); encodingsArray[0]= fDefaultEncodingName; fEncodingCombo.setItems(encodingsArray); // set the old settings setDefaults(); }