Search in sources :

Example 56 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class GlobalCMDocumentCacheTest method setGlobalCacheEnabled.

private void setGlobalCacheEnabled(boolean value) {
    Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences();
    pluginPreferences.setDefault(XMLCorePreferenceNames.CMDOCUMENT_GLOBAL_CACHE_ENABLED, value);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 57 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class NewXSLFileWizard method performFinish.

@Override
public boolean performFinish() {
    boolean performedOK = false;
    // save user options for next use
    fNewFileTemplatesPage.saveLastSavedPreferences();
    // no file extension specified so add default extension
    String fileName = fNewFilePage.getFileName();
    if (fileName.lastIndexOf('.') == -1) {
        String newFileName = fNewFilePage.addDefaultExtension(fileName);
        fNewFilePage.setFileName(newFileName);
    }
    // create a new empty file
    IFile file = fNewFilePage.createNewFile();
    int[] offset = new int[1];
    // sure to check
    if (file != null) {
        // put template contents into file
        String templateString = fNewFileTemplatesPage.getTemplateString(offset);
        if (templateString != null) {
            // determine the encoding for the new file
            Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
            String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
            try {
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                OutputStreamWriter outputStreamWriter = null;
                if (charSet == null || charSet.trim().equals("")) {
                    // $NON-NLS-1$
                    // just use default encoding
                    outputStreamWriter = new OutputStreamWriter(outputStream);
                } else {
                    outputStreamWriter = new OutputStreamWriter(outputStream, charSet);
                }
                outputStreamWriter.write(templateString);
                outputStreamWriter.flush();
                outputStreamWriter.close();
                ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
                file.setContents(inputStream, true, false, null);
                inputStream.close();
            } catch (Exception e) {
                XSLUIPlugin.log(e);
            }
        }
        // open the file in editor
        openEditor(file, offset[0]);
        // everything's fine
        performedOK = true;
    }
    return performedOK;
}
Also used : IFile(org.eclipse.core.resources.IFile) ByteArrayInputStream(java.io.ByteArrayInputStream) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Preferences(org.eclipse.core.runtime.Preferences) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

Example 58 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class AutoEditStrategyForTabs method getIndentationWidth.

/**
 * Returns indentation width if using spaces for indentation, -1 otherwise
 *
 * @return int
 */
private int getIndentationWidth() {
    int width = -1;
    Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
    if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) {
        width = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
    }
    return width;
}
Also used : Preferences(org.eclipse.core.runtime.Preferences)

Example 59 with Preferences

use of org.eclipse.core.runtime.Preferences in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfigurationXML method getIndentPrefixes.

public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
    Vector vector = new Vector();
    // prefix[0] is either '\t' or ' ' x tabWidth, depending on preference
    Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
    int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
    String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
    boolean useSpaces = XMLCorePreferenceNames.SPACE.equals(indentCharPref);
    for (int i = 0; i <= indentationWidth; i++) {
        StringBuffer prefix = new StringBuffer();
        boolean appendTab = false;
        if (useSpaces) {
            for (int j = 0; j + i < indentationWidth; j++) {
                prefix.append(' ');
            }
            if (i != 0) {
                appendTab = true;
            }
        } else {
            for (int j = 0; j < i; j++) {
                prefix.append(' ');
            }
            if (i != indentationWidth) {
                appendTab = true;
            }
        }
        if (appendTab) {
            prefix.append('\t');
            vector.add(prefix.toString());
            // remove the tab so that indentation - tab is also an indent
            // prefix
            prefix.deleteCharAt(prefix.length() - 1);
        }
        vector.add(prefix.toString());
    }
    // $NON-NLS-1$
    vector.add("");
    return (String[]) vector.toArray(new String[vector.size()]);
}
Also used : Preferences(org.eclipse.core.runtime.Preferences) Vector(java.util.Vector)

Example 60 with Preferences

use of org.eclipse.core.runtime.Preferences in project translationstudio8 by heartsome.

the class NewFolderDialogOfHs method createAdvancedControls.

/**
		 * Creates the widget for advanced options.
		 *  
		 * @param parent the parent composite
		 */
protected void createAdvancedControls(Composite parent) {
    Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
    if (preferences.getBoolean(ResourcesPlugin.PREF_DISABLE_LINKING) == false && isValidContainer()) {
        linkedResourceParent = new Composite(parent, SWT.NONE);
        linkedResourceParent.setFont(parent.getFont());
        linkedResourceParent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        GridLayout layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        linkedResourceParent.setLayout(layout);
        advancedButton = new Button(linkedResourceParent, SWT.PUSH);
        advancedButton.setFont(linkedResourceParent.getFont());
        advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
        setButtonLayoutData(advancedButton);
        GridData data = (GridData) advancedButton.getLayoutData();
        data.horizontalAlignment = GridData.BEGINNING;
        advancedButton.setLayoutData(data);
        advancedButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                handleAdvancedButtonSelect();
            }
        });
    }
    linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER, new Listener() {

        public void handleEvent(Event e) {
            validateLinkedResource();
            firstLinkCheck = false;
        }
    }, new CreateLinkedResourceGroup.IStringValue() {

        public void setValue(String string) {
            folderNameField.setText(string);
        }

        public String getValue() {
            return folderNameField.getText();
        }

        public IResource getResource() {
            return container;
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CreateLinkedResourceGroup(org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Preferences(org.eclipse.core.runtime.Preferences)

Aggregations

Preferences (org.eclipse.core.runtime.Preferences)113 ByteArrayInputStream (java.io.ByteArrayInputStream)7 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)7 IFile (org.eclipse.core.resources.IFile)6 PartInitException (org.eclipse.ui.PartInitException)6 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)6 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStreamWriter (java.io.OutputStreamWriter)5 IStructuredFormatPreferences (org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)4 IStructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences)4 StructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)4 List (java.util.List)3 Vector (java.util.Vector)3 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)3 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2