Java Code Examples for org.eclipse.jface.preference.IPreferenceStore#getInt()

The following examples show how to use org.eclipse.jface.preference.IPreferenceStore#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferenceInitializer.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static List<DBSetting> getDBSettingList(String database) {
	List<DBSetting> dbSettingList = new ArrayList<DBSetting>();

	IPreferenceStore store = Activator.getDefault().getPreferenceStore();

	int num = store.getInt(PreferenceInitializer.DB_SETTING_LIST_NUM);

	for (int i = 1; i <= num; i++) {
		DBSetting dbSetting = PreferenceInitializer.getDBSetting(i);
		if (database != null && !dbSetting.getDbsystem().equals(database)) {
			continue;
		}
		dbSettingList.add(dbSetting);
	}

	Collections.sort(dbSettingList);

	return dbSettingList;
}
 
Example 2
Source File: JavaNavigatorViewActionProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void restoreState(IMemento memento) {
	boolean isCurrentLayoutFlat= true;
	Integer state= null;
	if (memento != null)
		state= memento.getInteger(TAG_LAYOUT);

	// If no memento try an restore from preference store
	if (state == null) {
		IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
		state= new Integer(store.getInt(TAG_LAYOUT));
	}

	if (state.intValue() == FLAT_LAYOUT)
		isCurrentLayoutFlat= true;
	else
		if (state.intValue() == HIERARCHICAL_LAYOUT)
			isCurrentLayoutFlat= false;

	fStateModel.setBooleanProperty(Values.IS_LAYOUT_FLAT, isCurrentLayoutFlat);
	fLayoutActionGroup.setFlatLayout(isCurrentLayoutFlat);
}
 
Example 3
Source File: PreferenceInitializer.java    From erflute with Apache License 2.0 6 votes vote down vote up
public static DBSettings getDBSetting(int no) {
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();

    final String dbsystem = store.getString(PreferenceInitializer.DB_SETTING_DBSYSTEM + no);
    final String server = store.getString(PreferenceInitializer.DB_SETTING_SERVER + no);
    final int portNo = store.getInt(PreferenceInitializer.DB_SETTING_PORT + no);

    final String database = store.getString(PreferenceInitializer.DB_SETTING_DATABASE + no);
    final String user = store.getString(PreferenceInitializer.DB_SETTING_USER + no);
    final String password = store.getString(PreferenceInitializer.DB_SETTING_PASSWORD + no);
    final String useDefaultDriverString = store.getString(PreferenceInitializer.DB_SETTING_USE_DEFAULT_DRIVER + no);
    final String url = store.getString(PreferenceInitializer.DB_SETTING_URL + no);
    final String driverClassName = store.getString(PreferenceInitializer.DB_SETTING_DRIVER_CLASS_NAME + no);

    boolean useDefaultDriver = true;
    if ("false".equals(useDefaultDriverString) || StandardSQLDBManager.ID.equals(dbsystem)) {
        useDefaultDriver = false;
    }
    return new DBSettings(dbsystem, server, portNo, database, user, password, useDefaultDriver, url, driverClassName);
}
 
Example 4
Source File: PreferenceInitializer.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public static List<DBSetting> getDBSettingList(final String database) {
    final List<DBSetting> dbSettingList = new ArrayList<DBSetting>();

    final IPreferenceStore store = ERDiagramActivator.getDefault().getPreferenceStore();

    final int num = store.getInt(PreferenceInitializer.DB_SETTING_LIST_NUM);

    for (int i = 1; i <= num; i++) {
        final DBSetting dbSetting = PreferenceInitializer.getDBSetting(i);
        if (database != null && !dbSetting.getDbsystem().equals(database)) {
            continue;
        }
        dbSettingList.add(dbSetting);
    }

    Collections.sort(dbSettingList);

    return dbSettingList;
}
 
Example 5
Source File: PreferenceInitializer.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public static String getJDBCDriverPath(final String db, final String driverClassName) {
    String path = null;

    final IPreferenceStore store = ERDiagramActivator.getDefault().getPreferenceStore();

    final int listSize = store.getInt(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM);

    for (int i = 0; i < listSize; i++) {
        if (db.equals(store.getString(PreferenceInitializer.JDBC_DRIVER_DB_NAME_PREFIX + i)) && driverClassName.equals(store.getString(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_PREFIX + i))) {
            path = store.getString(PreferenceInitializer.JDBC_DRIVER_PATH_PREFIX + i);
            break;
        }
    }

    return path;
}
 
Example 6
Source File: ProfileManager.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public static IProfile readProfileFromStore(String profName, IPreferenceStore ips, String id, IProfile profileFactory) {
    int allCount = ips.getInt(id + ID_PROFILES_COUNT);
    for (int cnt=0; cnt < allCount; ++cnt) {
        try {
            String xml = ips.getString(id + ID_PROFILE + cnt);
            StringReader reader = new StringReader(xml);
            XMLMemento memento = XMLMemento.createReadRoot(reader);
            IProfile ip = profileFactory.createFromMemento(memento);
            if (ip != null && profName.equals(ip.getName())) {
                return ip;
            }
        } catch (Exception e) {
            LogHelper.logError(e);
        }
    }
    return null;
}
 
Example 7
Source File: ImportArranger.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return the maximum number of columns that may be available in a line.
 */
private static int getMaxCols(boolean multilineImports) {
    final int maxCols;
    if (multilineImports) {
        if (SharedCorePlugin.inTestMode()) {
            maxCols = 80;
        } else {
            IPreferenceStore chainedPrefStore = PyDevUiPrefs.getChainedPrefStore();
            maxCols = chainedPrefStore
                    .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
        }
    } else {
        maxCols = Integer.MAX_VALUE;
    }
    return maxCols;
}
 
Example 8
Source File: PDGSliceUnion.java    From JDeodorant with MIT License 6 votes vote down vote up
private boolean complyWithUserThresholds() {
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	int minimumSliceSize = store.getInt(PreferenceConstants.P_MINIMUM_SLICE_SIZE);
	int maximumSliceSize = store.getInt(PreferenceConstants.P_MAXIMUM_SLICE_SIZE);
	int maximumDuplication = store.getInt(PreferenceConstants.P_MAXIMUM_DUPLICATION);
	double maximumRatioOfDuplicatedToExtracted = store.getDouble(
			PreferenceConstants.P_MAXIMUM_RATIO_OF_DUPLICATED_TO_EXTRACTED);
	
	int sliceSize = sliceNodes.size();
	int duplicatedSize = sliceSize - removableNodes.size();
	double ratioOfDuplicatedToExtracted = (double)duplicatedSize/(double)sliceSize;
	
	if(sliceSize < minimumSliceSize)
		return false;
	if(sliceSize > (methodSize - maximumSliceSize))
		return false;
	if(duplicatedSize > maximumDuplication)
		return false;
	if(ratioOfDuplicatedToExtracted > maximumRatioOfDuplicatedToExtracted)
		return false;
	return true;
}
 
Example 9
Source File: PreferenceInitializer.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static String getJDBCDriverPath(String db, String driverClassName) {
	String path = null;

	IPreferenceStore store = Activator.getDefault().getPreferenceStore();

	int listSize = store
			.getInt(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM);

	for (int i = 0; i < listSize; i++) {
		if (driverClassName
				.equals(store
						.getString(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_PREFIX
								+ i))) {
			path = store
					.getString(PreferenceInitializer.JDBC_DRIVER_PATH_PREFIX
							+ i);
			break;
		}
	}

	return path;
}
 
Example 10
Source File: PreferenceUtil.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取项目属性的文本字段
 * @return ;
 */
public static ArrayList<String> getProjectFieldList() {
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	ArrayList<String> lstField = new ArrayList<String>();
	int fieldCount = store
			.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.fieldCount");
	if (fieldCount > 0) {
		for (int i = 0; i < fieldCount; i++) {
			lstField.add(store
					.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.field" + i));
		}
	}
	// 对中文按拼音排序
	Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
	Collections.sort(lstField, collatorChinese);
	return lstField;
}
 
Example 11
Source File: NonTranslationQAPage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performOk() {
	if (!isInit) {
		return true;
	}
	// 遍历列表,获取出要添加的数据
	List<NontransElementBean> addElementList = new ArrayList<NontransElementBean>();
	NontransElementBean listViewerBean;
	int listViewerNum = tableViewer.getTable().getItemCount();
	for (int i = 0; i < listViewerNum; i++) {
		if (tableViewer.getElementAt(i) instanceof NontransElementBean) {
			listViewerBean = (NontransElementBean)tableViewer.getElementAt(i);
			addElementList.add(listViewerBean);
		}
	}

	// 删除所有非译元素
	operate.deleteAllElement();
	
	// 再进行相关操作,先添加
	if (addElementList.size() > 0) {
		operate.addNonTransElement(addElementList);
	}
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	int oldValue = store.getInt(QAConstant.QA_PREF_nonTrans_changeTag);
	store.setValue(QAConstant.QA_PREF_nonTrans_changeTag, ++oldValue);
	return true;
}
 
Example 12
Source File: PreferenceInitializer.java    From erflute with Apache License 2.0 5 votes vote down vote up
public static void clearJDBCDriverInfo() {
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    final int num = store.getInt(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM);
    for (int i = 0; i < num; i++) {
        store.setValue(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_PREFIX + i, "");
        store.setValue(PreferenceInitializer.JDBC_DRIVER_PATH_PREFIX + i, "");
    }
    store.setValue(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM, 0);
}
 
Example 13
Source File: PreferenceInitializer.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public static void addJDBCDriver(final String db, final String className, final String path) {
    final IPreferenceStore store = ERDiagramActivator.getDefault().getPreferenceStore();

    final int listSize = store.getInt(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM);

    store.setValue(PreferenceInitializer.JDBC_DRIVER_DB_NAME_PREFIX + listSize, Format.null2blank(db));
    store.setValue(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_PREFIX + listSize, Format.null2blank(className));
    store.setValue(PreferenceInitializer.JDBC_DRIVER_PATH_PREFIX + listSize, Format.null2blank(path));

    store.setValue(PreferenceInitializer.JDBC_DRIVER_CLASS_NAME_LIST_NUM, listSize + 1);
}
 
Example 14
Source File: ParagraphConsistenceQA.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public ParagraphConsistenceQA(){
	//filterMap = model.getNotInclude();
	IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
	
	checkSameSource = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_SAMESOURCE);
	checkSameTarget = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_SAMETARGET);
	
	srcIgnoreTag = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_SRC_IGNORCETAG);
	srcIgnoreCase = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_SRC_IGNORCECASE);
	
	tgtIgnoreTag = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_TAR_IGNORCETAG);
	tgtIgnoreCase = preferenceStore.getBoolean(QAConstant.QA_PREF_PARA_TAR_IGNORCECASE);
	
	tipLevel = preferenceStore.getInt(QAConstant.QA_PREF_para_TIPLEVEL);
}
 
Example 15
Source File: PreferenceInitializer.java    From erflute with Apache License 2.0 5 votes vote down vote up
public static void addDBSetting(DBSettings dbSetting) {
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    int num = store.getInt(PreferenceInitializer.DB_SETTING_LIST_NUM);
    num++;
    store.setValue(PreferenceInitializer.DB_SETTING_LIST_NUM, num);
    saveSetting(num, dbSetting);
}
 
Example 16
Source File: PreferenceUtil.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 获取项目属性的属性字段
 * @return key 为属性名称,value 为属性值集合
 */
public static LinkedHashMap<String, ArrayList<String>> getProjectAttributeMap() {
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	HashMap<String, ArrayList<String>> mapAttr = new HashMap<String, ArrayList<String>>();
	int attrNameCount = store
			.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrNameCount");
	// 对中文按拼音排序
	final Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
	LinkedHashMap<String, ArrayList<String>> linkedMapAttr = new LinkedHashMap<String, ArrayList<String>>();
	if (attrNameCount > 0) {
		for (int i = 0; i < attrNameCount; i++) {
			String strAttrName = store
					.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName"
							+ i);
			int attrValCount = store
					.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName" + i
							+ ".count");
			ArrayList<String> lstAttrVal = new ArrayList<String>();
			if (attrValCount > 0) {
				for (int j = 0; j < attrValCount; j++) {
					lstAttrVal
							.add(store
									.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName"
											+ i + ".attrVal" + j));
				}
			}
			Collections.sort(lstAttrVal, collatorChinese);
			mapAttr.put(strAttrName, lstAttrVal);
		}
		List<Entry<String, ArrayList<String>>> lstAttr = new ArrayList<Entry<String, ArrayList<String>>>(
				mapAttr.entrySet());
		Collections.sort(lstAttr, new Comparator<Entry<String, ArrayList<String>>>() {

			public int compare(Entry<String, ArrayList<String>> arg0, Entry<String, ArrayList<String>> arg1) {
				return collatorChinese.compare(arg0.getKey(), arg1.getKey());
			}
		});

		for (Entry<String, ArrayList<String>> entry : lstAttr) {
			linkedMapAttr.put(entry.getKey(), entry.getValue());
		}
	}

	return linkedMapAttr;
}
 
Example 17
Source File: TmDbManagerImportWizardTmxPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 从首选项中读取导入策略
 * @return ;
 */
public int getTmxImportStrategy() {
	IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
	return ps.getInt(TMPreferenceConstants.TM_UPDATE);
}
 
Example 18
Source File: TbxImportWizardTbxPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 从首选项中读取导入策略
 * @return ;
 */
public int getTbxImportStrategy() {
	IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
	return ps.getInt(TBPreferenceConstants.TB_UPDATE);
}
 
Example 19
Source File: NewTermDbImportPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 从首选项中读取TBX导入策略
 * @return ;
 */
public int getTbxImportStrategy() {
	IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
	return ps.getInt(TBPreferenceConstants.TB_UPDATE);
}
 
Example 20
Source File: TLCChainedPreferenceStore.java    From tlaplus with MIT License 4 votes vote down vote up
public int getInt(String name) {
	IPreferenceStore visibleStore= getVisibleStore(name);
	if (visibleStore != null)
		return visibleStore.getInt(name);
	return INT_DEFAULT_DEFAULT;
}