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);
}
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;
}
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;
}
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()]);
}
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;
}
});
}
Aggregations