Search in sources :

Example 26 with DefaultScope

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

the class TaskTagPreferencePage method createCommonContents.

protected Control createCommonContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeLayout = new GridLayout();
    compositeLayout.marginLeft = 0;
    compositeLayout.marginRight = 0;
    composite.setLayout(compositeLayout);
    IScopeContext[] preferenceScopes = createPreferenceScopes();
    fOriginalEnableTaskTags = fEnableTaskTags = fPreferencesService.getBoolean(getPreferenceNodeQualifier(), TaskTagPreferenceKeys.TASK_TAG_ENABLE, false, preferenceScopes);
    fEnableCheckbox = new Button(composite, SWT.CHECK);
    fEnableCheckbox.setSelection(fEnableTaskTags);
    // $NON-NLS-1$
    fEnableCheckbox.setText(SSEUIMessages.TaskTagPreferenceTab_31);
    fEnableCheckbox.setSelection(fEnableTaskTags);
    fEnableCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_END, false, false, 1, 1));
    fTabFolder = new TabFolder(composite, SWT.NONE);
    fTabFolder.setLayout(new TabFolderLayout());
    fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    TabItem taskItem = new TabItem(fTabFolder, SWT.NONE);
    MainTab mainTab = new MainTab(this, fPreferencesService, preferenceScopes);
    taskItem.setText(mainTab.getTitle());
    final Control taskTagsControl = mainTab.createContents(fTabFolder);
    taskItem.setControl(taskTagsControl);
    TabItem exclusionItem = new TabItem(fTabFolder, SWT.NONE);
    ExclusionsTab exclusionsTab = new ExclusionsTab(this, fPreferencesService, preferenceScopes);
    exclusionItem.setText(exclusionsTab.getTitle());
    final Control exclusionControl = exclusionsTab.createContents(fTabFolder);
    exclusionItem.setControl(exclusionControl);
    fTabs = new IPreferenceTab[] { mainTab, exclusionsTab };
    fTabEnablementListener = new SelectionAdapter() {

        ControlEnableState[] lastEnableStates = null;

        public void widgetSelected(SelectionEvent e) {
            fEnableTaskTags = fEnableCheckbox.getSelection();
            if (fEnableTaskTags) {
                if (lastEnableStates != null) {
                    for (int i = 0; i < lastEnableStates.length; i++) {
                        if (lastEnableStates[i] != null) {
                            lastEnableStates[i].restore();
                        }
                    }
                    lastEnableStates = null;
                    fTabFolder.redraw();
                }
            } else if (lastEnableStates == null) {
                lastEnableStates = new ControlEnableState[fTabs.length + 1];
                lastEnableStates[0] = ControlEnableState.disable(taskTagsControl);
                lastEnableStates[1] = ControlEnableState.disable(exclusionControl);
                if (fRedetectButton != null) {
                    lastEnableStates[2] = ControlEnableState.disable(fRedetectButton);
                }
            }
        }
    };
    fTabEnablementListener.widgetSelected(null);
    fEnableCheckbox.addSelectionListener(fTabEnablementListener);
    // restore last selected tab
    int activeTab = new DefaultScope().getNode(getPreferenceNodeQualifier()).getInt(TASK_TAG_LAST_TAB, 0);
    if (activeTab > 0) {
        fTabFolder.setSelection(activeTab);
    }
    SSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PREFWEBX_TASKTAGS_HELPID);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) TabFolderLayout(org.eclipse.wst.sse.ui.internal.preferences.TabFolderLayout) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState)

Example 27 with DefaultScope

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

the class JSONValidatorPreferencePage method performDefaultsForSyntaxValidationGroup.

// protected void performDefaultsForValidatingGroup() {
// IEclipsePreferences modelPreferences = new DefaultScope()
// .getNode(getPreferenceNodeQualifier());
// boolean useXIncludeButtonSelected = modelPreferences.getBoolean(
// JSONCorePreferenceNames.USE_XINCLUDE, false);
// 
// if (fUseXinclude != null) {
// fUseXinclude.setSelection(useXIncludeButtonSelected);
// }
// boolean useHonourAllButtonSelected = modelPreferences.getBoolean(
// JSONCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true);
// if (fHonourAllSchemaLocations != null) {
// fHonourAllSchemaLocations.setSelection(useHonourAllButtonSelected);
// }
// }
protected void performDefaultsForSyntaxValidationGroup() {
    IEclipsePreferences modelPreferences = new DefaultScope().getNode(getPreferenceNodeQualifier());
    boolean useExtendedSyntaxValidation = modelPreferences.getBoolean(JSONCorePreferenceNames.SYNTAX_VALIDATION, false);
    boolean useSchemaValidation = modelPreferences.getBoolean(JSONCorePreferenceNames.SCHEMA_VALIDATION, false);
    if (fSchemaValidation != null) {
        fSchemaValidation.setSelection(useSchemaValidation);
    }
    if (fExtendedSyntaxValidation != null) {
        if (fExtendedSyntaxValidation.getSelection() != useExtendedSyntaxValidation) {
            handleSyntaxSeveritySelection(useExtendedSyntaxValidation);
        }
        fExtendedSyntaxValidation.setSelection(useExtendedSyntaxValidation);
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 28 with DefaultScope

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

the class DTDCorePreferenceInitializer method initializeDefaultPreferences.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
	 */
public void initializeDefaultPreferences() {
    IEclipsePreferences node = new DefaultScope().getNode(DTDCorePlugin.getInstance().getBundle().getSymbolicName());
    // this could be made smarter by actually looking up the content
    // type's valid extensions
    // $NON-NLS-1$
    node.put(DTDCorePreferenceNames.DEFAULT_EXTENSION, "dtd");
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 29 with DefaultScope

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

the class WorkspaceTaskScanner method init.

private boolean init(IResource resource) {
    IProject project = getProject(resource);
    IPreferencesService preferencesService = Platform.getPreferencesService();
    IScopeContext[] lookupOrder = new IScopeContext[] { new ProjectScope(project), new InstanceScope(), new DefaultScope() };
    boolean proceed = preferencesService.getBoolean(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_ENABLE, false, lookupOrder);
    if (Logger.DEBUG_TASKSPREFS) {
        // $NON-NLS-1$ //$NON-NLS-2$
        System.out.println(getClass().getName() + " scan of " + resource.getFullPath() + ":" + proceed);
    }
    if (proceed) {
        String[] tags = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_TAGS, null, lookupOrder));
        String[] priorities = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, null, lookupOrder));
        String[] currentIgnoreContentTypeIDs = StringUtils.unpack(preferencesService.getString(TaskTagPreferenceKeys.TASK_TAG_NODE, TaskTagPreferenceKeys.TASK_TAG_CONTENTTYPES_IGNORED, null, lookupOrder));
        if (Logger.DEBUG_TASKSPREFS) {
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " tags: ");
            for (int i = 0; i < tags.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(tags[i]);
            }
            System.out.println();
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " priorities: ");
            for (int i = 0; i < priorities.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(priorities[i]);
            }
            System.out.println();
            // $NON-NLS-1$
            System.out.print(getClass().getName() + " ignored content types: ");
            for (int i = 0; i < currentIgnoreContentTypeIDs.length; i++) {
                if (i > 0) {
                    // $NON-NLS-1$
                    System.out.print(",");
                }
                System.out.print(currentIgnoreContentTypeIDs[i]);
            }
            System.out.println();
        }
        fCurrentIgnoreContentTypes = new IContentType[currentIgnoreContentTypeIDs.length];
        IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
        for (int i = 0; i < currentIgnoreContentTypeIDs.length; i++) {
            fCurrentIgnoreContentTypes[i] = contentTypeManager.getContentType(currentIgnoreContentTypeIDs[i]);
        }
        int max = Math.min(tags.length, priorities.length);
        fCurrentTaskTags = new TaskTag[max];
        for (int i = 0; i < max; i++) {
            int priority = TaskTag.PRIORITY_NORMAL;
            try {
                priority = Integer.parseInt(priorities[i]);
            } catch (NumberFormatException e) {
            // default to normal priority
            }
            fCurrentTaskTags[i] = new TaskTag(tags[i], priority);
        }
    }
    return proceed;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) IProject(org.eclipse.core.resources.IProject) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager)

Example 30 with DefaultScope

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

the class JSPValidationPreferencePage method performDefaults.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
	 */
protected void performDefaults() {
    resetSeverities();
    IEclipsePreferences defaultContext = new DefaultScope().getNode(getPreferenceNodeQualifier());
    boolean validateFragments = defaultContext.getBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
    fValidateFragments.setSelection(validateFragments);
    super.performDefaults();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Aggregations

DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)44 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)24 ProjectScope (org.eclipse.core.resources.ProjectScope)17 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)7 IResource (org.eclipse.core.resources.IResource)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 IFile (org.eclipse.core.resources.IFile)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 IOException (java.io.IOException)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)2 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2