Example usage for org.eclipse.jface.preference IPreferenceStore setDefault

List of usage examples for org.eclipse.jface.preference IPreferenceStore setDefault

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore setDefault.

Prototype

void setDefault(String name, boolean value);

Source Link

Document

Sets the default value for the boolean-valued preference with the given name.

Usage

From source file:metabup.annotations.general.preferences.AnnotationsPreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    AnnotationFactory af = new AnnotationFactory();
    af.initializeFactory();/*from w  ww .  jav a 2s .  c o  m*/

    for (String ann : af.listAllAnnotationsNames()) {
        Class<? extends IAnnotation> annotationClass = af.getAnnotation(ann);
        try {
            IAnnotation annotation = annotationClass.newInstance();
            HashMap<String, Object> preferences = annotation.getPreferences();

            if (preferences != null && !preferences.isEmpty()) {

                Iterator it = preferences.entrySet().iterator();
                while (it.hasNext()) {
                    Map.Entry e = (Map.Entry) it.next();
                    if (e.getValue() instanceof String)
                        store.setDefault((String) e.getKey(), (String) e.getValue());
                    else if (e.getValue() instanceof Boolean)
                        store.setDefault((String) e.getKey(), (Boolean) e.getValue());
                }
            }
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
    }
}

From source file:metabup.annotations.preferences.AnnotationsPluginPreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(AnnotationsPluginPreferenceConstants.P_ANNOTATIONS_PACKAGE, "annotations");
    store.setDefault(AnnotationsPluginPreferenceConstants.P_ANNOTATIONS_LIB_FILES,
            "data/metabup.annotations.lib.jar");
}

From source file:metabup.assistance.preferences.AssistanceTipsPreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    AssistanceTipsFactory af = new AssistanceTipsFactory();
    af.initializeFactory();//from  w w  w . j av  a 2s . c om

    for (String at : af.listAllAssistanceTipNames()) {
        Class<? extends IAssistanceTip> tipClass = af.getAssistanceTip(at);
        try {
            IAssistanceTip tip = tipClass.newInstance();
            HashMap<String, Object> preferences = tip.getPreferences();

            if (preferences != null && !preferences.isEmpty()) {

                Iterator it = preferences.entrySet().iterator();
                while (it.hasNext()) {
                    Map.Entry e = (Map.Entry) it.next();
                    if (e.getValue() instanceof String)
                        store.setDefault((String) e.getKey(), (String) e.getValue());
                    else if (e.getValue() instanceof Boolean)
                        store.setDefault((String) e.getKey(), (Boolean) e.getValue());
                }
            }
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
    }
}

From source file:metabup.change.collaboro.CollaboroChangeTrace.java

License:Open Source License

public void exportToCollaboro(IFile chFile) {
    ResourceSetImpl rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new XMIResourceFactoryImpl());
    Resource chResource = new XMIResourceImpl(URI.createURI(chFile.getLocationURI().toString()));

    //IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = chFile.getProject();
    IFile ecoreFile = project.getFile(chFile.getName().substring(0, chFile.getName().indexOf(".")) + ".ecore");
    Resource ecoreResource = null;

    if (ecoreFile.exists()) {
        ecoreResource = new XMIResourceImpl(URI.createURI(ecoreFile.getLocationURI().toString()));
        rs.getResources().add(ecoreResource);
    } else //System.out.println("No ecore file found. It might carry future problems with serialization");

        rs.getResources().add(chResource);

    if (!chFile.exists()) {
        History collHistory = HistoryFactory.eINSTANCE.createHistory();

        String username = metabup.preferences.PreferenceConstants.P_COLLABORO_USERNAME;

        if (username.equals("")) {
            InputDialog ipDialog = new InputDialog(null, "Collaboro username required",
                    "Enter your collaboro username: ", PreferenceConstants.P_COLLABORO_USERNAME, null);
            if (ipDialog.open() == InputDialog.OK) {
                username = ipDialog.getValue();
                IPreferenceStore store = metabup.preferences.Activator.getDefault().getPreferenceStore();
                store.setDefault(PreferenceConstants.P_COLLABORO_USERNAME, username);
            }/*www  .  j a v a 2s . co m*/
        }

        User user = HistoryFactory.eINSTANCE.createUser();
        user.setId(username);

        VersionHistory vh = HistoryFactory.eINSTANCE.createVersionHistory();
        vh.setType(VersionHistoryType.TRUNK);

        Version version = HistoryFactory.eINSTANCE.createVersion();
        version.setId("1.0");

        Proposal proposal = HistoryFactory.eINSTANCE.createProposal();
        proposal.setProposedBy(user);
        proposal.setRationale("metabup-based proposal");
        proposal.setId("n0");

        Solution solution = HistoryFactory.eINSTANCE.createSolution();
        solution.setProposedBy(user);

        // root ePackage generation in case there's no one available 
        if (ePackage == null) {
            InputDialog ipDialog = new InputDialog(null, "Main EPackage name required",
                    "Name the EPackage that will contain your Metaclasses",
                    chFile.getName().substring(0, chFile.getName().lastIndexOf(".")), null);
            if (ipDialog.open() == InputDialog.OK) {
                ePackage = EcoreFactory.eINSTANCE.createEPackage();
                ePackage.setName(ipDialog.getValue());

                Add add = HistoryFactory.eINSTANCE.createAdd();

                NewAbstractSyntaxElement nase = HistoryFactory.eINSTANCE.createNewAbstractSyntaxElement();
                nase.setElement(ePackage);
                add.setTarget(nase);

                add.setSolution(solution);
                solution.getChanges().add(add);
            }
        }

        solution.getChanges().addAll(this.getCollaboroAdds(solution));
        solution.getChanges().addAll(this.getCollaboroDeletes(solution));
        solution.getChanges().addAll(this.getCollaboroUpdates(solution));

        proposal.getSols().add(solution);
        version.getProposals().add(proposal);
        vh.getVersions().add(version);
        collHistory.getUsers().add(user);
        collHistory.getHistories().add(vh);

        chResource.getContents().add(collHistory);

        try {
            chFile.create(null, true, null);
            chFile.refreshLocal(1, null);
            chResource.save(null);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        //WindowDialog.openError();
        //System.out.println("The file already exists");
    }
}

From source file:metabup.change.trace.ChangeTrace.java

License:Open Source License

public void exportToCollaboro(IFile chFile) {
    ResourceSetImpl rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new XMIResourceFactoryImpl());
    Resource chResource = new XMIResourceImpl(URI.createURI(chFile.getLocationURI().toString()));

    //IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = chFile.getProject();
    IFile ecoreFile = project.getFile(chFile.getName().substring(0, chFile.getName().indexOf(".")) + ".ecore");
    Resource ecoreResource = null;

    if (ecoreFile.exists()) {
        ecoreResource = new XMIResourceImpl(URI.createURI(ecoreFile.getLocationURI().toString()));
        rs.getResources().add(ecoreResource);
    } else //System.out.println("No ecore file found. It might carry future problems with serialization");

        rs.getResources().add(chResource);

    if (!chFile.exists()) {
        History collHistory = HistoryFactory.eINSTANCE.createHistory();

        String username = PreferenceConstants.P_COLLABORO_USERNAME;

        if (username.equals("")) {
            InputDialog ipDialog = new InputDialog(null, "Collaboro username required",
                    "Enter your collaboro username: ", PreferenceConstants.P_COLLABORO_USERNAME, null);
            if (ipDialog.open() == InputDialog.OK) {
                username = ipDialog.getValue();
                IPreferenceStore store = metabup.preferences.Activator.getDefault().getPreferenceStore();
                store.setDefault(PreferenceConstants.P_COLLABORO_USERNAME, username);
            }//from  w  ww.  j av a2s.c  om
        }

        User user = HistoryFactory.eINSTANCE.createUser();
        user.setId(username);

        VersionHistory vh = HistoryFactory.eINSTANCE.createVersionHistory();
        vh.setType(VersionHistoryType.TRUNK);

        Version version = HistoryFactory.eINSTANCE.createVersion();
        version.setId("1.0");

        Proposal proposal = HistoryFactory.eINSTANCE.createProposal();
        proposal.setProposedBy(user);
        proposal.setRationale("metabup-based proposal");
        proposal.setId("n0");

        Solution solution = HistoryFactory.eINSTANCE.createSolution();
        solution.setProposedBy(user);

        /* root ePackage generation in case there's no one available */
        if (ePackage == null) {
            InputDialog ipDialog = new InputDialog(null, "Main EPackage name required",
                    "Name the EPackage that will contain your Metaclasses",
                    chFile.getName().substring(0, chFile.getName().lastIndexOf(".")), null);
            if (ipDialog.open() == InputDialog.OK) {
                ePackage = EcoreFactory.eINSTANCE.createEPackage();
                ePackage.setName(ipDialog.getValue());

                Add add = HistoryFactory.eINSTANCE.createAdd();

                NewAbstractSyntaxElement nase = HistoryFactory.eINSTANCE.createNewAbstractSyntaxElement();
                nase.setElement(ePackage);
                add.setTarget(nase);

                add.setSolution(solution);
                solution.getChanges().add(add);
            }
        }

        solution.getChanges().addAll(this.getCollaboroAdds(solution));
        solution.getChanges().addAll(this.getCollaboroDeletes(solution));
        solution.getChanges().addAll(this.getCollaboroUpdates(solution));

        proposal.getSols().add(solution);
        version.getProposals().add(proposal);
        vh.getVersions().add(version);
        collHistory.getUsers().add(user);
        collHistory.getHistories().add(vh);

        chResource.getContents().add(collHistory);

        try {
            chFile.create(null, true, null);
            chFile.refreshLocal(1, null);
            chResource.save(null);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        //WindowDialog.openError();
        //System.out.println("The file already exists");
    }
}

From source file:metabup.change.trace.ChangeTracer.java

License:Open Source License

public void exportToCollaboro(IFile chFile) {
    ResourceSetImpl rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new XMIResourceFactoryImpl());
    Resource chResource = new XMIResourceImpl(URI.createURI(chFile.getLocationURI().toString()));

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = chFile.getProject();
    IFile ecoreFile = project.getFile(chFile.getName().substring(0, chFile.getName().indexOf(".")) + ".ecore");
    Resource ecoreResource = null;

    if (ecoreFile.exists()) {
        ecoreResource = new XMIResourceImpl(URI.createURI(ecoreFile.getLocationURI().toString()));
        rs.getResources().add(ecoreResource);
    } else //System.out.println("No ecore file found. It might carry future problems with serialization");

        rs.getResources().add(chResource);

    if (!chFile.exists()) {
        History collHistory = HistoryFactory.eINSTANCE.createHistory();

        String username = metabup.preferences.PreferenceConstants.P_COLLABORO_USERNAME;

        if (username.equals("")) {
            InputDialog ipDialog = new InputDialog(null, "Collaboro username required",
                    "Enter your collaboro username: ",
                    metabup.preferences.PreferenceConstants.P_COLLABORO_USERNAME, null);
            if (ipDialog.open() == InputDialog.OK) {
                username = ipDialog.getValue();
                IPreferenceStore store = metabup.preferences.Activator.getDefault().getPreferenceStore();
                store.setDefault(metabup.preferences.PreferenceConstants.P_COLLABORO_USERNAME, username);
            }/*  ww w  .  j  a  v a 2 s  .c  o m*/
        }

        User user = HistoryFactory.eINSTANCE.createUser();
        user.setId(username);

        VersionHistory vh = HistoryFactory.eINSTANCE.createVersionHistory();
        vh.setType(VersionHistoryType.TRUNK);

        Version version = HistoryFactory.eINSTANCE.createVersion();
        version.setId("1.0");

        Proposal proposal = HistoryFactory.eINSTANCE.createProposal();
        proposal.setProposedBy(user);
        proposal.setRationale("metabup-based proposal");
        proposal.setId("n0");

        Solution solution = HistoryFactory.eINSTANCE.createSolution();
        solution.setProposedBy(user);

        /* root ePackage generation in case there's no one available */
        if (ePackage == null) {
            InputDialog ipDialog = new InputDialog(null, "Main EPackage name required",
                    "Name the EPackage that will contain your Metaclasses",
                    chFile.getName().substring(0, chFile.getName().lastIndexOf(".")), null);
            if (ipDialog.open() == InputDialog.OK) {
                ePackage = EcoreFactory.eINSTANCE.createEPackage();
                ePackage.setName(ipDialog.getValue());

                Add add = HistoryFactory.eINSTANCE.createAdd();

                NewAbstractSyntaxElement nase = HistoryFactory.eINSTANCE.createNewAbstractSyntaxElement();
                nase.setElement(ePackage);
                add.setTarget(nase);

                add.setSolution(solution);
                solution.getChanges().add(add);
            }
        }

        solution.getChanges().addAll(this.getCollaboroAdds(solution));
        solution.getChanges().addAll(this.getCollaboroDeletes(solution));
        solution.getChanges().addAll(this.getCollaboroUpdates(solution));

        proposal.getSols().add(solution);
        version.getProposals().add(proposal);
        vh.getVersions().add(version);
        collHistory.getUsers().add(user);
        collHistory.getHistories().add(vh);

        chResource.getContents().add(collHistory);

        try {
            chFile.create(null, true, null);
            chFile.refreshLocal(1, null);
            chResource.save(null);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        //WindowDialog.openError();
        //System.out.println("The file already exists");
    }
}

From source file:metabup.lexicon.preferences.PreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(PreferenceConstants.WORDNET_LOCATION, "");
}

From source file:metabup.preferences.PreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(PreferenceConstants.P_COLLABORO_USERNAME, "");
    /*store.setDefault(PreferenceConstants.P_BOOLEAN, true);
    store.setDefault(PreferenceConstants.P_CHOICE, "choice2");
    store.setDefault(PreferenceConstants.P_STRING,
    "Default value");*//*from   w  ww .  j  a va  2  s . co m*/
}

From source file:metabup.sketches.Activator.java

License:Open Source License

@Override
protected void initializeDefaultPreferences(IPreferenceStore store) {
    store.setDefault(SketchPreferenceConstants.AssociationNamingCriteriaPreference,
            SketchPreferenceConstants.OBJECT);
}

From source file:metabup.sketches.preferences.SketchPreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(SketchPreferenceConstants.AssociationNamingCriteriaPreference,
            SketchPreferenceConstants.OBJECT);
}