Java 类org.eclipse.ui.ide.IDEEncoding 实例源码

项目:PDFReporter-Studio    文件:CEncodingFieldEditor.java   
protected void doStore() {
    String encoding = getSelectedEncoding();

    if (hasSameEncoding(encoding)) {
        return;
    }

    IDEEncoding.addIDEEncoding(encoding);

    if (encoding.equals(getDefaultEnc())) {
        getPreferenceStore().setToDefault(getPreferenceName());
    } else {
        getPreferenceStore().setValue(getPreferenceName(), encoding);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceAttachmentBlock.java   
/**
 * @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();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceAttachmentBlock.java   
/**
 * @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();
}