Preference in eclipse workbench (1)

Source: Internet
Author: User

(Original ENGLISH)

Translated by Frank

Preference in eclipse workbench


Overview
On the eclipse platform, plug-in developers Define preference pages for their own plug-ins, which can be used in the workbench preference dialog box. This article will show you when to use preference, as well as some features that support preference provided by the eclipse platform.

Editor's note: This article was first published in November 2001, corresponding to the 1.0 version of eclipse at that time. In 2.0, the user interface preference function was enhanced.


Introduction

The eclipse platform supports preference, which is accompanied by the emergence of a workspace. This article will discuss the data storage type of preference and describe how to develop and register user interfaces to make it easier for users to set preference, it also tells you how to use the import and export functions to store preference that does not depend on the workbench. It also tells you how to initialize and obtain the preference when other plug-ins want to use the preference of your plug-in. This function will be demonstrated in the following example. This example is to find the wrong word in the file. We will use two preference pages in this tool to set our preference, one of which is to set the color of high-volume display. This page is relatively simple, and the other is a little complicated, is to set the word list.

 

 

 

 

 

 

 

 

When to use preference

 

 

 

 

 

 

 

 

Preference is a type of data that exists in a workspace and allows users to store the status of the plug-in to ensure its consistency in eclipse. Eclipse 2.0 provides two preference types: User Interface (UI) preference (also exists in 1.0) and core preference. This article only covers how to use the UI preference storage. A typical UI preference has new instance default values, Editor colors, paths, and so on. The core preference is used for values that are not part of the UI.

 

 

 

 

 

 

 

 

Preference does not involve any resources in the current workspace. On the contrary, it should be used by the editor, view, or other objects that operate on resources. Data corresponding to a resource instance is best stored as an attribute. Of course, this will be discussed in a later article.

 

 

 

 

 

 

 

 

Preference is available for any plug-in. Of course, the prerequisite is that there is a plug-in. The common method is to provide APIs on your plug-in to allow the preference to be accessed. Preference values are stored in the. Metadata/. plugins directory of the workspace. The following is an example.

 

 

 

 

 

 

 

 

Preference store and plug-ins

 

 

 

 

 

 

 

 

Each plug-in has its own preference store, which is provided by the workspace. In this example, we will define a plug-in that uses its preference store to store preference. To use the plug-in the UI, we define the subclass of abustractuiplugin. Constructor (see
) An independent plug-in instance will be created in the Workbench to allow easy access. The implementation method initializedefaultpreferences () is used to set the default value for preference. First, a preference is defined for the wrong word, and the other is the color of the high-volume display. The value of each preference corresponds to the given keyword. The keywords used in the following code are constants defined in.

 

 

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.