org.eclipse.jdt.ui.PreferenceConstants Java Examples

The following examples show how to use org.eclipse.jdt.ui.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: JavaNavigatorContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void init(ICommonContentExtensionSite commonContentExtensionSite) {
	IExtensionStateModel stateModel = commonContentExtensionSite
			.getExtensionStateModel();
	IMemento memento = commonContentExtensionSite.getMemento();

	fStateModel = stateModel;
	restoreState(memento);
	fLayoutPropertyListener = new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			if (Values.IS_LAYOUT_FLAT.equals(event.getProperty())) {
				if (event.getNewValue() != null) {
					boolean newValue = ((Boolean) event.getNewValue())
							.booleanValue() ? true : false;
					setIsFlatLayout(newValue);
				}
			}

		}
	};
	fStateModel.addPropertyChangeListener(fLayoutPropertyListener);

	IPreferenceStore store = PreferenceConstants.getPreferenceStore();
	boolean showCUChildren = store
			.getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
	setProvideMembers(showCUChildren);
}
 
Example #2
Source File: QuickAssistLightBulbUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void doPropertyChanged(String property) {
	if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) {
		if (isSetInPreferences()) {
			ICompilationUnit cu= getCompilationUnit();
			if (cu != null) {
				installSelectionListener();
				Point point= fViewer.getSelectedRange();
				CompilationUnit astRoot= SharedASTProvider.getAST(cu, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
				if (astRoot != null) {
					doSelectionChanged(point.x, point.y, astRoot);
				}
			}
		} else {
			uninstallSelectionListener();
		}
	}
}
 
Example #3
Source File: PropertyValueScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected List<IRule> createRules() {
	setDefaultReturnToken(getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_VALUE));
	List<IRule> rules= new ArrayList<IRule>();

	// Add rule for arguments.
	IToken token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ARGUMENT);
	rules.add(new ArgumentRule(token));

	// Add word rule for assignment operator.
	token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ASSIGNMENT);
	WordRule wordRule= new WordRule(new AssignmentDetector(), token);
	rules.add(wordRule);

	// Add generic whitespace rule.
	rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));

	return rules;
}
 
Example #4
Source File: JavaTemplatesPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected SourceViewer createPatternViewer(Composite parent) {
	IDocument document= new Document();
	JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
	tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
	SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
	viewer.configure(configuration);
	viewer.setEditable(false);
	viewer.setDocument(document);

	Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
	viewer.getTextWidget().setFont(font);
	new JavaSourcePreviewerUpdater(viewer, configuration, store);

	Control control= viewer.getControl();
	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
	control.setLayoutData(data);

	viewer.setEditable(false);
	return viewer;
}
 
Example #5
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void putDefaultClasspathEntriesIn(Collection<IClasspathEntry> classpathEntries) {
	final IPath newPath = this.jreGroup.getJREContainerPath();
	if (newPath != null) {
		classpathEntries.add(JavaCore.newContainerEntry(newPath));
	} else {
		final IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
		classpathEntries.addAll(Arrays.asList(entries));
	}

	final IClasspathEntry sarlClasspathEntry = JavaCore.newContainerEntry(
			SARLClasspathContainerInitializer.CONTAINER_ID,
			new IAccessRule[0],
			new IClasspathAttribute[0],
			true);
	classpathEntries.add(sarlClasspathEntry);
}
 
Example #6
Source File: CallHierarchyContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the default "expand with constructors" mode for the method wrapper. Does nothing if the
 * mode has already been set.
 * 
 * 
 * @param wrapper the caller method wrapper
 * @since 3.5
 */
static void ensureDefaultExpandWithConstructors(CallerMethodWrapper wrapper) {

	if (!wrapper.isExpandWithConstructorsSet()) {
		if (CallHierarchyContentProvider.canExpandWithConstructors(wrapper)) {
			IMethod method= (IMethod)wrapper.getMember();
			IType type= method.getDeclaringType();
			try {
				boolean withConstructors= false;
				if (type != null) {
					boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
					if (anonymousPref && type.isAnonymous()) {
						withConstructors= true;
					} else if (isInTheDefaultExpandWithConstructorList(method)) {
						withConstructors= true;
					}
				}
				wrapper.setExpandWithConstructors(withConstructors);
			} catch (JavaModelException e) {
				// ignore: expand mode will be off
			}
		}
	}

}
 
Example #7
Source File: JavaTemplatePreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected SourceViewer createViewer(Composite parent) {
	IDocument document= new Document();
	JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
	tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
	SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
	viewer.configure(configuration);
	viewer.setEditable(false);
	viewer.setDocument(document);

	Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
	viewer.getTextWidget().setFont(font);
	new JavaSourcePreviewerUpdater(viewer, configuration, store);

	Control control= viewer.getControl();
	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
	control.setLayoutData(data);

	return viewer;
}
 
Example #8
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (fViewer == null)
		return;

	boolean refreshViewer= false;

	if (PreferenceConstants.SHOW_CU_CHILDREN.equals(event.getProperty())) {
		boolean showCUChildren= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
		((StandardJavaElementContentProvider)fViewer.getContentProvider()).setProvideMembers(showCUChildren);

		refreshViewer= true;
	} else if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
		refreshViewer= true;
	}

	if (refreshViewer)
		fViewer.refresh();
}
 
Example #9
Source File: SourceViewerInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void initializeColors() {
	IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
	RGB bgRGB;
	if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
		bgRGB= getVisibleBackgroundColor(fShell.getDisplay());
	} else {
		bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
	}
	if (bgRGB != null) {
		fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
		fIsSystemBackgroundColor= false;
	} else {
		fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
		fIsSystemBackgroundColor= true;
	}
}
 
Example #10
Source File: FoldingConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void restoreFromPreferences() {
	boolean enabled= fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
	fFoldingCheckbox.setSelection(enabled);
	updateCheckboxDependencies();

	String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
	Object provider= fProviderDescriptors.get(id);

	// Fallback to default
	if (provider == null) {
		String message= Messages.format(PreferencesMessages.FoldingConfigurationBlock_warning_providerNotFound_resetToDefault, id);
		JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null));

		id= JavaPlugin.getDefault().getPreferenceStore().getDefaultString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);

		provider= fProviderDescriptors.get(id);
		Assert.isNotNull(provider);

		fStore.setToDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
	}

	if (fProviderViewer == null)
		updateListDependencies();
	else
		fProviderViewer.setSelection(new StructuredSelection(provider), true);
}
 
Example #11
Source File: InputPageUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a signature preview viewer in a parent composite with a 1-column GridLayout.
 * 
 * @param parent the parent 
 * @return the preview viewer
 * @since 3.9
 */
public static JavaSourceViewer createSignaturePreview(Composite parent) {
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	JavaSourceViewer signaturePreview= new JavaSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP, store);
	signaturePreview.configure(new JavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
	StyledText textWidget= signaturePreview.getTextWidget();
	textWidget.setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
	textWidget.setAlwaysShowScrollBars(false);
	signaturePreview.adaptBackgroundColor(parent);
	signaturePreview.setDocument(new Document());
	signaturePreview.setEditable(false);

	GridData gdata= new GridData(GridData.FILL_BOTH);
	gdata.widthHint= new PixelConverter(textWidget).convertWidthInCharsToPixels(50);
	gdata.heightHint= textWidget.getLineHeight() * 2;
	textWidget.setLayoutData(gdata);
	
	return signaturePreview;
}
 
Example #12
Source File: SpellCheckEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public final void propertyChange(final PropertyChangeEvent event) {
	if (event.getProperty().equals(PreferenceConstants.SPELLING_LOCALE)) {
		resetSpellChecker();
		return;
	}

	if (event.getProperty().equals(PreferenceConstants.SPELLING_USER_DICTIONARY)) {
		resetUserDictionary();
		return;
	}

	if (event.getProperty().equals(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING)) {
		resetUserDictionary();
		return;
	}

	if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED) && !EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		if (this == fgEngine)
			SpellCheckEngine.shutdownInstance();
		else
			shutdown();
	}
}
 
Example #13
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static void initializeHighlightRange(IEditorPart editorPart) {
	if (editorPart instanceof ITextEditor) {
		IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
		boolean enable= toggleAction != null;
		if (enable && editorPart instanceof JavaEditor)
			enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
		else
			enable= enable && toggleAction.isEnabled() && toggleAction.isChecked();
		if (enable) {
			if (toggleAction instanceof TextEditorAction) {
				// Reset the action
				((TextEditorAction)toggleAction).setEditor(null);
				// Restore the action
				((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart);
			} else {
				// Uncheck
				toggleAction.run();
				// Check
				toggleAction.run();
			}
		}
	}
}
 
Example #14
Source File: TypeFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private synchronized StringMatcher[] getStringMatchers() {
	if (fStringMatchers == null) {
		String str= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.TYPEFILTER_ENABLED);
		StringTokenizer tok= new StringTokenizer(str, ";"); //$NON-NLS-1$
		int nTokens= tok.countTokens();

		fStringMatchers= new StringMatcher[nTokens];
		for (int i= 0; i < nTokens; i++) {
			String curr= tok.nextToken();
			if (curr.length() > 0) {
				fStringMatchers[i]= new StringMatcher(curr, false, false);
			}
		}
	}
	return fStringMatchers;
}
 
Example #15
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method should only be called inside this class
 * and from test cases.
 * @return the created content provider
 */
public PackageExplorerContentProvider createContentProvider() {
	IPreferenceStore store= PreferenceConstants.getPreferenceStore();
	boolean showCUChildren= store.getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
	if (getRootMode() == PROJECTS_AS_ROOTS)
		return new PackageExplorerContentProvider(showCUChildren);
	else
		return new WorkingSetAwareContentProvider(showCUChildren, fWorkingSetModel);
}
 
Example #16
Source File: EditFilterAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IPath getOutputLocation(IJavaProject javaProject) {
	try {
		return javaProject.getOutputLocation();
	} catch (CoreException e) {
		IProject project= javaProject.getProject();
		IPath projPath= project.getFullPath();
		return projPath.append(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
	}
}
 
Example #17
Source File: SmartTypingConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addStringsSection(Composite composite) {
	GridLayout layout= new GridLayout();
	composite.setLayout(layout);

	String label;
	label= PreferencesMessages.JavaEditorPreferencePage_wrapStrings;
	addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);

	label= PreferencesMessages.JavaEditorPreferencePage_escapeStrings;
	addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
}
 
Example #18
Source File: JavaPreferencesSettings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static CodeGenerationSettings getCodeGenerationSettings(IJavaProject project) {
	CodeGenerationSettings res= new CodeGenerationSettings();
	res.createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, project)).booleanValue();
	res.useKeywordThis= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_KEYWORD_THIS, project)).booleanValue();
	res.overrideAnnotation= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION, project)).booleanValue();
	res.importIgnoreLowercase= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, project)).booleanValue();
	res.tabWidth= CodeFormatterUtil.getTabWidth(project);
	res.indentWidth= CodeFormatterUtil.getIndentWidth(project);
	return res;
}
 
Example #19
Source File: JavaPackageCompletionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
    * Creates a <code>JavaPackageCompletionProcessor</code>.
    * The Processor uses the given <code>ILabelProvider</code> to show text and icons for the
    * possible completions.
    * @param labelProvider Used for the popups.
    */
public JavaPackageCompletionProcessor(ILabelProvider labelProvider) {
	fComparator= new CompletionProposalComparator();
	fLabelProvider= labelProvider;

	IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
	String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
	fProposalAutoActivationSet = triggers.toCharArray();
}
 
Example #20
Source File: DefaultJavaFoldingPreferenceBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private OverlayKey[] createKeys() {
	ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();

	overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_JAVADOC));
	overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_INNERTYPES));
	overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_METHODS));
	overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_IMPORTS));
	overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_HEADERS));

	return overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
}
 
Example #21
Source File: CreateLinkedSourceFolderAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IPath getOutputLocation(IJavaProject javaProject) {
  	try {
	return javaProject.getOutputLocation();
} catch (CoreException e) {
	IProject project= javaProject.getProject();
	IPath projPath= project.getFullPath();
	return projPath.append(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
}
  }
 
Example #22
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public LayoutGroup() {
	fStdRadio= new SelectionButtonDialogField(SWT.RADIO);
	fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder);

	fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO);
	fSrcBinRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_separateFolders);

	boolean useSrcBin= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ);
	fSrcBinRadio.setSelection(useSrcBin);
	fStdRadio.setSelection(!useSrcBin);
}
 
Example #23
Source File: SelfEncapsulateFieldInputPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String[] getRelevantOptions(IJavaProject project) {
	return new String[] {
		project.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES, true),
		project.getOption(JavaCore.CODEASSIST_FIELD_SUFFIXES, true),
		PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_IS_FOR_GETTERS, project)
	};
}
 
Example #24
Source File: JavaEditorAppearanceConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initializes the default colors.
 *
 * @since 3.3
 */
private void initializeDefaultColors() {
	if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
		Display display= fAppearanceColorList.getDisplay();
		RGB rgb= SourceViewerInformationControl.getVisibleBackgroundColor(display);
		if (rgb == null)
			rgb= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
		PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
	}
}
 
Example #25
Source File: PullUpMethodPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createSourceViewer(final Composite c) {
	final IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	fSourceViewer= new JavaSourceViewer(c, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store);
	fSourceViewer.configure(new JavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
	fSourceViewer.setEditable(false);
	fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
	fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
}
 
Example #26
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
	public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
		clear();

		if (!canEvaluate(template))
			throw new TemplateException(JavaTemplateMessages.Context_error_cannot_evaluate);

		TemplateTranslator translator= new TemplateTranslator() {
			@Override
			protected TemplateVariable createVariable(TemplateVariableType type, String name, int[] offsets) {
//				TemplateVariableResolver resolver= getContextType().getResolver(type.getName());
//				return resolver.createVariable();

				MultiVariable variable= new JavaVariable(type, name, offsets);
				fVariables.put(name, variable);
				return variable;
			}
		};
		TemplateBuffer buffer= translator.translate(template);

		getContextType().resolve(buffer, this);

		rewriteImports();

		IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore();
		boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);

		IJavaProject project= getJavaProject();
		JavaFormatter formatter= new JavaFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentation(), useCodeFormatter, project);
		formatter.format(buffer, this);

		clear();

		return buffer;
	}
 
Example #27
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Runs the action.
 */
@Override
public void run() {
	final boolean isChecked= isChecked();
	PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, isChecked);
	if (isChecked && fEditor != null)
		fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
	fOpenAndLinkWithEditorHelper.setLinkWithEditor(isChecked);
}
 
Example #28
Source File: MockJavaProjectProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void setUp() throws Exception {
	if(javaProject != null)
		return;
	TargetPlatformUtil.setTargetPlatform(MockJavaProjectProvider.class);
	javaProject = createJavaProject("projectWithoutSources",
			new String[] {
					JavaCore.NATURE_ID,
					"org.eclipse.pde.PluginNature"
			}
	);
	String path = "/org/eclipse/xtext/common/types/testSetups";
	String jarFileName = "/testData.jar";
	IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), path + jarFileName, javaProject.getProject(), 
			jarFileName);
	JavaProjectSetupUtil.addJarToClasspath(javaProject, jarFile);
	
	javaProjectWithSources = createJavaProject("projectWithSources",
			new String[] {
					JavaCore.NATURE_ID,
					"org.eclipse.pde.PluginNature"
			}
	);
	IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(javaProjectWithSources, "src");
	
	List<String> filesToCopy = readResource(path + "/files.list");
	IFolder srcFolder = sourceFolder.getFolder(new Path(path));
	createFolderRecursively(srcFolder);
	for(String fileToCopy: filesToCopy) {
		List<String> content = readResource(path + "/" + fileToCopy);
		String contentAsString = Strings.concat("\n", content);
		createFile(fileToCopy.substring(0, fileToCopy.length() - ".txt".length()), srcFolder, contentAsString);
	}
	createFile("ClassWithDefaultPackage.java", sourceFolder, "public class ClassWithDefaultPackage {}");
	PreferenceConstants.getPreferenceStore().putValue(PreferenceConstants.TYPEFILTER_ENABLED, "*.javafx.*;");
	IResourcesSetupUtil.waitForBuild();
}
 
Example #29
Source File: MyPreferenceConstants.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the JDT-UI preference store.
 *
 * @return the JDT-UI preference store
 */
public static IPreferenceStore getPreferenceStore() {
	IPreferenceStore store = PreferenceConstants.getPreferenceStore();
	if (!initialized) {
		MyPreferenceConstants.initializeDefaultValues(store);
		initialized = true;
	}
	return store;
}
 
Example #30
Source File: CreateSourceFolderAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IPath getOutputLocation(IJavaProject javaProject) {
  	try {
	return javaProject.getOutputLocation();
} catch (CoreException e) {
	IProject project= javaProject.getProject();
	IPath projPath= project.getFullPath();
	return projPath.append(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
}
  }