Search in sources :

Example 6 with IPersistentPreferenceStore

use of org.eclipse.jface.preference.IPersistentPreferenceStore in project xtext-xtend by eclipse.

the class XtendUIValidationTests method testConfigurableIssueCode.

@Test
public void testConfigurableIssueCode() {
    try {
        final IPersistentPreferenceStore xtendPrefStore = this.getXtendPreferencesStore();
        try {
            xtendPrefStore.setValue(IssueCodes.UNUSED_PRIVATE_MEMBER, "warning");
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("class TestConfigurableIssueCode {");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private String unusedField = \"unusedField\"");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            XtendFile _xtendFile = this.testHelper.xtendFile("TestConfigurableIssueCode.xtend", _builder.toString());
            final Procedure1<XtendFile> _function = (XtendFile it) -> {
                final XtendMember unusedField = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(it.getXtendTypes(), XtendClass.class)).getMembers());
                this.helper.assertWarning(unusedField, XtendPackage.Literals.XTEND_FIELD, IssueCodes.UNUSED_PRIVATE_MEMBER);
            };
            ObjectExtensions.<XtendFile>operator_doubleArrow(_xtendFile, _function);
            xtendPrefStore.setValue(IssueCodes.UNUSED_PRIVATE_MEMBER, "error");
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("class TestConfigurableIssueCode {");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("private String unusedField = \"unusedField\"");
            _builder_1.newLine();
            _builder_1.append("}");
            _builder_1.newLine();
            XtendFile _xtendFile_1 = this.testHelper.xtendFile("TestConfigurableIssueCode.xtend", _builder_1.toString());
            final Procedure1<XtendFile> _function_1 = (XtendFile it) -> {
                final XtendMember unusedField = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(it.getXtendTypes(), XtendClass.class)).getMembers());
                this.helper.assertError(unusedField, XtendPackage.Literals.XTEND_FIELD, IssueCodes.UNUSED_PRIVATE_MEMBER);
            };
            ObjectExtensions.<XtendFile>operator_doubleArrow(_xtendFile_1, _function_1);
        } finally {
            xtendPrefStore.setToDefault(IssueCodes.UNUSED_PRIVATE_MEMBER);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore) Test(org.junit.Test)

Example 7 with IPersistentPreferenceStore

use of org.eclipse.jface.preference.IPersistentPreferenceStore in project xtext-xtend by eclipse.

the class QuickfixTestBuilder method tearDown.

public void tearDown() {
    this.editor = null;
    this._workbenchTestHelper.closeAllEditors(false);
    final Consumer<IFile> _function = (IFile it) -> {
        try {
            NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
            it.delete(true, _nullProgressMonitor);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    };
    this._workbenchTestHelper.getFiles().forEach(_function);
    this._workbenchTestHelper.getFiles().clear();
    if ((this.modifiedIssueCodes != null)) {
        IPersistentPreferenceStore _preferenceStore = this.getPreferenceStore();
        final Procedure1<IPersistentPreferenceStore> _function_1 = (IPersistentPreferenceStore it) -> {
            final Consumer<String> _function_2 = (String code) -> {
                it.setToDefault(code);
            };
            this.modifiedIssueCodes.forEach(_function_2);
            it.setToDefault(XbaseBuilderPreferenceAccess.PREF_USE_COMPILER_SOURCE);
            it.setToDefault(XbaseBuilderPreferenceAccess.PREF_JAVA_VERSION);
        };
        ObjectExtensions.<IPersistentPreferenceStore>operator_doubleArrow(_preferenceStore, _function_1);
        this.modifiedIssueCodes = null;
    }
    NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
    this._syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) Consumer(java.util.function.Consumer) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore)

Example 8 with IPersistentPreferenceStore

use of org.eclipse.jface.preference.IPersistentPreferenceStore in project tdi-studio-se by Talend.

the class DefaultRunProcessService method storeProjectPreferences.

@Override
public void storeProjectPreferences(IPreferenceStore preferenceStore) {
    RepositoryWorkUnit workUnit = new //$NON-NLS-1$
    RepositoryWorkUnit(//$NON-NLS-1$
    "Store project preferences") {

        @Override
        protected void run() {
            try {
                if (preferenceStore instanceof IPersistentPreferenceStore) {
                    ((IPersistentPreferenceStore) preferenceStore).save();
                }
            } catch (IOException e) {
                ExceptionHandler.process(e);
            }
        }
    };
    workUnit.setAvoidUnloadResources(true);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
}
Also used : RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IOException(java.io.IOException) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore)

Example 9 with IPersistentPreferenceStore

use of org.eclipse.jface.preference.IPersistentPreferenceStore in project knime-core by knime.

the class IntroPage method showMissingBrowserWarning.

private void showMissingBrowserWarning(final IWebBrowser browser) {
    IPersistentPreferenceStore prefStore = (IPersistentPreferenceStore) KNIMEUIPlugin.getDefault().getPreferenceStore();
    boolean omitWarnings = prefStore.getBoolean(PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING);
    if (!omitWarnings) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openWarning(Display.getDefault().getActiveShell(), "Missing browser integration", "KNIME is unable to display web pages in an internal browser. This may be caused by missing " + "system libraries. Please visit https://www.knime.com/faq#q6 for details.\n" + "Some web pages may open in an external browser.", "Do not show again", false, prefStore, PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING);
        if (dialog.getToggleState()) {
            prefStore.setValue(PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING, true);
            try {
                prefStore.save();
            } catch (IOException ex) {
            // too bad, ignore it
            }
        }
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IOException(java.io.IOException) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore)

Example 10 with IPersistentPreferenceStore

use of org.eclipse.jface.preference.IPersistentPreferenceStore in project abstools by abstools.

the class ProjectAddLocationHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
    Object firstElement = selection.getFirstElement();
    if (firstElement instanceof IProject) {
        IProject project = (IProject) firstElement;
        AbsNature nature = UtilityFunctions.getAbsNature(project);
        if (nature == null)
            return null;
        IPersistentPreferenceStore projectStore = nature.getProjectPreferenceStore();
        boolean locationTypecheckingEnabled = projectStore.getBoolean(Constants.LOCATION_TYPECHECK);
        if (!locationTypecheckingEnabled) {
            MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Locationtypechecking", "Location type checking is disabled. Please enable for this function to work!");
            return null;
        }
        UtilityFunctions.saveEditors(project, false);
        Map<LocationTypeVariable, LocationType> locationTypeInferrerResult = nature.getLocationTypeInferrerResult();
        if (locationTypeInferrerResult != null) {
            InferMain inferMain = new InferMain();
            String commandId = event.getCommand().getId();
            if ("org.abs-models.abs.plugin.projectaddalllocations".equals(commandId)) {
                inferMain.setConfig(InferMain.Config.values());
            } else if ("org.abs-models.abs.plugin.projectaddclasslocations".equals(commandId)) {
                inferMain.setConfig(InferMain.Config.CLASSES);
            } else if ("org.abs-models.abs.plugin.projectaddfieldlocations".equals(commandId)) {
                inferMain.setConfig(InferMain.Config.FIELDS);
            } else if ("org.abs-models.abs.plugin.projectaddfunctionlocations".equals(commandId)) {
                inferMain.setConfig(InferMain.Config.FUNCTIONS);
            } else if ("org.abs-models.abs.plugin.projectaddinterfacelocations".equals(commandId)) {
                inferMain.setConfig(InferMain.Config.INTERFACES);
            }
            try {
                inferMain.writeInferenceResultsBack(locationTypeInferrerResult);
                try {
                    project.refreshLocal(IResource.DEPTH_INFINITE, null);
                } catch (CoreException e) {
                }
            } catch (IOException e) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Error while inserting locations", "An error occurred while inserting locations!\n" + e.getLocalizedMessage());
            }
        }
    }
    return null;
}
Also used : InferMain(abs.frontend.typechecker.locationtypes.infer.InferMain) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore) LocationTypeVariable(abs.frontend.typechecker.locationtypes.infer.LocationTypeVariable) CoreException(org.eclipse.core.runtime.CoreException) LocationType(abs.frontend.typechecker.locationtypes.LocationType) AbsNature(org.absmodels.abs.plugin.builder.AbsNature)

Aggregations

IPersistentPreferenceStore (org.eclipse.jface.preference.IPersistentPreferenceStore)14 IOException (java.io.IOException)8 CoreException (org.eclipse.core.runtime.CoreException)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 LocationType (abs.frontend.typechecker.locationtypes.LocationType)3 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 BooleanPrefAction (org.eclipse.egit.ui.internal.actions.BooleanPrefAction)3 InferMain (abs.frontend.typechecker.locationtypes.infer.InferMain)2 LocationTypeVariable (abs.frontend.typechecker.locationtypes.infer.LocationTypeVariable)2 Collection (java.util.Collection)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 AbsNature (org.absmodels.abs.plugin.builder.AbsNature)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 Action (org.eclipse.jface.action.Action)2 IAction (org.eclipse.jface.action.IAction)2