Package org.eclipse.jface.preference

Examples of org.eclipse.jface.preference.PreferenceStore


 
 
  public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
    fParent= parent;
    fOverlayKeys= overlayKeys;
    fStore= new PreferenceStore();
  }
View Full Code Here


    /* (non-Javadoc)
     * @see org.apache.felix.sigil.eclipse.model.repository.IRepositoryPreferences#getPreferenceStore(org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel)
     */
    public PreferenceStore toPreferenceStore(final IRepositoryModel model)
    {
        PreferenceStore store = new PreferenceStore();
        store.setFilename(makeFileName(model));
       
        for (Map.Entry<Object, Object> e : model.getProperties().entrySet()) {
            store.setValue((String) e.getKey(), (String) e.getValue());
        }
       
        store.setValue("provider", model.getType().getProvider());

        store.addPropertyChangeListener(new IPropertyChangeListener()
        {           
            public void propertyChange(PropertyChangeEvent event)
            {
                model.getProperties().setProperty(event.getProperty(), event.getNewValue().toString());
            }
View Full Code Here

     */
    public OverlayPreferenceStore(final IPreferenceStore parent,
            final OverlayKey[] overlayKeys) {
        fParent = parent;
        fOverlayKeys = overlayKeys;
        fStore = new PreferenceStore();
    }
View Full Code Here

        // Start worker thread to refresh tree for added or removed objects
        (new Thread(new Worker())).start();

        createConfigFile();
        _preferences = new PreferenceStore(INI_FILENAME);

        try
        {
            _preferences.load();
        }
View Full Code Here

        }
    }
   
    private void loadAttributePreferences()
    {
        _preferences = new PreferenceStore(INI_FILENAME);
        List<String> attributesList = new ArrayList<String>();
      
        //ensure the name is present, and first
        attributesList.add(ManagedQueue.ATTR_NAME);
       
View Full Code Here

                .getRoot()
                .getFile(
                        new Path(getPreferenceFileForTypeSystem(typeSystemFile.getFullPath()
                                .toPortableString())));

        PreferenceStore tsPrefStore = typeSystemPreferences.get(prefFile.getFullPath()
                .toPortableString());

        // If lookup for store failed ...
        if (tsPrefStore == null) {
          if (prefFile.exists()) {
            tsPrefStore = new PreferenceStore(prefFile.getName());
            try {
              tsPrefStore.load(prefFile.getContents()); // TODO: Close stream!
            } catch (IOException e) {
              e.printStackTrace(); // TODO: Handle this correctly!
            }
          } else {

            // UIMA-2245
            // DotCorpus to Eclipse PreferenceStore migration code.
            // If there is DotCorpus style file and not yet a preference store file
            // the settings from the DotCorpus style file should be written into a preference store
            // file.
            IFile styleFile = ResourcesPlugin
                    .getWorkspace()
                    .getRoot()
                    .getFile(
                            new Path(getStyleFileForTypeSystem(typeSystemFile.getFullPath()
                                    .toPortableString())));

            if (styleFile.exists()) {
              InputStream styleFileIn = null;
              ;
              DotCorpus dotCorpus = null;
              try {
                styleFileIn = styleFile.getContents();
                dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);

              } finally {
                if (styleFileIn != null)
                  try {
                    styleFileIn.close();
                  } catch (IOException e) {
                    CasEditorPlugin.log(e);
                  }
              }

              if (dotCorpus != null) {
                tsPrefStore = new PreferenceStore(prefFile.getName());
                for (AnnotationStyle style : dotCorpus.getAnnotationStyles()) {
                  AnnotationStyle.putAnnotatationStyleToStore(tsPrefStore, style);
                }

                for (String shownType : dotCorpus.getShownTypes()) {
                  tsPrefStore.putValue(shownType + ".isShown", "true");
                }

                ByteArrayOutputStream prefOut = new ByteArrayOutputStream();
                try {
                  tsPrefStore.save(prefOut, "");
                } catch (IOException e) {
                  // Should never happen!
                  CasEditorPlugin.log(e);
                }

                // TODO: Do we need to handle exceptions here?
                prefFile.create(new ByteArrayInputStream(prefOut.toByteArray()), IFile.FORCE, null);
              }
            }
          }

          // No preference defined, lets use defaults
          if (tsPrefStore == null) {
            tsPrefStore = new PreferenceStore(prefFile.getName());

            CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
            TypeSystem ts = cas.getTypeSystem();

            Collection<AnnotationStyle> defaultStyles = getConfiguredAnnotationStyles(tsPrefStore,
                    ts);

            Collection<AnnotationStyle> newStyles = DefaultColors.assignColors(ts, defaultStyles);

            // TODO: Settings defaults must be moved to the AnnotationEditor
            for (AnnotationStyle style : newStyles) {
              AnnotationStyle.putAnnotatationStyleToStore(tsPrefStore, style);
            }
          }

          typeSystemPreferences.put(prefFile.getFullPath().toPortableString(), tsPrefStore);
        }

        documentToTypeSystemMap.put(document, typeSystemFile
                .getFullPath().toPortableString());

        IPreferenceStore store = sessionPreferenceStores.get(getTypesystemId(element));

        if (store == null) {
          PreferenceStore newStore = new PreferenceStore();
          sessionPreferenceStores.put(getTypesystemId(element), newStore);
          newStore.addPropertyChangeListener(new SaveSessionPreferencesTrigger(element));

          String sessionPreferenceString = typeSystemFile.getPersistentProperty(new QualifiedName(
                  "", CAS_EDITOR_SESSION_PROPERTIES));

          if (sessionPreferenceString != null) {
            try {
              newStore.load(new ByteArrayInputStream(sessionPreferenceString.getBytes("UTF-8")));
            } catch (IOException e) {
              CasEditorPlugin.log(e);
            }
          }
        }
View Full Code Here

  @Override
  public void saveTypeSystemPreferenceStore(Object element) {
    String prefereceFileId = getPreferenceFileForTypeSystem(getTypesystemId(element));

    PreferenceStore preferences = typeSystemPreferences.get(prefereceFileId);

    // serialize ...
    IFile preferenceFile = ResourcesPlugin.getWorkspace().getRoot()
            .getFile(Path.fromPortableString(prefereceFileId));

    ByteArrayOutputStream preferenceBytes = new ByteArrayOutputStream();

    try {
      preferences.save(preferenceBytes, "");
    } catch (IOException e) {
      // will not fail, writing to memory
      CasEditorPlugin.log(e);
    }
View Full Code Here

    public void propertyChange(PropertyChangeEvent event) {
      IResource tsFile = ResourcesPlugin.getWorkspace().getRoot()
              .findMember((getTypesystemId(element)));

      PreferenceStore prefStore = (PreferenceStore) getSessionPreferenceStore(element);

      ByteArrayOutputStream prefBytes = new ByteArrayOutputStream();
      try {
        prefStore.save(prefBytes, "");
      } catch (IOException e) {
        CasEditorIdePlugin.log(e);
      }

      try {
View Full Code Here

          fEncodingEditor= new ResourceEncodingFieldEditor("", (Composite)composite, resource); //$NON-NLS-1$
          fEncodingEditor.setPage(page);
          fEncodingEditor.load();
        } else {
          fEncodingEditor= new EncodingFieldEditor(ENCODING_PREF_KEY, "", (Composite)composite); //$NON-NLS-1$
          store= new PreferenceStore();
          String defaultEncoding= encodingSupport.getDefaultEncoding();
          store.setDefault(ENCODING_PREF_KEY, defaultEncoding);
          String encoding= encodingSupport.getEncoding();
          if (encoding != null)
            store.setValue(ENCODING_PREF_KEY, encoding);
View Full Code Here

   * @param overlayKeys the overlay keys
   */
  public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
    fParent= parent;
    fOverlayKeys= overlayKeys;
    fStore= new PreferenceStore();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.preference.PreferenceStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.