org.eclipse.xtext.ui.editor.preferences.PreferenceConstants Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.preferences.PreferenceConstants. 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: XtextBuildPreferenceEvaluator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean hasBuildAffectingChanges(Entry<String, ValueDifference<String>> preference) {
	String key = preference.getKey();
	if (key.startsWith(PREFIX)) {
		String keyName = key.substring(key.lastIndexOf(PreferenceConstants.SEPARATOR) + 1);
		switch (keyName) {
			case OUTPUT_CREATE_DIRECTORY:
			case OUTPUT_OVERRIDE:
			case OUTPUT_DERIVED:
			case OUTPUT_CLEANUP_DERIVED:
			case OUTPUT_CLEAN_DIRECTORY:
			case OUTPUT_KEEP_LOCAL_HISTORY:
				return false;
		}
	}
	return true;
}
 
Example #2
Source File: SARLPreferenceStoreInitializer.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(IPreferenceStoreAccess preferenceStoreAccess) {
	this.preferenceStoreAccess = preferenceStoreAccess;

	// Initialize the default visibilities for the optional issue codes.
	setupIssueCodesDefaults(preferenceStoreAccess);

	final IPreferenceStore preferenceStore = org.eclipse.jdt.ui.PreferenceConstants.getPreferenceStore();
	preferenceStore.addPropertyChangeListener(this);

	// Copy the Subword navigation from the JDT plugin.
	preferenceStoreAccess.getWritablePreferenceStore().setDefault(
			PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION,
			preferenceStore.getBoolean(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));

	// Initialize the editor preferences
	setupSourceViewerDefaults(preferenceStoreAccess);
	setupCodeminingDefaults(preferenceStoreAccess);

	// Initialize the generators for the extra languages.
	setupExtraLanguageGeneratorDefaults(preferenceStoreAccess);
}
 
Example #3
Source File: SARLPreferenceStoreInitializer.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
	if (this.preferenceStoreAccess == null) {
		return;
	}
	// Copy the Subword navigation from the JDT plugin.
	if (org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION.equalsIgnoreCase(event.getProperty())) {
		this.preferenceStoreAccess.getWritablePreferenceStore().setValue(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION,
				Boolean.valueOf(event.getNewValue().toString()));
	}

}
 
Example #4
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run() {
	// Check whether we are in a java code partition and the preference is enabled
	final IPreferenceStore store= getPreferenceStore();
	if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) {
		super.run();
		return;
	}

	final ISourceViewer viewer = getSourceViewer();
	final IDocument document = viewer.getDocument();
	try {
		fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
		int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
		if (position == -1)
			return;

		int next = findNextPosition(position);
		if (isBlockSelectionModeEnabled()
				&& document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
			super.run(); // may navigate into virtual white space
		} else if (next != BreakIterator.DONE) {
			setCaretPosition(next);
			getTextWidget().showSelection();
			fireSelectionChanged();
		}
	} catch (BadLocationException x) {
		// ignore
	}
}
 
Example #5
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run() {
	// Check whether we are in a java code partition and the preference is enabled
	final IPreferenceStore store= getPreferenceStore();
	if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) {
		super.run();
		return;
	}

	final ISourceViewer viewer = getSourceViewer();
	final IDocument document = viewer.getDocument();
	try {
		fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
		int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
		if (position == -1)
			return;

		int previous = findPreviousPosition(position);
		if (isBlockSelectionModeEnabled()
				&& document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
			super.run(); // may navigate into virtual white space
		} else if (previous != BreakIterator.DONE) {
			setCaretPosition(previous);
			getTextWidget().showSelection();
			fireSelectionChanged();
		}
	} catch (BadLocationException x) {
		// ignore - getLineOfOffset failed
	}

}
 
Example #6
Source File: AbstractDetailsPart.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected final void addField(FieldEditor editor) {
	String prefix = null;
	if (getPreferencePrefix() != null)
		prefix = getPreferencePrefix() + PreferenceConstants.SEPARATOR + editor.getPreferenceName();
	else
		prefix = editor.getPreferenceName();
	editor.setPreferenceName(prefix);
	internalEditorsList.add(editor);
	super.addField(editor);
}
 
Example #7
Source File: AbstractDetailsPart.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void setPreferencePrefix(String preferencePrefix) {
	this.preferencePrefix = preferencePrefix;
	for (FieldEditor fe : internalEditorsList) {
		String oldPreferenceName = fe.getPreferenceName();
		if (oldPreferenceName.indexOf(PreferenceConstants.SEPARATOR) >= 0) {
			oldPreferenceName = oldPreferenceName.substring(oldPreferenceName
					.lastIndexOf(PreferenceConstants.SEPARATOR) + 1);
		}
		fe.setPreferenceName(getPreferencePrefix() + PreferenceConstants.SEPARATOR + oldPreferenceName);
	}
}
 
Example #8
Source File: XtendPreferenceStoreInitializer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
	if (preferenceStoreAccess == null) {
		return;
	}
	if (org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION.equalsIgnoreCase(event.getProperty())) {
		preferenceStoreAccess.getWritablePreferenceStore().setValue(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION,
				Boolean.valueOf(event.getNewValue().toString()));
	}
}
 
Example #9
Source File: XtendPreferenceStoreInitializer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void initialize(IPreferenceStoreAccess preferenceStoreAccess) {
	this.preferenceStoreAccess = preferenceStoreAccess;

	IPreferenceStore preferenceStore = org.eclipse.jdt.ui.PreferenceConstants.getPreferenceStore();
	preferenceStore.addPropertyChangeListener(this);
	preferenceStoreAccess.getWritablePreferenceStore().setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION,
			preferenceStore.getBoolean(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
	
}
 
Example #10
Source File: KeepLocalHistoryTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public String getKey(final String preferenceName) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(EclipseOutputConfigurationProvider.OUTPUT_PREFERENCE_TAG);
  _builder.append(PreferenceConstants.SEPARATOR);
  _builder.append(IFileSystemAccess.DEFAULT_OUTPUT);
  _builder.append(PreferenceConstants.SEPARATOR);
  _builder.append(preferenceName);
  return _builder.toString();
}
 
Example #11
Source File: AbstractBuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected String getUseOutputPerSourceFolderKey() {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + IFileSystemAccess.DEFAULT_OUTPUT
			+ PreferenceConstants.SEPARATOR + USE_OUTPUT_PER_SOURCE_FOLDER;
}
 
Example #12
Source File: BuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static String getIgnoreSourceFolderKey(OutputConfiguration outputConfiguration, String sourceFolder) {
	return getKey(outputConfiguration, SOURCE_FOLDER_TAG + PreferenceConstants.SEPARATOR + sourceFolder + PreferenceConstants.SEPARATOR + IGNORE_SOURCE_FOLDER_TAG);
}
 
Example #13
Source File: BuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static String getOutputForSourceFolderKey(OutputConfiguration outputConfiguration, String sourceFolder) {
	return getKey(outputConfiguration, SOURCE_FOLDER_TAG + PreferenceConstants.SEPARATOR + sourceFolder + PreferenceConstants.SEPARATOR + OUTPUT_DIRECTORY);
}
 
Example #14
Source File: BuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static String getKey(OutputConfiguration outputConfiguration, String preferenceName) {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + outputConfiguration.getName()
			+ PreferenceConstants.SEPARATOR + preferenceName;
}
 
Example #15
Source File: EclipseOutputConfigurationProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private boolean isIgnoreSourceFolder(IPreferenceStore store ,OutputConfiguration outputConfiguration, String sourceFolder) {
	String key = getKey(outputConfiguration, SOURCE_FOLDER_TAG + PreferenceConstants.SEPARATOR + sourceFolder + PreferenceConstants.SEPARATOR + IGNORE_SOURCE_FOLDER_TAG);
	return store.contains(key)? store.getBoolean(key): false;
}
 
Example #16
Source File: EclipseOutputConfigurationProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private String getOutputForSourceFolder(IPreferenceStore store ,OutputConfiguration outputConfiguration, String sourceFolder) {
	String key = getKey(outputConfiguration, SOURCE_FOLDER_TAG + PreferenceConstants.SEPARATOR + sourceFolder + PreferenceConstants.SEPARATOR + OUTPUT_DIRECTORY);
	return Strings.emptyToNull(store.getString(key));
}
 
Example #17
Source File: EclipseOutputConfigurationProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private String getKey(OutputConfiguration outputConfiguration, String preferenceName) {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + outputConfiguration.getName()
			+ PreferenceConstants.SEPARATOR + preferenceName;
}
 
Example #18
Source File: AbstractMasterDetailsFieldEditor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private String calculateClientPreferencePrefix(Object object) {
	return getPreferenceName() + PreferenceConstants.SEPARATOR + identifier(object);
}
 
Example #19
Source File: SmartCaretPreferenceInitializer.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize(IPreferenceStoreAccess access) {
	access.getWritablePreferenceStore().setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true);
}
 
Example #20
Source File: AbstractBuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected String getDefaultOutputDirectoryKey() {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + IFileSystemAccess.DEFAULT_OUTPUT
			+ PreferenceConstants.SEPARATOR + OUTPUT_DIRECTORY;
}
 
Example #21
Source File: ExtraLanguagePreferenceAccess.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Create a preference key according to the Xtext option block standards.
 *
 * @param preferenceContainerID the identifier of the generator's preference container.
 * @param preferenceName the name of the preference.
 * @return the key.
 */
private static String getXtextKey(String preferenceContainerID, String preferenceName) {
	return GENERATOR_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + preferenceContainerID
			+ PreferenceConstants.SEPARATOR + preferenceName;
}