📄 myviewerfilter.java
字号:
/* * Copyright 2006 Marcel Schoffelmeer * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.s10r.manager;import com.s10r.manager.model.ItemLabel;import com.s10r.manager.model.ManagerItem;import com.s10r.manager.model.PasswordEntry;import org.eclipse.jface.viewers.Viewer;import org.eclipse.jface.viewers.ViewerFilter;/** * @author schoffem */public class MyViewerFilter extends ViewerFilter{ private String filterText; private ItemLabel filterLabel; @Override public boolean select(Viewer viewer, Object parentElement, Object element) { ManagerItem entry = (ManagerItem) element; // filter on a label if the filter label is set, and either the item // is a label, or is a password entry and the entry does not have // the filter label assigned. boolean filterOnLabel = filterLabel != null && (entry instanceof ItemLabel || (entry instanceof PasswordEntry && !((PasswordEntry) entry) .hasLabel(filterLabel))); // filter on text if the filter text is set and the entry's name // does not match the filter text (partial match) boolean filterOnText = filterText != null && filterText.length() > 0 && !(entry.getName().toLowerCase().indexOf(filterText) >= 0); if (filterOnLabel || filterOnText) { // filter out return false; } else { // select return true; } } /** * @param filter * the filter to set * @uml.property name="filter" */ public void setFilter(String filter) { this.filterText = filter; } public void setFilter(ItemLabel label) { this.filterLabel = label; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -