Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-06-14 04:58:30 -0400
committerUwe Stieber2013-06-14 04:58:30 -0400
commitcdbddf60bf8200bcc9cc67c1cfe065dfe5913600 (patch)
treee8bdc0cb1624af5be714a7c5db66a0d20ca3e41d
parent442a2c185e22c34b4d1d81a58fca716fd79b8346 (diff)
downloadorg.eclipse.tcf-cdbddf60bf8200bcc9cc67c1cfe065dfe5913600.tar.gz
org.eclipse.tcf-cdbddf60bf8200bcc9cc67c1cfe065dfe5913600.tar.xz
org.eclipse.tcf-cdbddf60bf8200bcc9cc67c1cfe065dfe5913600.zip
Target Explorer: Fix find: General options missed "Wrap". Fixed search wrapping.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java602
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java506
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java510
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties324
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/META-INF/MANIFEST.MF98
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java788
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/AbstractSearcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java)182
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/BreadthFirstSearcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java)6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DelegateProgressMonitor.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DelegateProgressMonitor.java)348
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DepthFirstSearcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DepthFirstSearcher.java)22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/FilteringImageDescriptor.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/FilteringImageDescriptor.java)2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilter.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java)2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilterPopup.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java)432
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchEngine.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchEngine.java)446
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchMatcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java)222
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/StringMatcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/StringMatcher.java)986
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TablePatternFilter.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TablePatternFilter.java)2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TreeViewerSearchDialog.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java)88
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java49
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/TreeViewerUtil.java744
34 files changed, 3272 insertions, 3340 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java
index 6d5cebee0..c261bb746 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java
@@ -1,300 +1,302 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
-import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
-
-/**
- * The searchable that provides a UI to collect and test
- * the general operations of a file search.
- */
-public class FSGeneralSearchable extends AbstractSearchable {
- // The keys to access the options stored in the dialog settings.
- private static final String INCLUDE_HIDDEN = "FS.IncludeHidden"; //$NON-NLS-1$
- private static final String INCLUDE_SYSTEM = "FS.IncludeSystem"; //$NON-NLS-1$
- private static final String TARGET_NAME = "FS.TargetName"; //$NON-NLS-1$
- private static final String TARGET_TYPE = "FS.TargetType"; //$NON-NLS-1$
- private static final String MATCH_PRECISE = "FS.MatchPrecise"; //$NON-NLS-1$
- private static final String CASE_SENSITIVE = "FS.CaseSensitive"; //$NON-NLS-1$
- // The check option to define if system files should be searched.
- private Button fBtnSystem;
- // The check option to define if hidden files should be searched.
- private Button fBtnHidden;
- // The case sensitive check box.
- private Button fBtnCase;
- // The matching rule check box.
- private Button fBtnMatch;
- // The input field for searching conditions.
- private BaseEditBrowseTextControl fSearchField;
- // The current target names.
- private String fTargetName;
- // Whether it is case sensitive
- private boolean fCaseSensitive;
- // Whether it is precise matching.
- private boolean fMatchPrecise;
- // The flag if system files should be searched, default to true.
- private boolean fIncludeSystem = true;
- // The flag if hidden files should be searched, default to true.
- private boolean fIncludeHidden = true;
- // The types of target files.
- private Combo fCmbTypes;
- // The current selected target type index.
- private int fTargetType;
- // The root directory node.
- private FSTreeNode rootNode;
-
- /**
- * Constructor
- *
- * @param node the node whose sub tree will be searched.
- */
- public FSGeneralSearchable(FSTreeNode node) {
- rootNode = node;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createCommonPart(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout glayout = new GridLayout(3, false);
- glayout.marginHeight = 0;
- glayout.marginWidth = 0;
- composite.setLayout(glayout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Searching field.
- Label label = new Label(composite, SWT.NONE);
- label.setText(Messages.FSGeneralSearchable_Find);
-
- fSearchField = new BaseEditBrowseTextControl(null);
- fSearchField.setIsGroup(false);
- fSearchField.setHasHistory(false);
- fSearchField.setHideBrowseButton(true);
- fSearchField.setParentControlIsInnerPanel(true);
- fSearchField.setupPanel(composite);
- fSearchField.setEditFieldValidator(new NameValidator());
- //fSearchField.setEditFieldValidator(new FolderValidator(this));
- Text text = (Text) fSearchField.getEditFieldControl();
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- searchTextModified();
- }
- });
-
- SelectionListener l = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- optionChecked(e);
- }
- };
-
- Group group = new Group(parent, SWT.NONE);
- group.setText(Messages.FSGeneralSearchable_GeneralOptionText);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite cmpType = new Composite(group, SWT.NONE);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- cmpType.setLayoutData(data);
- cmpType.setLayout(new GridLayout(2, false));
-
- label = new Label(cmpType, SWT.NONE);
- label.setText(Messages.FSGeneralSearchable_FileType);
-
- // Search files only
- fCmbTypes = new Combo(cmpType, SWT.BORDER | SWT.READ_ONLY);
- fCmbTypes.setItems(new String[]{Messages.FSTreeNodeSearchable_FilesAndFolders, Messages.FSTreeNodeSearchable_FilesOnly, Messages.FSTreeNodeSearchable_FoldersOnly});
- fCmbTypes.setLayoutData(new GridData());
- fCmbTypes.addSelectionListener(l);
-
- Composite compOptions = new Composite(group, SWT.NONE);
- data = new GridData(GridData.FILL_HORIZONTAL);
- compOptions.setLayoutData(data);
- compOptions.setLayout(new GridLayout(2, true));
-
- // Case sensitive
- fBtnCase = new Button(compOptions, SWT.CHECK);
- fBtnCase.setText(Messages.TreeViewerSearchDialog_BtnCaseText);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnCase.setLayoutData(data);
- fBtnCase.addSelectionListener(l);
-
- // Matching precisely
- fBtnMatch = new Button(compOptions, SWT.CHECK);
- fBtnMatch.setText(Messages.TreeViewerSearchDialog_BtnPreciseText);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnMatch.setLayoutData(data);
- fBtnMatch.addSelectionListener(l);
-
- // If the target is Windows platform, then add system/hidden options.
- if(rootNode.isWindowsNode()) {
- fBtnSystem = new Button(compOptions, SWT.CHECK);
- fBtnSystem.setText(Messages.FSGeneralSearchable_SearchSystemFiles);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnSystem.setLayoutData(data);
- fBtnSystem.addSelectionListener(l);
-
- fBtnHidden = new Button(compOptions, SWT.CHECK);
- fBtnHidden.setText(Messages.FSGeneralSearchable_SearchHiddenFiles);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnHidden.setLayoutData(data);
- fBtnHidden.addSelectionListener(l);
- }
- }
-
- /**
- * The text for searching is modified.
- */
- protected void searchTextModified() {
- fireOptionChanged();
- fTargetName = fSearchField.getEditFieldControlText().trim();
- }
-
- /**
- * Handling the event that a button is selected and checked.
- *
- * @param e The selection event.
- */
- protected void optionChecked(SelectionEvent e) {
- Object src = e.getSource();
- if (src == fBtnCase) {
- fCaseSensitive = fBtnCase.getSelection();
- }
- else if (src == fBtnMatch) {
- fMatchPrecise = fBtnMatch.getSelection();
- }
- else if (src == fCmbTypes) {
- fTargetType = fCmbTypes.getSelectionIndex();
- }
- else if (src == fBtnSystem) {
- fIncludeSystem = fBtnSystem.getSelection();
- }
- else if (src == fBtnHidden) {
- fIncludeHidden = fBtnHidden.getSelection();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void restoreValues(IDialogSettings settings) {
- if(settings != null) {
- fCaseSensitive = settings.getBoolean(CASE_SENSITIVE);
- fBtnCase.setSelection(fCaseSensitive);
- fMatchPrecise = settings.getBoolean(MATCH_PRECISE);
- fBtnMatch.setSelection(fMatchPrecise);
- try {
- fTargetType = settings.getInt(TARGET_TYPE);
- fCmbTypes.select(fTargetType);
- }catch(NumberFormatException e) {
- fTargetType = 0;
- }
- fTargetName = settings.get(TARGET_NAME);
- if (fTargetName != null) {
- fSearchField.setEditFieldControlText(fTargetName);
- }
- if (rootNode.isWindowsNode()) {
- fIncludeSystem = settings.get(INCLUDE_SYSTEM) == null ? true : settings.getBoolean(INCLUDE_SYSTEM);
- fIncludeHidden = settings.get(INCLUDE_HIDDEN) == null ? true : settings.getBoolean(INCLUDE_HIDDEN);
- }
- }
- else {
- fCaseSensitive = false;
- fMatchPrecise = false;
- fTargetType = 0;
- fTargetName = null;
- if(rootNode.isWindowsNode()) {
- fIncludeHidden = true;
- fIncludeSystem = true;
- }
- }
- fBtnCase.setSelection(fCaseSensitive);
- fBtnMatch.setSelection(fMatchPrecise);
- fCmbTypes.select(fTargetType);
- if (fTargetName != null) {
- fSearchField.setEditFieldControlText(fTargetName);
- }
- if (rootNode.isWindowsNode()) {
- fBtnSystem.setSelection(fIncludeSystem);
- fBtnHidden.setSelection(fIncludeHidden);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void persistValues(IDialogSettings settings) {
- if(settings != null) {
- settings.put(CASE_SENSITIVE, fCaseSensitive);
- settings.put(MATCH_PRECISE, fMatchPrecise);
- settings.put(TARGET_TYPE, fTargetType);
- settings.put(TARGET_NAME, fTargetName);
- if(rootNode.isWindowsNode()) {
- settings.put(INCLUDE_SYSTEM, fIncludeSystem);
- settings.put(INCLUDE_HIDDEN, fIncludeHidden);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
- */
- @Override
- public ISearchMatcher getMatcher() {
- return new FSTreeNodeMatcher(fCaseSensitive, fMatchPrecise, fTargetType, fTargetName, fIncludeSystem, fIncludeHidden);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- return fSearchField.isValid();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#getPreferredSize()
- */
- @Override
- public Point getPreferredSize() {
- return new Point(400, rootNode.isWindowsNode() ? 200 : 180);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
+import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
+
+/**
+ * The searchable that provides a UI to collect and test
+ * the general operations of a file search.
+ */
+public class FSGeneralSearchable extends AbstractSearchable {
+ // The keys to access the options stored in the dialog settings.
+ private static final String INCLUDE_HIDDEN = "FS.IncludeHidden"; //$NON-NLS-1$
+ private static final String INCLUDE_SYSTEM = "FS.IncludeSystem"; //$NON-NLS-1$
+ private static final String TARGET_NAME = "FS.TargetName"; //$NON-NLS-1$
+ private static final String TARGET_TYPE = "FS.TargetType"; //$NON-NLS-1$
+ private static final String MATCH_PRECISE = "FS.MatchPrecise"; //$NON-NLS-1$
+ private static final String CASE_SENSITIVE = "FS.CaseSensitive"; //$NON-NLS-1$
+ // The check option to define if system files should be searched.
+ private Button fBtnSystem;
+ // The check option to define if hidden files should be searched.
+ private Button fBtnHidden;
+ // The case sensitive check box.
+ private Button fBtnCase;
+ // The matching rule check box.
+ private Button fBtnMatch;
+ // The input field for searching conditions.
+ private BaseEditBrowseTextControl fSearchField;
+ // The current target names.
+ private String fTargetName;
+ // Whether it is case sensitive
+ private boolean fCaseSensitive;
+ // Whether it is precise matching.
+ private boolean fMatchPrecise;
+ // The flag if system files should be searched, default to true.
+ private boolean fIncludeSystem = true;
+ // The flag if hidden files should be searched, default to true.
+ private boolean fIncludeHidden = true;
+ // The types of target files.
+ private Combo fCmbTypes;
+ // The current selected target type index.
+ private int fTargetType;
+ // The root directory node.
+ private FSTreeNode rootNode;
+
+ /**
+ * Constructor
+ *
+ * @param node the node whose sub tree will be searched.
+ */
+ public FSGeneralSearchable(FSTreeNode node) {
+ rootNode = node;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createCommonPart(TreeViewerSearchDialog dialog, Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout(3, false);
+ glayout.marginHeight = 0;
+ glayout.marginWidth = 0;
+ composite.setLayout(glayout);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Searching field.
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.FSGeneralSearchable_Find);
+
+ fSearchField = new BaseEditBrowseTextControl(null);
+ fSearchField.setIsGroup(false);
+ fSearchField.setHasHistory(false);
+ fSearchField.setHideBrowseButton(true);
+ fSearchField.setParentControlIsInnerPanel(true);
+ fSearchField.setupPanel(composite);
+ fSearchField.setEditFieldValidator(new NameValidator());
+ //fSearchField.setEditFieldValidator(new FolderValidator(this));
+ Text text = (Text) fSearchField.getEditFieldControl();
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ searchTextModified();
+ }
+ });
+
+ SelectionListener l = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ optionChecked(e);
+ }
+ };
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(Messages.FSGeneralSearchable_GeneralOptionText);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite cmpType = new Composite(group, SWT.NONE);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ cmpType.setLayoutData(data);
+ cmpType.setLayout(new GridLayout(2, false));
+
+ label = new Label(cmpType, SWT.NONE);
+ label.setText(Messages.FSGeneralSearchable_FileType);
+
+ // Search files only
+ fCmbTypes = new Combo(cmpType, SWT.BORDER | SWT.READ_ONLY);
+ fCmbTypes.setItems(new String[]{Messages.FSTreeNodeSearchable_FilesAndFolders, Messages.FSTreeNodeSearchable_FilesOnly, Messages.FSTreeNodeSearchable_FoldersOnly});
+ fCmbTypes.setLayoutData(new GridData());
+ fCmbTypes.addSelectionListener(l);
+
+ Composite compOptions = new Composite(group, SWT.NONE);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ compOptions.setLayoutData(data);
+ compOptions.setLayout(new GridLayout(3, true));
+
+ // Case sensitive
+ fBtnCase = new Button(compOptions, SWT.CHECK);
+ fBtnCase.setText(Messages.TreeViewerSearchDialog_BtnCaseText);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnCase.setLayoutData(data);
+ fBtnCase.addSelectionListener(l);
+
+ // Matching precisely
+ fBtnMatch = new Button(compOptions, SWT.CHECK);
+ fBtnMatch.setText(Messages.TreeViewerSearchDialog_BtnPreciseText);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnMatch.setLayoutData(data);
+ fBtnMatch.addSelectionListener(l);
+
+ dialog.createSearchDirectionOptions(compOptions);
+
+ // If the target is Windows platform, then add system/hidden options.
+ if(rootNode.isWindowsNode()) {
+ fBtnSystem = new Button(compOptions, SWT.CHECK);
+ fBtnSystem.setText(Messages.FSGeneralSearchable_SearchSystemFiles);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnSystem.setLayoutData(data);
+ fBtnSystem.addSelectionListener(l);
+
+ fBtnHidden = new Button(compOptions, SWT.CHECK);
+ fBtnHidden.setText(Messages.FSGeneralSearchable_SearchHiddenFiles);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnHidden.setLayoutData(data);
+ fBtnHidden.addSelectionListener(l);
+ }
+ }
+
+ /**
+ * The text for searching is modified.
+ */
+ protected void searchTextModified() {
+ fireOptionChanged();
+ fTargetName = fSearchField.getEditFieldControlText().trim();
+ }
+
+ /**
+ * Handling the event that a button is selected and checked.
+ *
+ * @param e The selection event.
+ */
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ if (src == fBtnCase) {
+ fCaseSensitive = fBtnCase.getSelection();
+ }
+ else if (src == fBtnMatch) {
+ fMatchPrecise = fBtnMatch.getSelection();
+ }
+ else if (src == fCmbTypes) {
+ fTargetType = fCmbTypes.getSelectionIndex();
+ }
+ else if (src == fBtnSystem) {
+ fIncludeSystem = fBtnSystem.getSelection();
+ }
+ else if (src == fBtnHidden) {
+ fIncludeHidden = fBtnHidden.getSelection();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void restoreValues(IDialogSettings settings) {
+ if(settings != null) {
+ fCaseSensitive = settings.getBoolean(CASE_SENSITIVE);
+ fBtnCase.setSelection(fCaseSensitive);
+ fMatchPrecise = settings.getBoolean(MATCH_PRECISE);
+ fBtnMatch.setSelection(fMatchPrecise);
+ try {
+ fTargetType = settings.getInt(TARGET_TYPE);
+ fCmbTypes.select(fTargetType);
+ }catch(NumberFormatException e) {
+ fTargetType = 0;
+ }
+ fTargetName = settings.get(TARGET_NAME);
+ if (fTargetName != null) {
+ fSearchField.setEditFieldControlText(fTargetName);
+ }
+ if (rootNode.isWindowsNode()) {
+ fIncludeSystem = settings.get(INCLUDE_SYSTEM) == null ? true : settings.getBoolean(INCLUDE_SYSTEM);
+ fIncludeHidden = settings.get(INCLUDE_HIDDEN) == null ? true : settings.getBoolean(INCLUDE_HIDDEN);
+ }
+ }
+ else {
+ fCaseSensitive = false;
+ fMatchPrecise = false;
+ fTargetType = 0;
+ fTargetName = null;
+ if(rootNode.isWindowsNode()) {
+ fIncludeHidden = true;
+ fIncludeSystem = true;
+ }
+ }
+ fBtnCase.setSelection(fCaseSensitive);
+ fBtnMatch.setSelection(fMatchPrecise);
+ fCmbTypes.select(fTargetType);
+ if (fTargetName != null) {
+ fSearchField.setEditFieldControlText(fTargetName);
+ }
+ if (rootNode.isWindowsNode()) {
+ fBtnSystem.setSelection(fIncludeSystem);
+ fBtnHidden.setSelection(fIncludeHidden);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void persistValues(IDialogSettings settings) {
+ if(settings != null) {
+ settings.put(CASE_SENSITIVE, fCaseSensitive);
+ settings.put(MATCH_PRECISE, fMatchPrecise);
+ settings.put(TARGET_TYPE, fTargetType);
+ settings.put(TARGET_NAME, fTargetName);
+ if(rootNode.isWindowsNode()) {
+ settings.put(INCLUDE_SYSTEM, fIncludeSystem);
+ settings.put(INCLUDE_HIDDEN, fIncludeHidden);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
+ */
+ @Override
+ public ISearchMatcher getMatcher() {
+ return new FSTreeNodeMatcher(fCaseSensitive, fMatchPrecise, fTargetType, fTargetName, fIncludeSystem, fIncludeHidden);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ return fSearchField.isValid();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#getPreferredSize()
+ */
+ @Override
+ public Point getPreferredSize() {
+ return new Point(400, rootNode.isWindowsNode() ? 200 : 180);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java
index 5521339d8..8667ab195 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java
@@ -1,253 +1,253 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-
-/**
- * The searchable that provides a UI to collect and test
- * the last modified time of a file during searching.
- */
-public class FSModifiedSearchable extends FSBaseSearchable {
- // Constant values of last modified options
- private static final int OPTION_NOT_REMEMBER = 0;
- private static final int OPTION_LAST_WEEK = 1;
- private static final int OPTION_LAST_MONTH = 2;
- private static final int OPTION_LAST_YEAR = 3;
- private static final int OPTION_SPECIFIED = 4;
-
- // Constant values of different time unit, used for matching purpose.
- private static final long SECOND = 1000L;
- private static final long MINUTE = 60 * SECOND;
- private static final long HOUR = 60 * MINUTE;
- private static final long DAY = 24 * HOUR;
- private static final long WEEK = 7 * DAY;
- private static final long MONTH = 30 * DAY;
- private static final long YEAR = 365 * DAY;
-
- // The choice selected
- private int choice;
- // The specified "from" date
- private long fromTime;
- // The specified "to" date
- private long toTime;
-
- // UI elements for input
- private Button fBtnLmNotRem;
- private Button fBtnLmLastWeek;
- private Button fBtnLmPastMonth;
- private Button fBtnLmPastYear;
- private Button fBtnLmSpecified;
- private BaseEditBrowseTextControl txtLmFrom;
- private BaseEditBrowseTextControl txtLmTo;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createAdvancedPart(Composite parent) {
- SelectionListener l = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- optionChecked(e);
- }
- };
- Composite modifiedComp = createSection(parent, Messages.FSModifiedSearchable_WhenModified);
- modifiedComp.setLayout(new GridLayout(4, false));
-
- fBtnLmNotRem = new Button(modifiedComp, SWT.RADIO);
- fBtnLmNotRem.setText(Messages.FSModifiedSearchable_DontRemember);
- fBtnLmNotRem.setSelection(true);
- GridData data = new GridData();
- data.horizontalSpan = 4;
- fBtnLmNotRem.setLayoutData(data);
- fBtnLmNotRem.addSelectionListener(l);
-
- fBtnLmLastWeek = new Button(modifiedComp, SWT.RADIO);
- fBtnLmLastWeek.setText(Messages.FSModifiedSearchable_LastWeek);
- data = new GridData();
- data.horizontalSpan = 4;
- fBtnLmLastWeek.setLayoutData(data);
- fBtnLmLastWeek.addSelectionListener(l);
-
- fBtnLmPastMonth = new Button(modifiedComp, SWT.RADIO);
- fBtnLmPastMonth.setText(Messages.FSModifiedSearchable_PastMonth);
- data = new GridData();
- data.horizontalSpan = 4;
- fBtnLmPastMonth.setLayoutData(data);
- fBtnLmPastMonth.addSelectionListener(l);
-
- fBtnLmPastYear = new Button(modifiedComp, SWT.RADIO);
- fBtnLmPastYear.setText(Messages.FSModifiedSearchable_PastYear);
- data = new GridData();
- data.horizontalSpan = 4;
- fBtnLmPastYear.setLayoutData(data);
- fBtnLmPastYear.addSelectionListener(l);
-
- fBtnLmSpecified = new Button(modifiedComp, SWT.RADIO);
- fBtnLmSpecified.setText(Messages.FSModifiedSearchable_SpecifyDates);
- data = new GridData();
- fBtnLmSpecified.setLayoutData(data);
- fBtnLmSpecified.addSelectionListener(l);
-
- Composite cmpFrom = new Composite(modifiedComp, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- cmpFrom.setLayout(layout);
- data = new GridData();
- cmpFrom.setLayoutData(data);
-
- txtLmFrom = new BaseEditBrowseTextControl(null);
- txtLmFrom.setIsGroup(false);
- txtLmFrom.setHasHistory(false);
- txtLmFrom.setHideBrowseButton(true);
- txtLmFrom.setParentControlIsInnerPanel(true);
- txtLmFrom.setupPanel(cmpFrom);
- txtLmFrom.setEnabled(false);
- txtLmFrom.setEditFieldValidator(new DateValidator());
- Text text = (Text) txtLmFrom.getEditFieldControl();
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- datesModified();
- }
- });
-
- Label label = new Label(modifiedComp, SWT.NONE);
- label.setText(Messages.FSModifiedSearchable_ToDate);
-
- Composite cmpTo = new Composite(modifiedComp, SWT.NONE);
- layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- cmpTo.setLayout(layout);
- data = new GridData();
- cmpTo.setLayoutData(data);
-
- txtLmTo = new BaseEditBrowseTextControl(null);
- txtLmTo.setIsGroup(false);
- txtLmTo.setHasHistory(false);
- txtLmTo.setHideBrowseButton(true);
- txtLmTo.setParentControlIsInnerPanel(true);
- txtLmTo.setupPanel(cmpTo);
- txtLmTo.setEnabled(false);
- txtLmTo.setEditFieldValidator(new DateValidator());
- text = (Text) txtLmTo.getEditFieldControl();
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- datesModified();
- }
- });
- }
-
- /**
- * The modified event of the date fields.
- */
- protected void datesModified() {
- fireOptionChanged();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- if(choice == OPTION_SPECIFIED && txtLmFrom != null && txtLmTo != null) {
- boolean vFrom = txtLmFrom.isValid();
- boolean vTo = txtLmTo.isValid();
- if(vFrom) {
- String fromText = txtLmFrom.getEditFieldControlText().trim();
- this.fromTime = DateValidator.parseTimeInMillis(fromText);
- }
- if(vTo) {
- String toText = txtLmTo.getEditFieldControlText().trim();
- this.toTime = DateValidator.parseTimeInMillis(toText);
- }
- return vFrom && vTo;
- }
- return true;
- }
-
- /**
- * The method handling the selection event.
- *
- * @param e The selection event.
- */
- protected void optionChecked(SelectionEvent e) {
- Object src = e.getSource();
- boolean specified = false;
- if(src == fBtnLmNotRem) {
- choice = OPTION_NOT_REMEMBER;
- }
- else if(src == fBtnLmLastWeek) {
- choice = OPTION_LAST_WEEK;
- }
- else if(src == fBtnLmPastMonth) {
- choice = OPTION_LAST_MONTH;
- }
- else if(src == fBtnLmPastYear) {
- choice = OPTION_LAST_YEAR;
- }
- else if(src == fBtnLmSpecified) {
- choice = OPTION_SPECIFIED;
- specified = true;
- }
- if (txtLmFrom != null) txtLmFrom.setEnabled(specified);
- if (txtLmTo != null) txtLmTo.setEnabled(specified);
- fireOptionChanged();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
- */
- @Override
- public boolean match(Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- long now = System.currentTimeMillis();
- switch (choice) {
- case OPTION_NOT_REMEMBER:
- return true;
- case OPTION_LAST_WEEK:
- return node.attr.mtime > now - WEEK;
- case OPTION_LAST_MONTH:
- return node.attr.mtime > now - MONTH;
- case OPTION_LAST_YEAR:
- return node.attr.mtime > now - YEAR;
- case OPTION_SPECIFIED:
- return node.attr.mtime >= fromTime && node.attr.mtime < toTime;
- }
- }
- return false;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
+
+/**
+ * The searchable that provides a UI to collect and test
+ * the last modified time of a file during searching.
+ */
+public class FSModifiedSearchable extends FSBaseSearchable {
+ // Constant values of last modified options
+ private static final int OPTION_NOT_REMEMBER = 0;
+ private static final int OPTION_LAST_WEEK = 1;
+ private static final int OPTION_LAST_MONTH = 2;
+ private static final int OPTION_LAST_YEAR = 3;
+ private static final int OPTION_SPECIFIED = 4;
+
+ // Constant values of different time unit, used for matching purpose.
+ private static final long SECOND = 1000L;
+ private static final long MINUTE = 60 * SECOND;
+ private static final long HOUR = 60 * MINUTE;
+ private static final long DAY = 24 * HOUR;
+ private static final long WEEK = 7 * DAY;
+ private static final long MONTH = 30 * DAY;
+ private static final long YEAR = 365 * DAY;
+
+ // The choice selected
+ private int choice;
+ // The specified "from" date
+ private long fromTime;
+ // The specified "to" date
+ private long toTime;
+
+ // UI elements for input
+ private Button fBtnLmNotRem;
+ private Button fBtnLmLastWeek;
+ private Button fBtnLmPastMonth;
+ private Button fBtnLmPastYear;
+ private Button fBtnLmSpecified;
+ private BaseEditBrowseTextControl txtLmFrom;
+ private BaseEditBrowseTextControl txtLmTo;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
+ SelectionListener l = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ optionChecked(e);
+ }
+ };
+ Composite modifiedComp = createSection(parent, Messages.FSModifiedSearchable_WhenModified);
+ modifiedComp.setLayout(new GridLayout(4, false));
+
+ fBtnLmNotRem = new Button(modifiedComp, SWT.RADIO);
+ fBtnLmNotRem.setText(Messages.FSModifiedSearchable_DontRemember);
+ fBtnLmNotRem.setSelection(true);
+ GridData data = new GridData();
+ data.horizontalSpan = 4;
+ fBtnLmNotRem.setLayoutData(data);
+ fBtnLmNotRem.addSelectionListener(l);
+
+ fBtnLmLastWeek = new Button(modifiedComp, SWT.RADIO);
+ fBtnLmLastWeek.setText(Messages.FSModifiedSearchable_LastWeek);
+ data = new GridData();
+ data.horizontalSpan = 4;
+ fBtnLmLastWeek.setLayoutData(data);
+ fBtnLmLastWeek.addSelectionListener(l);
+
+ fBtnLmPastMonth = new Button(modifiedComp, SWT.RADIO);
+ fBtnLmPastMonth.setText(Messages.FSModifiedSearchable_PastMonth);
+ data = new GridData();
+ data.horizontalSpan = 4;
+ fBtnLmPastMonth.setLayoutData(data);
+ fBtnLmPastMonth.addSelectionListener(l);
+
+ fBtnLmPastYear = new Button(modifiedComp, SWT.RADIO);
+ fBtnLmPastYear.setText(Messages.FSModifiedSearchable_PastYear);
+ data = new GridData();
+ data.horizontalSpan = 4;
+ fBtnLmPastYear.setLayoutData(data);
+ fBtnLmPastYear.addSelectionListener(l);
+
+ fBtnLmSpecified = new Button(modifiedComp, SWT.RADIO);
+ fBtnLmSpecified.setText(Messages.FSModifiedSearchable_SpecifyDates);
+ data = new GridData();
+ fBtnLmSpecified.setLayoutData(data);
+ fBtnLmSpecified.addSelectionListener(l);
+
+ Composite cmpFrom = new Composite(modifiedComp, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ cmpFrom.setLayout(layout);
+ data = new GridData();
+ cmpFrom.setLayoutData(data);
+
+ txtLmFrom = new BaseEditBrowseTextControl(null);
+ txtLmFrom.setIsGroup(false);
+ txtLmFrom.setHasHistory(false);
+ txtLmFrom.setHideBrowseButton(true);
+ txtLmFrom.setParentControlIsInnerPanel(true);
+ txtLmFrom.setupPanel(cmpFrom);
+ txtLmFrom.setEnabled(false);
+ txtLmFrom.setEditFieldValidator(new DateValidator());
+ Text text = (Text) txtLmFrom.getEditFieldControl();
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ datesModified();
+ }
+ });
+
+ Label label = new Label(modifiedComp, SWT.NONE);
+ label.setText(Messages.FSModifiedSearchable_ToDate);
+
+ Composite cmpTo = new Composite(modifiedComp, SWT.NONE);
+ layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ cmpTo.setLayout(layout);
+ data = new GridData();
+ cmpTo.setLayoutData(data);
+
+ txtLmTo = new BaseEditBrowseTextControl(null);
+ txtLmTo.setIsGroup(false);
+ txtLmTo.setHasHistory(false);
+ txtLmTo.setHideBrowseButton(true);
+ txtLmTo.setParentControlIsInnerPanel(true);
+ txtLmTo.setupPanel(cmpTo);
+ txtLmTo.setEnabled(false);
+ txtLmTo.setEditFieldValidator(new DateValidator());
+ text = (Text) txtLmTo.getEditFieldControl();
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ datesModified();
+ }
+ });
+ }
+
+ /**
+ * The modified event of the date fields.
+ */
+ protected void datesModified() {
+ fireOptionChanged();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ if(choice == OPTION_SPECIFIED && txtLmFrom != null && txtLmTo != null) {
+ boolean vFrom = txtLmFrom.isValid();
+ boolean vTo = txtLmTo.isValid();
+ if(vFrom) {
+ String fromText = txtLmFrom.getEditFieldControlText().trim();
+ this.fromTime = DateValidator.parseTimeInMillis(fromText);
+ }
+ if(vTo) {
+ String toText = txtLmTo.getEditFieldControlText().trim();
+ this.toTime = DateValidator.parseTimeInMillis(toText);
+ }
+ return vFrom && vTo;
+ }
+ return true;
+ }
+
+ /**
+ * The method handling the selection event.
+ *
+ * @param e The selection event.
+ */
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ boolean specified = false;
+ if(src == fBtnLmNotRem) {
+ choice = OPTION_NOT_REMEMBER;
+ }
+ else if(src == fBtnLmLastWeek) {
+ choice = OPTION_LAST_WEEK;
+ }
+ else if(src == fBtnLmPastMonth) {
+ choice = OPTION_LAST_MONTH;
+ }
+ else if(src == fBtnLmPastYear) {
+ choice = OPTION_LAST_YEAR;
+ }
+ else if(src == fBtnLmSpecified) {
+ choice = OPTION_SPECIFIED;
+ specified = true;
+ }
+ if (txtLmFrom != null) txtLmFrom.setEnabled(specified);
+ if (txtLmTo != null) txtLmTo.setEnabled(specified);
+ fireOptionChanged();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
+ */
+ @Override
+ public boolean match(Object element) {
+ if (element instanceof FSTreeNode) {
+ FSTreeNode node = (FSTreeNode) element;
+ long now = System.currentTimeMillis();
+ switch (choice) {
+ case OPTION_NOT_REMEMBER:
+ return true;
+ case OPTION_LAST_WEEK:
+ return node.attr.mtime > now - WEEK;
+ case OPTION_LAST_MONTH:
+ return node.attr.mtime > now - MONTH;
+ case OPTION_LAST_YEAR:
+ return node.attr.mtime > now - YEAR;
+ case OPTION_SPECIFIED:
+ return node.attr.mtime >= fromTime && node.attr.mtime < toTime;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java
index 6173d53d7..01abb34cb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java
@@ -1,255 +1,255 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-
-/**
- * The searchable that provides a UI to collect and test
- * the size of a file during searching.
- */
-public class FSSizeSearchable extends FSBaseSearchable {
- // Constant values of size options
- private static final int OPTION_NOT_REMEMBER = 0;
- private static final int OPTION_SIZE_SMALL = 1;
- private static final int OPTION_SIZE_MEDIUM = 2;
- private static final int OPTION_SIZE_LARGE = 3;
- private static final int OPTION_SIZE_SPECIFIED = 4;
-
- // Constant values of different size unit, used for matching purpose.
- private static final long KB = 1024;
- private static final long MB = 1024 * KB;
-
- private static final long SIZE_SMALL = 100 * KB;
- private static final long SIZE_MEDIUM = 1*MB;
-
- // The choice selected
- private int choice;
- // The lower bound of size
- private int lowerSize;
- // The upper bound of size
- private int upperSize;
-
- // UI elements for input
- private Button fBtnSizeNotRem;
- private Button fBtnSizeSmall;
- private Button fBtnSizeMedium;
- private Button fBtnSizeLarge;
- private Button fBtnSizeSpecified;
- private BaseEditBrowseTextControl txtSizeFrom;
- private BaseEditBrowseTextControl txtSizeTo;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createAdvancedPart(Composite parent) {
- SelectionListener l = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- optionChecked(e);
- }
- };
-
- Composite sizeComp = createSection(parent, Messages.FSSizeSearchable_WhatSize);
- sizeComp.setLayout(new GridLayout(5, false));
-
- fBtnSizeNotRem = new Button(sizeComp, SWT.RADIO);
- fBtnSizeNotRem.setText(Messages.FSSizeSearchable_DontRemember);
- fBtnSizeNotRem.setSelection(true);
- GridData data = new GridData();
- data.horizontalSpan = 5;
- fBtnSizeNotRem.setLayoutData(data);
- fBtnSizeNotRem.addSelectionListener(l);
-
- fBtnSizeSmall = new Button(sizeComp, SWT.RADIO);
- fBtnSizeSmall.setText(Messages.FSSizeSearchable_Small);
- data = new GridData();
- data.horizontalSpan = 5;
- fBtnSizeSmall.setLayoutData(data);
- fBtnSizeSmall.addSelectionListener(l);
-
- fBtnSizeMedium = new Button(sizeComp, SWT.RADIO);
- fBtnSizeMedium.setText(Messages.FSSizeSearchable_Medium);
- data = new GridData();
- data.horizontalSpan = 5;
- fBtnSizeMedium.setLayoutData(data);
- fBtnSizeMedium.addSelectionListener(l);
-
- fBtnSizeLarge = new Button(sizeComp, SWT.RADIO);
- fBtnSizeLarge.setText(Messages.FSSizeSearchable_Large);
- data = new GridData();
- data.horizontalSpan = 5;
- fBtnSizeLarge.setLayoutData(data);
- fBtnSizeLarge.addSelectionListener(l);
-
- fBtnSizeSpecified = new Button(sizeComp, SWT.RADIO);
- fBtnSizeSpecified.setText(Messages.FSSizeSearchable_SpecifySize);
- data = new GridData();
- fBtnSizeSpecified.setLayoutData(data);
- fBtnSizeSpecified.addSelectionListener(l);
-
- Composite cmpFrom = new Composite(sizeComp, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- cmpFrom.setLayout(layout);
- data = new GridData();
- cmpFrom.setLayoutData(data);
-
- txtSizeFrom = new BaseEditBrowseTextControl(null);
- txtSizeFrom.setIsGroup(false);
- txtSizeFrom.setHasHistory(false);
- txtSizeFrom.setHideBrowseButton(true);
- txtSizeFrom.setParentControlIsInnerPanel(true);
- txtSizeFrom.setupPanel(cmpFrom);
- txtSizeFrom.setEnabled(false);
- txtSizeFrom.setEditFieldValidator(new SizeValidator());
- Text text = (Text) txtSizeFrom.getEditFieldControl();
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- sizeModified();
- }
- });
-
-
- Label label = new Label(sizeComp, SWT.NONE);
- label.setText(Messages.FSSizeSearchable_ToText);
-
- Composite cmpTo = new Composite(sizeComp, SWT.NONE);
- layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- cmpTo.setLayout(layout);
- data = new GridData();
- cmpTo.setLayoutData(data);
-
- txtSizeTo = new BaseEditBrowseTextControl(null);
- txtSizeTo.setIsGroup(false);
- txtSizeTo.setHasHistory(false);
- txtSizeTo.setHideBrowseButton(true);
- txtSizeTo.setParentControlIsInnerPanel(true);
- txtSizeTo.setupPanel(cmpTo);
- txtSizeTo.setEnabled(false);
- txtSizeTo.setEditFieldValidator(new SizeValidator());
- text = (Text) txtSizeTo.getEditFieldControl();
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- sizeModified();
- }
- });
-
- label = new Label(sizeComp, SWT.NONE);
- label.setText(Messages.FSSizeSearchable_KBS);
- }
-
- /**
- * The modified event of the size fields.
- */
- protected void sizeModified() {
- fireOptionChanged();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- if(choice == OPTION_SIZE_SPECIFIED && txtSizeFrom != null && txtSizeTo != null) {
- boolean vFrom = txtSizeFrom.isValid();
- boolean vTo = txtSizeTo.isValid();
- if(vFrom) {
- String fromText = txtSizeFrom.getEditFieldControlText();
- this.lowerSize = Integer.parseInt(fromText);
- }
- if(vTo) {
- String toText = txtSizeTo.getEditFieldControlText();
- this.upperSize = Integer.parseInt(toText);
- }
- return vFrom && vTo;
- }
- return true;
- }
-
- /**
- * The method handling the selection event.
- *
- * @param e The selection event.
- */
- protected void optionChecked(SelectionEvent e) {
- Object src = e.getSource();
- boolean specified = false;
- if(src == fBtnSizeNotRem) {
- choice = OPTION_NOT_REMEMBER;
- }
- else if(src == fBtnSizeSmall) {
- choice = OPTION_SIZE_SMALL;
- }
- else if(src == fBtnSizeMedium) {
- choice = OPTION_SIZE_MEDIUM;
- }
- else if(src == fBtnSizeLarge) {
- choice = OPTION_SIZE_LARGE;
- }
- else if(src == fBtnSizeSpecified) {
- choice = OPTION_SIZE_SPECIFIED;
- specified = true;
- }
- if (txtSizeFrom != null) txtSizeFrom.setEnabled(specified);
- if (txtSizeTo != null) txtSizeTo.setEnabled(specified);
- fireOptionChanged();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
- */
- @Override
- public boolean match(Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- switch (choice) {
- case OPTION_NOT_REMEMBER:
- return true;
- case OPTION_SIZE_SMALL:
- return node.attr.size <= SIZE_SMALL;
- case OPTION_SIZE_MEDIUM:
- return node.attr.size <= SIZE_MEDIUM;
- case OPTION_SIZE_LARGE:
- return node.attr.size > SIZE_MEDIUM;
- case OPTION_SIZE_SPECIFIED:
- return node.attr.size >= lowerSize && node.attr.size < upperSize;
- }
- }
- return false;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
+
+/**
+ * The searchable that provides a UI to collect and test
+ * the size of a file during searching.
+ */
+public class FSSizeSearchable extends FSBaseSearchable {
+ // Constant values of size options
+ private static final int OPTION_NOT_REMEMBER = 0;
+ private static final int OPTION_SIZE_SMALL = 1;
+ private static final int OPTION_SIZE_MEDIUM = 2;
+ private static final int OPTION_SIZE_LARGE = 3;
+ private static final int OPTION_SIZE_SPECIFIED = 4;
+
+ // Constant values of different size unit, used for matching purpose.
+ private static final long KB = 1024;
+ private static final long MB = 1024 * KB;
+
+ private static final long SIZE_SMALL = 100 * KB;
+ private static final long SIZE_MEDIUM = 1*MB;
+
+ // The choice selected
+ private int choice;
+ // The lower bound of size
+ private int lowerSize;
+ // The upper bound of size
+ private int upperSize;
+
+ // UI elements for input
+ private Button fBtnSizeNotRem;
+ private Button fBtnSizeSmall;
+ private Button fBtnSizeMedium;
+ private Button fBtnSizeLarge;
+ private Button fBtnSizeSpecified;
+ private BaseEditBrowseTextControl txtSizeFrom;
+ private BaseEditBrowseTextControl txtSizeTo;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
+ SelectionListener l = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ optionChecked(e);
+ }
+ };
+
+ Composite sizeComp = createSection(parent, Messages.FSSizeSearchable_WhatSize);
+ sizeComp.setLayout(new GridLayout(5, false));
+
+ fBtnSizeNotRem = new Button(sizeComp, SWT.RADIO);
+ fBtnSizeNotRem.setText(Messages.FSSizeSearchable_DontRemember);
+ fBtnSizeNotRem.setSelection(true);
+ GridData data = new GridData();
+ data.horizontalSpan = 5;
+ fBtnSizeNotRem.setLayoutData(data);
+ fBtnSizeNotRem.addSelectionListener(l);
+
+ fBtnSizeSmall = new Button(sizeComp, SWT.RADIO);
+ fBtnSizeSmall.setText(Messages.FSSizeSearchable_Small);
+ data = new GridData();
+ data.horizontalSpan = 5;
+ fBtnSizeSmall.setLayoutData(data);
+ fBtnSizeSmall.addSelectionListener(l);
+
+ fBtnSizeMedium = new Button(sizeComp, SWT.RADIO);
+ fBtnSizeMedium.setText(Messages.FSSizeSearchable_Medium);
+ data = new GridData();
+ data.horizontalSpan = 5;
+ fBtnSizeMedium.setLayoutData(data);
+ fBtnSizeMedium.addSelectionListener(l);
+
+ fBtnSizeLarge = new Button(sizeComp, SWT.RADIO);
+ fBtnSizeLarge.setText(Messages.FSSizeSearchable_Large);
+ data = new GridData();
+ data.horizontalSpan = 5;
+ fBtnSizeLarge.setLayoutData(data);
+ fBtnSizeLarge.addSelectionListener(l);
+
+ fBtnSizeSpecified = new Button(sizeComp, SWT.RADIO);
+ fBtnSizeSpecified.setText(Messages.FSSizeSearchable_SpecifySize);
+ data = new GridData();
+ fBtnSizeSpecified.setLayoutData(data);
+ fBtnSizeSpecified.addSelectionListener(l);
+
+ Composite cmpFrom = new Composite(sizeComp, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ cmpFrom.setLayout(layout);
+ data = new GridData();
+ cmpFrom.setLayoutData(data);
+
+ txtSizeFrom = new BaseEditBrowseTextControl(null);
+ txtSizeFrom.setIsGroup(false);
+ txtSizeFrom.setHasHistory(false);
+ txtSizeFrom.setHideBrowseButton(true);
+ txtSizeFrom.setParentControlIsInnerPanel(true);
+ txtSizeFrom.setupPanel(cmpFrom);
+ txtSizeFrom.setEnabled(false);
+ txtSizeFrom.setEditFieldValidator(new SizeValidator());
+ Text text = (Text) txtSizeFrom.getEditFieldControl();
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ sizeModified();
+ }
+ });
+
+
+ Label label = new Label(sizeComp, SWT.NONE);
+ label.setText(Messages.FSSizeSearchable_ToText);
+
+ Composite cmpTo = new Composite(sizeComp, SWT.NONE);
+ layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ cmpTo.setLayout(layout);
+ data = new GridData();
+ cmpTo.setLayoutData(data);
+
+ txtSizeTo = new BaseEditBrowseTextControl(null);
+ txtSizeTo.setIsGroup(false);
+ txtSizeTo.setHasHistory(false);
+ txtSizeTo.setHideBrowseButton(true);
+ txtSizeTo.setParentControlIsInnerPanel(true);
+ txtSizeTo.setupPanel(cmpTo);
+ txtSizeTo.setEnabled(false);
+ txtSizeTo.setEditFieldValidator(new SizeValidator());
+ text = (Text) txtSizeTo.getEditFieldControl();
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ sizeModified();
+ }
+ });
+
+ label = new Label(sizeComp, SWT.NONE);
+ label.setText(Messages.FSSizeSearchable_KBS);
+ }
+
+ /**
+ * The modified event of the size fields.
+ */
+ protected void sizeModified() {
+ fireOptionChanged();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ if(choice == OPTION_SIZE_SPECIFIED && txtSizeFrom != null && txtSizeTo != null) {
+ boolean vFrom = txtSizeFrom.isValid();
+ boolean vTo = txtSizeTo.isValid();
+ if(vFrom) {
+ String fromText = txtSizeFrom.getEditFieldControlText();
+ this.lowerSize = Integer.parseInt(fromText);
+ }
+ if(vTo) {
+ String toText = txtSizeTo.getEditFieldControlText();
+ this.upperSize = Integer.parseInt(toText);
+ }
+ return vFrom && vTo;
+ }
+ return true;
+ }
+
+ /**
+ * The method handling the selection event.
+ *
+ * @param e The selection event.
+ */
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ boolean specified = false;
+ if(src == fBtnSizeNotRem) {
+ choice = OPTION_NOT_REMEMBER;
+ }
+ else if(src == fBtnSizeSmall) {
+ choice = OPTION_SIZE_SMALL;
+ }
+ else if(src == fBtnSizeMedium) {
+ choice = OPTION_SIZE_MEDIUM;
+ }
+ else if(src == fBtnSizeLarge) {
+ choice = OPTION_SIZE_LARGE;
+ }
+ else if(src == fBtnSizeSpecified) {
+ choice = OPTION_SIZE_SPECIFIED;
+ specified = true;
+ }
+ if (txtSizeFrom != null) txtSizeFrom.setEnabled(specified);
+ if (txtSizeTo != null) txtSizeTo.setEnabled(specified);
+ fireOptionChanged();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
+ */
+ @Override
+ public boolean match(Object element) {
+ if (element instanceof FSTreeNode) {
+ FSTreeNode node = (FSTreeNode) element;
+ switch (choice) {
+ case OPTION_NOT_REMEMBER:
+ return true;
+ case OPTION_SIZE_SMALL:
+ return node.attr.size <= SIZE_SMALL;
+ case OPTION_SIZE_MEDIUM:
+ return node.attr.size <= SIZE_MEDIUM;
+ case OPTION_SIZE_LARGE:
+ return node.attr.size > SIZE_MEDIUM;
+ case OPTION_SIZE_SPECIFIED:
+ return node.attr.size >= lowerSize && node.attr.size < upperSize;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
index eb451aebf..79b9b0fba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
@@ -69,12 +69,19 @@ public class FSTreeNodeSearchable extends CompositeSearchable {
return rootNode.name;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
*/
@Override
public String getElementText(Object element) {
return getElementName(element);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getCustomMessage(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public String getCustomMessage(Object rootElement, String key) {
+ return null;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties
index 1ed28fe9d..d112de073 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties
@@ -1,162 +1,162 @@
-###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
-# This program and the accompanying materials are made available under the terms
-# of the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Wind River Systems - initial API and implementation
-###############################################################################
-FSFolderSelectionDialog_MoveDialogMessage=Choose destination for the files to be moved:
-FSFolderSelectionDialog_MoveDialogTitle=Move Files and Folders
-FSOpenFileDialog_message=Please select an image file for the process.
-FSOpenFileDialog_title=Select Process Image
-FSDelete_ConfirmDelete=Confirm Delete
-FSDelete_ConfirmMessage=Are you sure you want to remove the read-only file ''{0}''?
-FSDelete_ButtonCancel=Cancel
-FSDelete_ButtonNo=&No
-FSDelete_ButtonYes=&Yes
-FSDelete_ButtonYes2All=Yes to &All
-DateValidator_DateInvalidNumber=The date is not a valid number.
-DateValidator_DateOutofRange=The date is a number between 1 and 31.
-DateValidator_InfoFormat=The format of the date is MM/DD/YYYY
-DateValidator_InfoPrompt=Please enter a date.
-DateValidator_InvalidDate=The date entered is not a valid date\!
-DateValidator_MonthInvalidNumber=The month is not a valid number.
-DateValidator_MonthOutofRange=The month is a number between 1 and 12.
-DateValidator_YearInvalidNumber=The year is not a valid number.
-DateValidator_YearOutofRange=The year is a number which is bigger than zero.
-DeleteFilesHandler_ConfirmDialogTitle=Confirm Delete
-DeleteFilesHandler_DeleteMultipleFilesConfirmation=Are you sure you want to delete these {0} files/folders?
-DeleteFilesHandler_DeleteOneFileConfirmation=Are you sure you want to delete ''{0}''?
-FSRenamingAssistant_NameAlreadyExists=A file/folder with the name you specified already exists\! Specify a different name.
-FSRenamingAssistant_SpecifyNonEmptyName=Specify a non-empty name.
-FSRenamingAssistant_UnixIllegalCharacters=File or folder name cannot contain any of the following characters:\n/
-FSRenamingAssistant_WinIllegalCharacters=File or folder name cannot contain any of the following characters:\n\\/:*?<>|
-LocalTypedElement_SavingFile=Saving file: {0}
-MergeEditorInput_LocalFile=Local: {0}
-MergeEditorInput_RemoteFile=Remote: {0}
-MergeEditorInput_CompareLeftAndRight=Compare {0} and {1}
-MergeEditorInput_CompareWithLocalCache=Compare {0} with Local Cache
-MergeInput_CopyNotSupported=Copy is not support by this type of compare input
-RemoteTypedElement_GettingRemoteContent=Getting content from the remote file:
-RemoteTypedElement_DowloadingFile=Downloading file {0}...
-FSDropTargetListener_ConfirmMoveTitle=Confirm Move
-FSDropTargetListener_MovingWarningMultiple=This operation will delete the files after moving. You can copy them without deletion by CTRL + dragging. \n\nAre you sure you want to move these {0} files/folders?
-FSDropTargetListener_MovingWarningSingle=This operation will delete the file after moving. You can copy it without deletion by CTRL + dragging. \n\nAre you sure you want to move ''{0}''?
-FSExplorerEditorPage_PageTitle=File System Explorer
-FSGeneralSearchable_FileType=Select type of file
-FSGeneralSearchable_Find=Find:
-FSGeneralSearchable_GeneralOptionText=General search options
-FSGeneralSearchable_SearchHiddenFiles=Search hidden files/folders
-FSGeneralSearchable_SearchSystemFiles=Search system files/folders
-FSModifiedSearchable_DontRemember=Don't remember
-FSModifiedSearchable_LastWeek=Within the last week
-FSModifiedSearchable_PastMonth=Past month
-FSModifiedSearchable_PastYear=Within the past year
-FSModifiedSearchable_SpecifyDates=Specify dates, from
-FSModifiedSearchable_ToDate=to
-FSModifiedSearchable_WhenModified=When was it modified?
-FSUpload_Cancel=Cancel
-FSUpload_No=No
-FSUpload_OverwriteConfirmation=A file with a same name already exists. Are you sure to overwrite {0}?
-FSUpload_OverwriteTitle=Confirm Overwrite
-FSUpload_Yes=Yes
-FSUpload_YesToAll=Yes to All
-FSOperation_ConfirmDialogCancel=Cancel
-FSOperation_ConfirmDialogNo=&No
-FSOperation_ConfirmDialogYes=&Yes
-FSOperation_ConfirmDialogYesToAll=Yes to &All
-FSOperation_ConfirmFileReplace=Confirm File Replace
-FSOperation_ConfirmFileReplaceMessage=This folder already contains a file named {0}.\n\n If the files in the existing folder have the same name as files in the folder you are moving or copying, they will be replaced. Do you still want to move or copy the file?
-FSOperation_ConfirmFolderReplaceMessage=This folder already contains a folder named {0}.\n\n If the files in the existing folder have the same name as files in the folder you are moving or copying, they will be replaced. Do you still want to move or copy the folder?
-FSOperation_ConfirmFolderReplaceTitle=Confirm Folder Replace
-OpenFileHandler_OpeningBinaryNotSupported=Opening a binary file is not supported yet.
-OpenFileHandler_Warning=Warning
-OpenWithMenu_ChooseEditorForOpening=Choose the editor for opening {0}
-OpenWithMenu_DefaultEditor=&Default Editor
-OpenWithMenu_NoEditorFound=No editor found to edit the file resource.
-OpenWithMenu_OpenWith=Open With
-FSRename_RenameFileFolderTitle=Error Renaming File or Folder
-FSSizeSearchable_DontRemember=Don't remember
-FSSizeSearchable_KBS=KB(s)
-FSSizeSearchable_Large=Large (more than 1 MB)
-FSSizeSearchable_Medium=Medium (less than 1 MB)
-FSSizeSearchable_Small=Small (less than 100 KB)
-FSSizeSearchable_SpecifySize=Specify size, from
-FSSizeSearchable_ToText=KB(s) to
-FSSizeSearchable_WhatSize=What size is it?
-FSTreeNodeSearchable_FilesAndFolders=both files and folders
-FSTreeNodeSearchable_FilesOnly=files only
-FSTreeNodeSearchable_FindFilesAndFolders=Find Files
-FSTreeNodeSearchable_FindMessage=Find files and folders under {0}.\nWarning: subsidiary files and folders will be loaded and searched.
-FSTreeNodeSearchable_FoldersOnly=folders only
-FSTreeNodeSearchable_SearchingTargets=Find in
-FSTreeNodeSearchable_SelectedFileSystem=the selected file system
-RenameFilesHandler_TitleRename=Rename
-RenameFilesHandler_TitleRenameFile=Rename File
-RenameFilesHandler_TitleRenameFolder=Rename Folder
-RenameFilesHandler_PromptNewName=New name:
-RenameFilesHandler_RenamePromptMessage=Please enter a new name
-PreferencePage_AutoSavingText=Automatically upload files to targets upon saving
-PreferencePage_CopyOwnershipText=Copy source UID and GID when copying files
-PreferencePage_CopyPermissionText=Copy source permissions when copying files
-PreferencePage_PersistExpanded=Remember expanded directories
-PreferencePage_RenamingOptionText=Use In-place Editor when renaming a file/folder
-AdvancedAttributesDialog_FileBanner=Choose the options you want for this file.
-AdvancedAttributesDialog_FolderBanner=Choose the settings you want for this folder.\n\nWhen you apply these changes you will be asked if you want the\n changes to affect all subfolders and files as well.
-AdvancedAttributesDialog_CompressEncrypt=Compress or Encrypt attributes
-AdvancedAttributesDialog_ArchiveIndex=Archive and Index attributes
-AdvancedAttributesDialog_IndexFile=For fast searching, allow Indexing Service to index this file
-AdvancedAttributesDialog_IndexFolder=For fast searching, allow Indexing Service to index this folder
-AdvancedAttributesDialog_FileArchive=File is ready for archiving
-AdvancedAttributesDialog_FolderArchive=Folder is ready for archiving
-AdvancedAttributesDialog_Encrypt=Encrypt contents to secure data
-AdvancedAttributesDialog_Compress=Compress contents to save disk space
-AdvancedAttributesDialog_ShellTitle=Advanced Attributes
-GeneralInformationPage_Accessed=Accessed:
-GeneralInformationPage_Advanced=\ A&dvanced...
-GeneralInformationPage_Attributes=Attributes:
-GeneralInformationPage_FileSizeInfo={0} KB ({1} bytes)
-GeneralInformationPage_Hidden=Hidden
-GeneralInformationPage_ReadOnly=Read-only
-GeneralInformationPage_Computer=computer
-GeneralInformationPage_Location=Location:
-GeneralInformationPage_Modified=Modified:
-GeneralInformationPage_Name=Name:
-GeneralInformationPage_Size=Size:
-GeneralInformationPage_Type=Type:
-GeneralInformationPage_PermissionText=Permissions:
-PermissionsGroup_Executable=Executable
-PermissionsGroup_GroupPermissions=Group:
-PermissionsGroup_OtherPermissions=Other:
-PermissionsGroup_Readable=Readable
-PermissionsGroup_UserPermissions=User:
-PermissionsGroup_Writable=Writable
-BasicFolderSection_BasicInfoText=Basic Information
-LinuxPermissionsSection_Permissions=Permissions
-WindowsAttributesSection_Attributes=Attributes
-FolderValidator_SpecifyFolder=Please specify the folder where the file or folder is going to be created.
-FolderValidator_DirNotExist=The directory {0} does not exist in the current target.
-FolderValidator_NotWritable=The directory {0} is not writable. Please choose a different one.
-NameValidator_InfoPrompt=Please enter a name to search.
-NameValidator_SpecifyFolder=Please specify the folder where the file or folder is going to be created.
-NewFileWizard_NewFileWizardTitle=New File Wizard
-NewFileWizardPage_NewFileWizardPageDescription=Create a new file in the directory.
-NewFileWizardPage_NewFileWizardPageNameLabel=File name:
-NewFileWizardPage_NewFileWizardPageTitle=New File
-NewFolderWizard_NewFolderWizardTitle=New Folder Wizard
-NewFolderWizardPage_NewFolderWizardPageDescription=Create a new folder in the directory.
-NewFolderWizardPage_NewFolderWizardPageNameLabel=Folder name:
-NewFolderWizardPage_NewFolderWizardPageTitle=New Folder
-NewNodeWizardPage_PromptFolderLabel=Enter or select the parent folder:
-SizeValidator_ErrorIncorrectFormat=The format of the size entered is not correct.
-SizeValidator_ErrorSizeOutofRange=The size entered is not in the expected range.
-SizeValidator_InfoPrompt=Please enter a size number.
-TargetSelectionPage_Description=Please select the target where the new file or folder is created.
-TargetSelectionPage_Targets=Targets:
-TargetSelectionPage_Title=Select the target.
-TreeViewerSearchDialog_LblCancelText=Find:
-TreeViewerSearchDialog_GrpOptionsText=Options
-TreeViewerSearchDialog_BtnCaseText=Case sensitive
-TreeViewerSearchDialog_BtnPreciseText=Precise matching
+###############################################################################
+# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# This program and the accompanying materials are made available under the terms
+# of the Eclipse Public License v1.0 which accompanies this distribution, and is
+# available at http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Wind River Systems - initial API and implementation
+###############################################################################
+FSFolderSelectionDialog_MoveDialogMessage=Choose destination for the files to be moved:
+FSFolderSelectionDialog_MoveDialogTitle=Move Files and Folders
+FSOpenFileDialog_message=Please select an image file for the process.
+FSOpenFileDialog_title=Select Process Image
+FSDelete_ConfirmDelete=Confirm Delete
+FSDelete_ConfirmMessage=Are you sure you want to remove the read-only file ''{0}''?
+FSDelete_ButtonCancel=Cancel
+FSDelete_ButtonNo=&No
+FSDelete_ButtonYes=&Yes
+FSDelete_ButtonYes2All=Yes to &All
+DateValidator_DateInvalidNumber=The date is not a valid number.
+DateValidator_DateOutofRange=The date is a number between 1 and 31.
+DateValidator_InfoFormat=The format of the date is MM/DD/YYYY
+DateValidator_InfoPrompt=Please enter a date.
+DateValidator_InvalidDate=The date entered is not a valid date\!
+DateValidator_MonthInvalidNumber=The month is not a valid number.
+DateValidator_MonthOutofRange=The month is a number between 1 and 12.
+DateValidator_YearInvalidNumber=The year is not a valid number.
+DateValidator_YearOutofRange=The year is a number which is bigger than zero.
+DeleteFilesHandler_ConfirmDialogTitle=Confirm Delete
+DeleteFilesHandler_DeleteMultipleFilesConfirmation=Are you sure you want to delete these {0} files/folders?
+DeleteFilesHandler_DeleteOneFileConfirmation=Are you sure you want to delete ''{0}''?
+FSRenamingAssistant_NameAlreadyExists=A file/folder with the name you specified already exists\! Specify a different name.
+FSRenamingAssistant_SpecifyNonEmptyName=Specify a non-empty name.
+FSRenamingAssistant_UnixIllegalCharacters=File or folder name cannot contain any of the following characters:\n/
+FSRenamingAssistant_WinIllegalCharacters=File or folder name cannot contain any of the following characters:\n\\/:*?<>|
+LocalTypedElement_SavingFile=Saving file: {0}
+MergeEditorInput_LocalFile=Local: {0}
+MergeEditorInput_RemoteFile=Remote: {0}
+MergeEditorInput_CompareLeftAndRight=Compare {0} and {1}
+MergeEditorInput_CompareWithLocalCache=Compare {0} with Local Cache
+MergeInput_CopyNotSupported=Copy is not support by this type of compare input
+RemoteTypedElement_GettingRemoteContent=Getting content from the remote file:
+RemoteTypedElement_DowloadingFile=Downloading file {0}...
+FSDropTargetListener_ConfirmMoveTitle=Confirm Move
+FSDropTargetListener_MovingWarningMultiple=This operation will delete the files after moving. You can copy them without deletion by CTRL + dragging. \n\nAre you sure you want to move these {0} files/folders?
+FSDropTargetListener_MovingWarningSingle=This operation will delete the file after moving. You can copy it without deletion by CTRL + dragging. \n\nAre you sure you want to move ''{0}''?
+FSExplorerEditorPage_PageTitle=File System Explorer
+FSGeneralSearchable_FileType=Select type of file
+FSGeneralSearchable_Find=Find:
+FSGeneralSearchable_GeneralOptionText=General options
+FSGeneralSearchable_SearchHiddenFiles=Search hidden files/folders
+FSGeneralSearchable_SearchSystemFiles=Search system files/folders
+FSModifiedSearchable_DontRemember=Don't remember
+FSModifiedSearchable_LastWeek=Within the last week
+FSModifiedSearchable_PastMonth=Past month
+FSModifiedSearchable_PastYear=Within the past year
+FSModifiedSearchable_SpecifyDates=Specify dates, from
+FSModifiedSearchable_ToDate=to
+FSModifiedSearchable_WhenModified=When was it modified?
+FSUpload_Cancel=Cancel
+FSUpload_No=No
+FSUpload_OverwriteConfirmation=A file with a same name already exists. Are you sure to overwrite {0}?
+FSUpload_OverwriteTitle=Confirm Overwrite
+FSUpload_Yes=Yes
+FSUpload_YesToAll=Yes to All
+FSOperation_ConfirmDialogCancel=Cancel
+FSOperation_ConfirmDialogNo=&No
+FSOperation_ConfirmDialogYes=&Yes
+FSOperation_ConfirmDialogYesToAll=Yes to &All
+FSOperation_ConfirmFileReplace=Confirm File Replace
+FSOperation_ConfirmFileReplaceMessage=This folder already contains a file named {0}.\n\n If the files in the existing folder have the same name as files in the folder you are moving or copying, they will be replaced. Do you still want to move or copy the file?
+FSOperation_ConfirmFolderReplaceMessage=This folder already contains a folder named {0}.\n\n If the files in the existing folder have the same name as files in the folder you are moving or copying, they will be replaced. Do you still want to move or copy the folder?
+FSOperation_ConfirmFolderReplaceTitle=Confirm Folder Replace
+OpenFileHandler_OpeningBinaryNotSupported=Opening a binary file is not supported yet.
+OpenFileHandler_Warning=Warning
+OpenWithMenu_ChooseEditorForOpening=Choose the editor for opening {0}
+OpenWithMenu_DefaultEditor=&Default Editor
+OpenWithMenu_NoEditorFound=No editor found to edit the file resource.
+OpenWithMenu_OpenWith=Open With
+FSRename_RenameFileFolderTitle=Error Renaming File or Folder
+FSSizeSearchable_DontRemember=Don't remember
+FSSizeSearchable_KBS=KB(s)
+FSSizeSearchable_Large=Large (more than 1 MB)
+FSSizeSearchable_Medium=Medium (less than 1 MB)
+FSSizeSearchable_Small=Small (less than 100 KB)
+FSSizeSearchable_SpecifySize=Specify size, from
+FSSizeSearchable_ToText=KB(s) to
+FSSizeSearchable_WhatSize=What size is it?
+FSTreeNodeSearchable_FilesAndFolders=both files and folders
+FSTreeNodeSearchable_FilesOnly=files only
+FSTreeNodeSearchable_FindFilesAndFolders=Find Files
+FSTreeNodeSearchable_FindMessage=Find files and folders under {0}.\nWarning: subsidiary files and folders will be loaded and searched.
+FSTreeNodeSearchable_FoldersOnly=folders only
+FSTreeNodeSearchable_SearchingTargets=Find in
+FSTreeNodeSearchable_SelectedFileSystem=the selected file system
+RenameFilesHandler_TitleRename=Rename
+RenameFilesHandler_TitleRenameFile=Rename File
+RenameFilesHandler_TitleRenameFolder=Rename Folder
+RenameFilesHandler_PromptNewName=New name:
+RenameFilesHandler_RenamePromptMessage=Please enter a new name
+PreferencePage_AutoSavingText=Automatically upload files to targets upon saving
+PreferencePage_CopyOwnershipText=Copy source UID and GID when copying files
+PreferencePage_CopyPermissionText=Copy source permissions when copying files
+PreferencePage_PersistExpanded=Remember expanded directories
+PreferencePage_RenamingOptionText=Use In-place Editor when renaming a file/folder
+AdvancedAttributesDialog_FileBanner=Choose the options you want for this file.
+AdvancedAttributesDialog_FolderBanner=Choose the settings you want for this folder.\n\nWhen you apply these changes you will be asked if you want the\n changes to affect all subfolders and files as well.
+AdvancedAttributesDialog_CompressEncrypt=Compress or Encrypt attributes
+AdvancedAttributesDialog_ArchiveIndex=Archive and Index attributes
+AdvancedAttributesDialog_IndexFile=For fast searching, allow Indexing Service to index this file
+AdvancedAttributesDialog_IndexFolder=For fast searching, allow Indexing Service to index this folder
+AdvancedAttributesDialog_FileArchive=File is ready for archiving
+AdvancedAttributesDialog_FolderArchive=Folder is ready for archiving
+AdvancedAttributesDialog_Encrypt=Encrypt contents to secure data
+AdvancedAttributesDialog_Compress=Compress contents to save disk space
+AdvancedAttributesDialog_ShellTitle=Advanced Attributes
+GeneralInformationPage_Accessed=Accessed:
+GeneralInformationPage_Advanced=\ A&dvanced...
+GeneralInformationPage_Attributes=Attributes:
+GeneralInformationPage_FileSizeInfo={0} KB ({1} bytes)
+GeneralInformationPage_Hidden=Hidden
+GeneralInformationPage_ReadOnly=Read-only
+GeneralInformationPage_Computer=computer
+GeneralInformationPage_Location=Location:
+GeneralInformationPage_Modified=Modified:
+GeneralInformationPage_Name=Name:
+GeneralInformationPage_Size=Size:
+GeneralInformationPage_Type=Type:
+GeneralInformationPage_PermissionText=Permissions:
+PermissionsGroup_Executable=Executable
+PermissionsGroup_GroupPermissions=Group:
+PermissionsGroup_OtherPermissions=Other:
+PermissionsGroup_Readable=Readable
+PermissionsGroup_UserPermissions=User:
+PermissionsGroup_Writable=Writable
+BasicFolderSection_BasicInfoText=Basic Information
+LinuxPermissionsSection_Permissions=Permissions
+WindowsAttributesSection_Attributes=Attributes
+FolderValidator_SpecifyFolder=Please specify the folder where the file or folder is going to be created.
+FolderValidator_DirNotExist=The directory {0} does not exist in the current target.
+FolderValidator_NotWritable=The directory {0} is not writable. Please choose a different one.
+NameValidator_InfoPrompt=Please enter a name to search.
+NameValidator_SpecifyFolder=Please specify the folder where the file or folder is going to be created.
+NewFileWizard_NewFileWizardTitle=New File Wizard
+NewFileWizardPage_NewFileWizardPageDescription=Create a new file in the directory.
+NewFileWizardPage_NewFileWizardPageNameLabel=File name:
+NewFileWizardPage_NewFileWizardPageTitle=New File
+NewFolderWizard_NewFolderWizardTitle=New Folder Wizard
+NewFolderWizardPage_NewFolderWizardPageDescription=Create a new folder in the directory.
+NewFolderWizardPage_NewFolderWizardPageNameLabel=Folder name:
+NewFolderWizardPage_NewFolderWizardPageTitle=New Folder
+NewNodeWizardPage_PromptFolderLabel=Enter or select the parent folder:
+SizeValidator_ErrorIncorrectFormat=The format of the size entered is not correct.
+SizeValidator_ErrorSizeOutofRange=The size entered is not in the expected range.
+SizeValidator_InfoPrompt=Please enter a size number.
+TargetSelectionPage_Description=Please select the target where the new file or folder is created.
+TargetSelectionPage_Targets=Targets:
+TargetSelectionPage_Title=Select the target.
+TreeViewerSearchDialog_LblCancelText=Find:
+TreeViewerSearchDialog_GrpOptionsText=Options
+TreeViewerSearchDialog_BtnCaseText=Case sensitive
+TreeViewerSearchDialog_BtnPreciseText=Precise matching
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
index 094f915f8..e7212d7e3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
@@ -309,21 +309,6 @@
</with>
</visibleWhen>
</command>
- <command
- commandId="org.eclipse.tcf.te.tcf.processes.ui.command.refreshViewer"
- icon="icons/obj16/refresh.gif"
- label="%command.refreshviewer.label"
- style="push"
- tooltip="%command.refreshviewer.tooltip">
- <visibleWhen checkEnabled="false">
- <with variable="selection">
- <count value="+"/>
- <iterate ifEmpty="false" operator="and">
- <instanceof value="org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode"/>
- </iterate>
- </with>
- </visibleWhen>
- </command>
<separator
name="group.search"
visible="true">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
index c94aae289..4667eac6f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
@@ -176,7 +176,6 @@ public class Messages extends NLS {
public static String GeneralSearchable_CaseSensitive;
public static String GeneralSearchable_FindLabel;
public static String GeneralSearchable_GeneralOptions;
- public static String GeneralSearchable_PreciseMatching;
public static String TerminateHandler_terminateFailed;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
index b0e7a07f5..f932679dd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
@@ -128,8 +128,7 @@ GeneralInformationPage_User=User:
GeneralSearchable_CaseSensitive=Case sensitive
GeneralSearchable_FindLabel=Find:
-GeneralSearchable_GeneralOptions=General search options
-GeneralSearchable_PreciseMatching=Precise matching
+GeneralSearchable_GeneralOptions=General options
TerminateHandler_terminateFailed=Failed to terminate process {0}.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java
index f2e86f850..52f572668 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java
@@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
/**
@@ -36,32 +37,25 @@ import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
public class GeneralSearchable extends AbstractSearchable {
// The keys to access the options stored in the dialog settings.
private static final String TARGET_NAME = "PM.TargetName"; //$NON-NLS-1$
- private static final String MATCH_PRECISE = "PM.MatchPrecise"; //$NON-NLS-1$
private static final String CASE_SENSITIVE = "PM.CaseSensitive"; //$NON-NLS-1$
// The case sensitive check box.
private Button fBtnCase;
- // The matching rule check box.
- private Button fBtnMatch;
// The input field for searching conditions.
private BaseEditBrowseTextControl fSearchField;
// The current target names.
private String fTargetName;
// Whether it is case sensitive
private boolean fCaseSensitive;
- // Whether it is precise matching.
- private boolean fMatchPrecise;
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.tcf.te.ui.internal.utils.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createCommonPart(Composite parent) {
+ public void createCommonPart(TreeViewerSearchDialog dialog, Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
- GridLayout glayout = new GridLayout(3, false);
- glayout.marginHeight = 0;
- glayout.marginWidth = 0;
- composite.setLayout(glayout);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Searching field.
@@ -84,19 +78,19 @@ public class GeneralSearchable extends AbstractSearchable {
searchTextModified();
}
});
-
+
SelectionListener l = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionChecked(e);
}
};
-
+
Group group = new Group(parent, SWT.NONE);
group.setText(Messages.GeneralSearchable_GeneralOptions);
group.setLayout(new GridLayout(2, true));
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
// Case sensitive
fBtnCase = new Button(group, SWT.CHECK);
fBtnCase.setText(Messages.GeneralSearchable_CaseSensitive);
@@ -104,14 +98,9 @@ public class GeneralSearchable extends AbstractSearchable {
fBtnCase.setLayoutData(data);
fBtnCase.addSelectionListener(l);
- // Matching precisely
- fBtnMatch = new Button(group, SWT.CHECK);
- fBtnMatch.setText(Messages.GeneralSearchable_PreciseMatching);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnMatch.setLayoutData(data);
- fBtnMatch.addSelectionListener(l);
+ dialog.createSearchDirectionOptions(group);
}
-
+
/**
* The text for searching is modified.
*/
@@ -119,10 +108,10 @@ public class GeneralSearchable extends AbstractSearchable {
fireOptionChanged();
fTargetName = fSearchField.getEditFieldControlText().trim();
}
-
+
/**
* Handling the event that a button is selected and checked.
- *
+ *
* @param e The selection event.
*/
protected void optionChecked(SelectionEvent e) {
@@ -130,13 +119,9 @@ public class GeneralSearchable extends AbstractSearchable {
if (src == fBtnCase) {
fCaseSensitive = fBtnCase.getSelection();
}
- else if (src == fBtnMatch) {
- fMatchPrecise = fBtnMatch.getSelection();
- }
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
*/
@Override
@@ -144,8 +129,7 @@ public class GeneralSearchable extends AbstractSearchable {
return fSearchField.isValid();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
*/
@Override
@@ -153,8 +137,6 @@ public class GeneralSearchable extends AbstractSearchable {
if(settings != null) {
fCaseSensitive = settings.getBoolean(CASE_SENSITIVE);
fBtnCase.setSelection(fCaseSensitive);
- fMatchPrecise = settings.getBoolean(MATCH_PRECISE);
- fBtnMatch.setSelection(fMatchPrecise);
fTargetName = settings.get(TARGET_NAME);
if (fTargetName != null) {
fSearchField.setEditFieldControlText(fTargetName);
@@ -162,11 +144,9 @@ public class GeneralSearchable extends AbstractSearchable {
}
else {
fCaseSensitive = false;
- fMatchPrecise = false;
fTargetName = null;
}
fBtnCase.setSelection(fCaseSensitive);
- fBtnMatch.setSelection(fMatchPrecise);
if (fTargetName != null) {
fSearchField.setEditFieldControlText(fTargetName);
}
@@ -180,7 +160,6 @@ public class GeneralSearchable extends AbstractSearchable {
public void persistValues(IDialogSettings settings) {
if(settings != null) {
settings.put(CASE_SENSITIVE, fCaseSensitive);
- settings.put(MATCH_PRECISE, fMatchPrecise);
settings.put(TARGET_NAME, fTargetName);
}
}
@@ -191,9 +170,9 @@ public class GeneralSearchable extends AbstractSearchable {
*/
@Override
public ISearchMatcher getMatcher() {
- return new ProcessNodeGeneralMatcher(fCaseSensitive, fMatchPrecise, fTargetName);
+ return new ProcessNodeGeneralMatcher(fCaseSensitive, fTargetName);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#getPreferredSize()
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java
index be97aa345..165236639 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,18 +9,14 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.search;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.IExpansionListener;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
/**
* The base searchable that provides common methods for its subclasses.
@@ -31,46 +27,29 @@ import org.eclipse.ui.forms.widgets.Section;
public abstract class ProcessBaseSearchable extends AbstractSearchable implements ISearchMatcher {
/**
- * Create a collapseable section with the specified title and return the
- * content composite.
+ * Create a group with the specified title.
*
- * @param parent The parent where the section is to be created.
- * @return The content composite.
+ * @param parent The parent where the group is to be created.
+ * @return The group composite.
*/
- protected Composite createSection(Composite parent) {
- Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- section.setText(getSectionTitle());
- section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
- GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
- section.setLayoutData(layoutData);
+ protected Composite createGroup(Composite parent) {
+ Assert.isNotNull(parent);
- final Composite client = new Composite(section, SWT.NONE);
- client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- client.setBackground(section.getBackground());
- section.setClient(client);
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(getGroupTitle());
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setBackground(parent.getBackground());
- section.addExpansionListener(new IExpansionListener(){
- @Override
- public void expansionStateChanging(ExpansionEvent e) {
- }
- @Override
- public void expansionStateChanged(ExpansionEvent e) {
- Shell shell = client.getShell();
- boolean state = e.getState();
- int client_height = client.getSize().y;
- Point p = shell.getSize();
- p.y = state ? p.y + client_height : p.y - client_height;
- shell.setSize(p.x, p.y);
- }});
- return client;
+ return group;
}
/**
- * Returns the section title.
+ * Returns the group title.
*
- * @return The section title.
+ * @return The group title.
*/
- protected abstract String getSectionTitle();
+ protected abstract String getGroupTitle();
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java
index da7db2a43..b3c2d05a5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java
@@ -20,8 +20,6 @@ import org.eclipse.tcf.te.ui.utils.StringMatcher;
public class ProcessNodeGeneralMatcher implements ISearchMatcher {
// Whether it is case sensitive
private boolean fCaseSensitive;
- // Whether it is precise matching.
- private boolean fMatchPrecise;
// The string matcher for matching.
private StringMatcher fStringMatcher;
// The label provider used to get a text for a process.
@@ -33,16 +31,12 @@ public class ProcessNodeGeneralMatcher implements ISearchMatcher {
* Constructor with options.
*
* @param caseSensitive
- * @param matchPrecise
* @param targetName
*/
- public ProcessNodeGeneralMatcher(boolean caseSensitive, boolean matchPrecise, String targetName) {
+ public ProcessNodeGeneralMatcher(boolean caseSensitive, String targetName) {
fCaseSensitive = caseSensitive;
fTargetName = targetName;
- fMatchPrecise = matchPrecise;
- if (!fMatchPrecise) {
- fStringMatcher = new StringMatcher(fTargetName, !fCaseSensitive, false);
- }
+ fStringMatcher = new StringMatcher(fTargetName, !fCaseSensitive, false);
}
/*
@@ -56,9 +50,6 @@ public class ProcessNodeGeneralMatcher implements ISearchMatcher {
IProcessContextNode node = (IProcessContextNode) context;
String text = labelProvider.getText(node);
if (text != null) {
- if (fMatchPrecise) {
- return fCaseSensitive ? text.equals(fTargetName) : text.equalsIgnoreCase(fTargetName);
- }
return fStringMatcher.match(text);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java
index f62f79a1c..06b26b022 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java
@@ -111,6 +111,34 @@ public class ProcessSearchable extends CompositeSearchable {
return message;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getCustomMessage(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public String getCustomMessage(final Object rootElement, final String key) {
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ if (rootElement instanceof IRuntimeModel) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ if (rootElement instanceof IRuntimeModel) {
+ node.set(((IRuntimeModel)rootElement).getPeerModel());
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+ }
+ else if (rootElement != null) {
+ node.set(rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class));
+ }
+
+ String message = Messages.getStringDelegated(node.get(), key);
+ return message;
+ }
+
/**
* Get a name representation for each process node.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java
index 285a37b6e..e303581d6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java
@@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
/**
* The searchable that provides a UI to collect and test
@@ -64,19 +65,18 @@ public class ProcessStateSearchable extends ProcessBaseSearchable {
// The current selected states expressed in the above characters.
private String fStates;
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createAdvancedPart(Composite parent) {
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
SelectionListener l = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionChecked(e);
}
};
- Composite stateComposite = createSection(parent);
+ Composite stateComposite = createGroup(parent);
stateComposite.setLayout(new GridLayout());
fBtnNotRem = new Button(stateComposite, SWT.RADIO);
@@ -146,7 +146,7 @@ public class ProcessStateSearchable extends ProcessBaseSearchable {
* @see org.eclipse.tcf.te.tcf.processes.ui.search.ProcessBaseSearchable#getSectionTitle()
*/
@Override
- protected String getSectionTitle() {
+ protected String getGroupTitle() {
return Messages.ProcessStateSearchable_SectionChooseState;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java
index cef67fcd2..f86d257c8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java
@@ -27,6 +27,7 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
/**
* The searchable that provides a UI to collect and test
@@ -49,19 +50,18 @@ public class ProcessUserSearchable extends ProcessBaseSearchable {
private Button fBtnUserSpecified;
private BaseEditBrowseTextControl txtUser;
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createAdvancedPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createAdvancedPart(Composite parent) {
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
SelectionListener l = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionChecked(e);
}
};
- Composite modifiedComp = createSection(parent);
+ Composite modifiedComp = createGroup(parent);
modifiedComp.setLayout(new GridLayout(2, false));
fBtnUserNotRem = new Button(modifiedComp, SWT.RADIO);
@@ -115,7 +115,7 @@ public class ProcessUserSearchable extends ProcessBaseSearchable {
* @see org.eclipse.tcf.te.tcf.processes.ui.search.ProcessBaseSearchable#getSectionTitle()
*/
@Override
- protected String getSectionTitle() {
+ protected String getGroupTitle() {
return Messages.ProcessUserSearchable_WhoStarted;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui/META-INF/MANIFEST.MF
index 5eaf1c9e3..b2705e1cc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/META-INF/MANIFEST.MF
@@ -1,49 +1,49 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tcf.te.ui;singleton:=true
-Bundle-Version: 1.1.0.qualifier
-Bundle-Activator: org.eclipse.tcf.te.ui.activator.UIPlugin
-Bundle-Vendor: %providerName
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
- org.eclipse.core.expressions;bundle-version="3.4.400",
- org.eclipse.help;bundle-version="3.6.0",
- org.eclipse.ui;bundle-version="3.8.0",
- org.eclipse.ui.forms;bundle-version="3.5.200",
- org.eclipse.ui.navigator;bundle-version="3.5.200",
- org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.stepper;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.1.0",
- org.eclipse.tcf.te.core;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: plugin
-Export-Package: org.eclipse.tcf.te.ui,
- org.eclipse.tcf.te.ui.activator,
- org.eclipse.tcf.te.ui.async,
- org.eclipse.tcf.te.ui.dialogs,
- org.eclipse.tcf.te.ui.events,
- org.eclipse.tcf.te.ui.handler,
- org.eclipse.tcf.te.ui.help,
- org.eclipse.tcf.te.ui.interfaces,
- org.eclipse.tcf.te.ui.interfaces.data,
- org.eclipse.tcf.te.ui.interfaces.handler,
- org.eclipse.tcf.te.ui.interfaces.services,
- org.eclipse.tcf.te.ui.internal.executors;x-internal:=true,
- org.eclipse.tcf.te.ui.internal.utils;x-internal:=true,
- org.eclipse.tcf.te.ui.nls,
- org.eclipse.tcf.te.ui.preferences,
- org.eclipse.tcf.te.ui.statushandler,
- org.eclipse.tcf.te.ui.tables,
- org.eclipse.tcf.te.ui.tables.properties,
- org.eclipse.tcf.te.ui.trees,
- org.eclipse.tcf.te.ui.utils,
- org.eclipse.tcf.te.ui.wizards,
- org.eclipse.tcf.te.ui.wizards.interfaces,
- org.eclipse.tcf.te.ui.wizards.newWizard,
- org.eclipse.tcf.te.ui.wizards.pages
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.tcf.te.ui;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Activator: org.eclipse.tcf.te.ui.activator.UIPlugin
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.core.expressions;bundle-version="3.4.400",
+ org.eclipse.help;bundle-version="3.6.0",
+ org.eclipse.ui;bundle-version="3.8.0",
+ org.eclipse.ui.forms;bundle-version="3.5.200",
+ org.eclipse.ui.navigator;bundle-version="3.5.200",
+ org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.stepper;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.1.0",
+ org.eclipse.tcf.te.core;bundle-version="1.1.0",
+ org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0",
+ org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.tcf.te.ui,
+ org.eclipse.tcf.te.ui.activator,
+ org.eclipse.tcf.te.ui.async,
+ org.eclipse.tcf.te.ui.dialogs,
+ org.eclipse.tcf.te.ui.events,
+ org.eclipse.tcf.te.ui.handler,
+ org.eclipse.tcf.te.ui.help,
+ org.eclipse.tcf.te.ui.interfaces,
+ org.eclipse.tcf.te.ui.interfaces.data,
+ org.eclipse.tcf.te.ui.interfaces.handler,
+ org.eclipse.tcf.te.ui.interfaces.services,
+ org.eclipse.tcf.te.ui.internal.executors;x-internal:=true,
+ org.eclipse.tcf.te.ui.nls,
+ org.eclipse.tcf.te.ui.preferences,
+ org.eclipse.tcf.te.ui.search,
+ org.eclipse.tcf.te.ui.statushandler,
+ org.eclipse.tcf.te.ui.tables,
+ org.eclipse.tcf.te.ui.tables.properties,
+ org.eclipse.tcf.te.ui.trees,
+ org.eclipse.tcf.te.ui.utils,
+ org.eclipse.tcf.te.ui.wizards,
+ org.eclipse.tcf.te.ui.wizards.interfaces,
+ org.eclipse.tcf.te.ui.wizards.newWizard,
+ org.eclipse.tcf.te.ui.wizards.pages
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
index 1952fc104..7ab9e5ab4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
@@ -1,394 +1,394 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.dialogs;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.internal.utils.TablePatternFilter;
-import org.eclipse.tcf.te.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.ui.navigator.IDescriptionProvider;
-
-/**
- * A selection dialog with a checked list and a filter text field.
- */
-public class FilteredCheckedListDialog extends SelectionStatusDialog implements ISelectionChangedListener {
- // The pattern filter used filter the content of the list.
- TablePatternFilter patternFilter;
- // The text field used to enter filters.
- Text filterText;
- // The check-box style table used to display a list and select elements.
- CheckboxTableViewer tableViewer;
- // The button of select All.
- Button btnSelAll;
- // The button of deselect All
- Button btnDesAll;
- // The label provider used to provide labels, images and descriptions for the listed items.
- ILabelProvider labelProvider;
- // The initial filter displayed in the filter text field.
- String filter;
- // The elements to be selected.
- Object[] elements;
- // Currently selected items.
- Set<Object> checkedItems;
-
- /**
- * Constructor used to instantiate a dialog with a specified parent.
- *
- * @param shell The parent shell.
- */
- public FilteredCheckedListDialog(Shell shell) {
- super(shell);
- checkedItems = new HashSet<Object>();
- }
-
- /**
- * Set the initial filter text to be displayed in the filter text field.
- *
- * @param filterText The initial filter text.
- */
- public void setFilterText(String filterText) {
- this.filter = filterText;
- }
-
- /**
- * Set the label provider used to provide labels, images and descriptive text
- * for items in the list.
- *
- * @param labelProvider The new label provider.
- */
- public void setLabelProvider(ILabelProvider labelProvider) {
- this.labelProvider = labelProvider;
- }
-
- /**
- * Set elements to be displayed in the list for selection.
- *
- * @param elements The elements.
- */
- public void setElements(Object[] elements) {
- this.elements = elements != null ? Arrays.copyOf(elements, elements.length) : null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
- Object element = structuredSelection.getFirstElement();
- String description = labelProvider != null && labelProvider instanceof IDescriptionProvider ? ((IDescriptionProvider)labelProvider).getDescription(element) : null;
- if (description == null) description = element == null ? "" : "Enable "+labelProvider.getText(element)+"."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updateStatus(new Status(IStatus.OK, UIPlugin.getUniqueIdentifier(), description));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
- */
- @Override
- protected void computeResult() {
- setSelectionResult(checkedItems.toArray());
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- createMessageArea(composite);
- createPatternFilterText(composite);
- createTable(composite);
- createSelBtn(composite);
- initializeData();
- return composite;
- }
-
- /**
- * Get accessible name for the filter text field.
- *
- * @param e The accessible event.
- */
- protected void getAccessibleName(AccessibleEvent e) {
- String filterTextString = filterText.getText();
- if (filterTextString.length() == 0) {
- e.result = filter;
- }
- else {
- e.result = filterTextString;
- }
- }
-
- /**
- * Called when the filter text field gains focus.
- *
- * @param e The focus event.
- */
- protected void filterTextFocusGained(FocusEvent e) {
- if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
- filterText.selectAll();
- }
- }
-
- /**
- * Called when a mouse up event happens to the filter text field.
- *
- * @param e The mouse up event.
- */
- protected void filterTextMouseUp(MouseEvent e) {
- if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
- filterText.selectAll();
- }
- }
-
- /**
- * Called when a key event happens to the filter text field.
- *
- * @param e The key event.
- */
- protected void filterTextKeyPressed(KeyEvent e) {
- boolean hasItems = tableViewer.getTable().getItemCount() > 0;
- if (hasItems && e.keyCode == SWT.ARROW_DOWN) {
- tableViewer.getTable().setFocus();
- }
- }
-
- /**
- * Called when a traverse event happens to the filter text field.
- *
- * @param e The traverse event.
- */
- protected void filterTextKeyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- if (tableViewer.getTable().getItemCount() == 0) {
- Display.getCurrent().beep();
- }
- else {
- // if the initial filter text hasn't changed, do not try to match
- boolean hasFocus = tableViewer.getTable().setFocus();
- boolean textChanged = filter != null && !filter.equals(SWTControlUtil.getText(filterText).trim());
- if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
- TableItem[] items = tableViewer.getTable().getItems();
- for (TableItem item : items) {
- if (patternFilter.match(item.getText())) {
- tableViewer.getTable().setSelection(new TableItem[] { item });
- ISelection sel = tableViewer.getSelection();
- tableViewer.setSelection(sel, true);
- break;
- }
- }
- }
- }
- }
- }
-
- /**
- * Called when a text modification event happens.
- *
- * @param e The modification event.
- */
- protected void filterTextModifyText(ModifyEvent e) {
- patternFilter.setPattern(filterText.getText());
- tableViewer.refresh();
- for (Object item : checkedItems) {
- tableViewer.setChecked(item, true);
- }
- }
-
- /**
- * Called when a list item is checked or unchecked.
- *
- * @param event The check event.
- */
- protected void tableCheckStateChanged(CheckStateChangedEvent event) {
- if (event.getChecked()) checkedItems.add(event.getElement());
- else checkedItems.remove(event.getElement());
- }
-
- /**
- * Create the filter text field and add listeners to respond to control input.
- *
- * @param composite The parent composite.
- */
- private void createPatternFilterText(Composite composite) {
- filterText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridData filterTextGridData = new GridData(GridData.FILL_HORIZONTAL);
- filterText.setLayoutData(filterTextGridData);
- filterText.setText(filter);
- filterText.setFont(composite.getFont());
- filterText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- getAccessibleName(e);
- }
- });
- filterText.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- filterTextFocusGained(e);
- }
- });
- filterText.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- filterTextMouseUp(e);
- }
- });
- filterText.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- filterTextKeyPressed(e);
- }
- });
- // enter key set focus to tree
- filterText.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- filterTextKeyTraversed(e);
- }
- });
- filterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- filterTextModifyText(e);
- }
- });
- }
-
- /**
- * Create the checked list and add check state changed listener to monitor events.
- *
- * @param composite The parent composite.
- */
- private void createTable(Composite composite) {
- tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- tableViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- tableCheckStateChanged(event);
- }
- });
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- data.heightHint = 120;
- data.widthHint = 200;
- tableViewer.getTable().setLayoutData(data);
-
- tableViewer.setContentProvider(ArrayContentProvider.getInstance());
- tableViewer.setLabelProvider(labelProvider);
- patternFilter = new TablePatternFilter(labelProvider);
- tableViewer.addFilter(patternFilter);
- tableViewer.addSelectionChangedListener(this);
- }
-
- private void createSelBtn(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- composite.setLayout(layout);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- composite.setLayoutData(data);
-
- btnSelAll = new Button(composite, SWT.PUSH);
- btnSelAll.setText(Messages.FilteredCheckedListDialog_SelAllText);
- btnSelAll.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectAll();
- }
- });
-
- btnDesAll = new Button(composite, SWT.PUSH);
- btnDesAll.setText(Messages.FilteredCheckedListDialog_DesAllText);
- btnDesAll.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- deselectAll();
- }
- });
- }
-
- void selectAll() {
- TableItem[] items = tableViewer.getTable().getItems();
- for (TableItem item : items) {
- if (item.getData() != null && !item.getChecked()) {
- item.setChecked(true);
- checkedItems.add(item.getData());
- }
- }
- }
-
- void deselectAll() {
- TableItem[] children = tableViewer.getTable().getItems();
- for (TableItem item : children) {
- if (item.getData() != null && item.getChecked()) {
- item.setChecked(false);
- checkedItems.remove(item.getData());
- }
- }
- }
-
- /**
- * Initialize the list items in the table and force focus to it.
- */
- private void initializeData() {
- tableViewer.setInput(elements);
- List<Object> selection = getInitialElementSelections();
- if (selection != null) {
- for (Object element : selection) {
- tableViewer.setChecked(element, true);
- checkedItems.add(element);
- }
- }
- filterText.forceFocus();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.dialogs;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.search.TablePatternFilter;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+import org.eclipse.ui.navigator.IDescriptionProvider;
+
+/**
+ * A selection dialog with a checked list and a filter text field.
+ */
+public class FilteredCheckedListDialog extends SelectionStatusDialog implements ISelectionChangedListener {
+ // The pattern filter used filter the content of the list.
+ TablePatternFilter patternFilter;
+ // The text field used to enter filters.
+ Text filterText;
+ // The check-box style table used to display a list and select elements.
+ CheckboxTableViewer tableViewer;
+ // The button of select All.
+ Button btnSelAll;
+ // The button of deselect All
+ Button btnDesAll;
+ // The label provider used to provide labels, images and descriptions for the listed items.
+ ILabelProvider labelProvider;
+ // The initial filter displayed in the filter text field.
+ String filter;
+ // The elements to be selected.
+ Object[] elements;
+ // Currently selected items.
+ Set<Object> checkedItems;
+
+ /**
+ * Constructor used to instantiate a dialog with a specified parent.
+ *
+ * @param shell The parent shell.
+ */
+ public FilteredCheckedListDialog(Shell shell) {
+ super(shell);
+ checkedItems = new HashSet<Object>();
+ }
+
+ /**
+ * Set the initial filter text to be displayed in the filter text field.
+ *
+ * @param filterText The initial filter text.
+ */
+ public void setFilterText(String filterText) {
+ this.filter = filterText;
+ }
+
+ /**
+ * Set the label provider used to provide labels, images and descriptive text
+ * for items in the list.
+ *
+ * @param labelProvider The new label provider.
+ */
+ public void setLabelProvider(ILabelProvider labelProvider) {
+ this.labelProvider = labelProvider;
+ }
+
+ /**
+ * Set elements to be displayed in the list for selection.
+ *
+ * @param elements The elements.
+ */
+ public void setElements(Object[] elements) {
+ this.elements = elements != null ? Arrays.copyOf(elements, elements.length) : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
+ Object element = structuredSelection.getFirstElement();
+ String description = labelProvider != null && labelProvider instanceof IDescriptionProvider ? ((IDescriptionProvider)labelProvider).getDescription(element) : null;
+ if (description == null) description = element == null ? "" : "Enable "+labelProvider.getText(element)+"."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ updateStatus(new Status(IStatus.OK, UIPlugin.getUniqueIdentifier(), description));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
+ */
+ @Override
+ protected void computeResult() {
+ setSelectionResult(checkedItems.toArray());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ createMessageArea(composite);
+ createPatternFilterText(composite);
+ createTable(composite);
+ createSelBtn(composite);
+ initializeData();
+ return composite;
+ }
+
+ /**
+ * Get accessible name for the filter text field.
+ *
+ * @param e The accessible event.
+ */
+ protected void getAccessibleName(AccessibleEvent e) {
+ String filterTextString = filterText.getText();
+ if (filterTextString.length() == 0) {
+ e.result = filter;
+ }
+ else {
+ e.result = filterTextString;
+ }
+ }
+
+ /**
+ * Called when the filter text field gains focus.
+ *
+ * @param e The focus event.
+ */
+ protected void filterTextFocusGained(FocusEvent e) {
+ if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
+ filterText.selectAll();
+ }
+ }
+
+ /**
+ * Called when a mouse up event happens to the filter text field.
+ *
+ * @param e The mouse up event.
+ */
+ protected void filterTextMouseUp(MouseEvent e) {
+ if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
+ filterText.selectAll();
+ }
+ }
+
+ /**
+ * Called when a key event happens to the filter text field.
+ *
+ * @param e The key event.
+ */
+ protected void filterTextKeyPressed(KeyEvent e) {
+ boolean hasItems = tableViewer.getTable().getItemCount() > 0;
+ if (hasItems && e.keyCode == SWT.ARROW_DOWN) {
+ tableViewer.getTable().setFocus();
+ }
+ }
+
+ /**
+ * Called when a traverse event happens to the filter text field.
+ *
+ * @param e The traverse event.
+ */
+ protected void filterTextKeyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
+ if (tableViewer.getTable().getItemCount() == 0) {
+ Display.getCurrent().beep();
+ }
+ else {
+ // if the initial filter text hasn't changed, do not try to match
+ boolean hasFocus = tableViewer.getTable().setFocus();
+ boolean textChanged = filter != null && !filter.equals(SWTControlUtil.getText(filterText).trim());
+ if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
+ TableItem[] items = tableViewer.getTable().getItems();
+ for (TableItem item : items) {
+ if (patternFilter.match(item.getText())) {
+ tableViewer.getTable().setSelection(new TableItem[] { item });
+ ISelection sel = tableViewer.getSelection();
+ tableViewer.setSelection(sel, true);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Called when a text modification event happens.
+ *
+ * @param e The modification event.
+ */
+ protected void filterTextModifyText(ModifyEvent e) {
+ patternFilter.setPattern(filterText.getText());
+ tableViewer.refresh();
+ for (Object item : checkedItems) {
+ tableViewer.setChecked(item, true);
+ }
+ }
+
+ /**
+ * Called when a list item is checked or unchecked.
+ *
+ * @param event The check event.
+ */
+ protected void tableCheckStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) checkedItems.add(event.getElement());
+ else checkedItems.remove(event.getElement());
+ }
+
+ /**
+ * Create the filter text field and add listeners to respond to control input.
+ *
+ * @param composite The parent composite.
+ */
+ private void createPatternFilterText(Composite composite) {
+ filterText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridData filterTextGridData = new GridData(GridData.FILL_HORIZONTAL);
+ filterText.setLayoutData(filterTextGridData);
+ filterText.setText(filter);
+ filterText.setFont(composite.getFont());
+ filterText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ getAccessibleName(e);
+ }
+ });
+ filterText.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ filterTextFocusGained(e);
+ }
+ });
+ filterText.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ filterTextMouseUp(e);
+ }
+ });
+ filterText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ filterTextKeyPressed(e);
+ }
+ });
+ // enter key set focus to tree
+ filterText.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ filterTextKeyTraversed(e);
+ }
+ });
+ filterText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ filterTextModifyText(e);
+ }
+ });
+ }
+
+ /**
+ * Create the checked list and add check state changed listener to monitor events.
+ *
+ * @param composite The parent composite.
+ */
+ private void createTable(Composite composite) {
+ tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ tableCheckStateChanged(event);
+ }
+ });
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = 120;
+ data.widthHint = 200;
+ tableViewer.getTable().setLayoutData(data);
+
+ tableViewer.setContentProvider(ArrayContentProvider.getInstance());
+ tableViewer.setLabelProvider(labelProvider);
+ patternFilter = new TablePatternFilter(labelProvider);
+ tableViewer.addFilter(patternFilter);
+ tableViewer.addSelectionChangedListener(this);
+ }
+
+ private void createSelBtn(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ composite.setLayout(layout);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ composite.setLayoutData(data);
+
+ btnSelAll = new Button(composite, SWT.PUSH);
+ btnSelAll.setText(Messages.FilteredCheckedListDialog_SelAllText);
+ btnSelAll.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectAll();
+ }
+ });
+
+ btnDesAll = new Button(composite, SWT.PUSH);
+ btnDesAll.setText(Messages.FilteredCheckedListDialog_DesAllText);
+ btnDesAll.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ deselectAll();
+ }
+ });
+ }
+
+ void selectAll() {
+ TableItem[] items = tableViewer.getTable().getItems();
+ for (TableItem item : items) {
+ if (item.getData() != null && !item.getChecked()) {
+ item.setChecked(true);
+ checkedItems.add(item.getData());
+ }
+ }
+ }
+
+ void deselectAll() {
+ TableItem[] children = tableViewer.getTable().getItems();
+ for (TableItem item : children) {
+ if (item.getData() != null && item.getChecked()) {
+ item.setChecked(false);
+ checkedItems.remove(item.getData());
+ }
+ }
+ }
+
+ /**
+ * Initialize the list items in the table and force focus to it.
+ */
+ private void initializeData() {
+ tableViewer.setInput(elements);
+ List<Object> selection = getInitialElementSelections();
+ if (selection != null) {
+ for (Object element : selection) {
+ tableViewer.setChecked(element, true);
+ checkedItems.add(element);
+ }
+ }
+ filterText.forceFocus();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
index b93852256..6fcceea42 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.ui.interfaces;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
@@ -45,6 +46,16 @@ public interface ISearchable {
public String getSearchMessage(Object rootElement);
/**
+ * Returns a customized message for the given key and root element.
+ *
+ * @param rootElement The root element where the search is started.
+ * @param key The message key
+ *
+ * @return The customized message or <code>null</code>.
+ */
+ public String getCustomMessage(Object rootElement, String key);
+
+ /**
* Get a text to be used during searching process.
*
* @param element The element to searched.
@@ -56,17 +67,19 @@ public interface ISearchable {
* Create the part in the searching dialog where the user
* enters the common matching rule used in searching.
*
+ * @param dialog The parent tree viewer search dialog.
* @param parent The parent composite of this option part.
*/
- public void createCommonPart(Composite parent);
+ public void createCommonPart(TreeViewerSearchDialog dialog, Composite parent);
/**
* Create the part in the searching dialog where the user
* enters the advanced matching rule used in searching.
*
+ * @param dialog The parent tree viewer search dialog.
* @param parent The parent composite of this option part.
*/
- public void createAdvancedPart(Composite parent);
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent);
/**
* Get a searching matcher object to test if a tree node matches
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
index 239ba9f05..eab2a3372 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
@@ -80,24 +80,17 @@ public class Messages extends NLS {
public static String TreeViewerSearchDialog_AdvancedOptions;
public static String TreeViewerSearchDialog_All;
- public static String TreeViewerSearchDialog_BFS;
public static String TreeViewerSearchDialog_BtnBackText;
public static String TreeViewerSearchDialog_BtnCloseText;
public static String TreeViewerSearchDialog_BtnSearchText;
- public static String TreeViewerSearchDialog_DepthFirst;
- public static String TreeViewerSearchDialog_DFS;
public static String TreeViewerSearchDialog_JobName;
public static String TreeViewerSearchDialog_MainTaskName;
public static String TreeViewerSearchDialog_NoMoreNodeFound;
public static String TreeViewerSearchDialog_NoSuchNode;
public static String TreeViewerSearchDialog_Scope;
public static String TreeViewerSearchDialog_SearchAlgorithm;
- public static String TreeViewerSearchDialog_SearchNodesUsing;
public static String TreeViewerSearchDialog_Selected;
- public static String TreeViewerSearchDialog_BreadthFirst;
public static String TreeViewerSearchDialog_BtnWrapText;
- public static String TreeViewerSearchDialog_GeneralOptions;
- public static String TreeViewerSearchDialog_UseOptions;
public static String ViewerStateManager_MkdirFailed;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
index 4ab4ea01f..7b1e12783 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
@@ -56,24 +56,17 @@ QuickFilterPopup_PromptMessage=<ENTER> to confirm, <ESC> to reset
TreeViewerSearchDialog_AdvancedOptions=Advanced options
TreeViewerSearchDialog_All=All
-TreeViewerSearchDialog_BFS=Breadth-first search
TreeViewerSearchDialog_BtnBackText=Find backward
TreeViewerSearchDialog_BtnCloseText=Close
TreeViewerSearchDialog_BtnSearchText=Find
-TreeViewerSearchDialog_DepthFirst=Depth-First Search
-TreeViewerSearchDialog_DFS=Depth-first search
TreeViewerSearchDialog_JobName=Find Elements
TreeViewerSearchDialog_MainTaskName=Finding
TreeViewerSearchDialog_NoMoreNodeFound=No more node is found\!
TreeViewerSearchDialog_NoSuchNode=No such node\!
TreeViewerSearchDialog_Scope=Scope
TreeViewerSearchDialog_SearchAlgorithm=Algorithm
-TreeViewerSearchDialog_SearchNodesUsing=Search nodes using
TreeViewerSearchDialog_Selected=Selected element
-TreeViewerSearchDialog_BreadthFirst=Breadth-First Search
TreeViewerSearchDialog_BtnWrapText=Wrap search
-TreeViewerSearchDialog_GeneralOptions=General search options
-TreeViewerSearchDialog_UseOptions=with option(s):
# ***** Preference Pages *****
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/AbstractSearcher.java
index 2c8c16b0a..65cac7a43 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/AbstractSearcher.java
@@ -1,91 +1,91 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.tcf.te.ui.interfaces.ILazyLoader;
-import org.eclipse.tcf.te.ui.interfaces.ISearchable;
-import org.eclipse.tcf.te.ui.interfaces.ITreeSearcher;
-import org.eclipse.tcf.te.ui.trees.Pending;
-import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
-
-/**
- * The abstract implementation of ITreeSearcher which provides common utility methods
- * for traversing.
- */
-public abstract class AbstractSearcher implements ITreeSearcher {
- // The tree viewer to be searched.
- protected TreeViewer fViewer;
- // The searchable element.
- protected ISearchable fSearchable;
-
- /**
- * Create a searcher with the specified viewer and matcher.
- *
- * @param viewer The tree viewer to be searched.
- * @param searchable The matcher used to match tree nodes.
- */
- protected AbstractSearcher(TreeViewer viewer, ISearchable searchable) {
- fViewer = viewer;
- this.fSearchable = searchable;
- }
-
- /**
- * Update the children of the specified parent. If the data of the parent
- * is lazily loaded and not loaded yet, then load the data first, before getting
- * the children.
- *
- * @param parent The parent node to get the updated children from.
- * @param monitor The progress monitor used while loading data.
- * @return The updated children of the parent node.
- */
- protected Object[] getUpdatedChildren(final Object parent, final IProgressMonitor monitor) {
- if (parent instanceof Pending) return new Object[0];
- final ILazyLoader lazyLoader = getLazyLoader(parent);
- if (lazyLoader != null) {
- if(lazyLoader.isLeaf()) {
- return new Object[0];
- }
- if (!lazyLoader.isDataLoaded()) {
- try{
- lazyLoader.loadData(monitor);
- }catch(Exception e) {
- return new Object[0];
- }
- }
- }
- Object[] children = TreeViewerUtil.getSortedChildren(fViewer, parent);
- return children;
- }
-
- /**
- * Get a lazy loader from the specified element if it could be
- * adapted to a lazy loader.
- *
- * @param element The element to get the lazy loader from.
- * @return A lazy loader or null if it is not adapted to a lazy loader.
- */
- private ILazyLoader getLazyLoader(Object element) {
- ILazyLoader loader = null;
- if(element instanceof ILazyLoader) {
- loader = (ILazyLoader) element;
- }
- if(loader == null && element instanceof IAdaptable) {
- loader = (ILazyLoader)((IAdaptable)element).getAdapter(ILazyLoader.class);
- }
- if(loader == null) {
- loader = (ILazyLoader) Platform.getAdapterManager().getAdapter(element, ILazyLoader.class);
- }
- return loader;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.tcf.te.ui.interfaces.ILazyLoader;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+import org.eclipse.tcf.te.ui.interfaces.ITreeSearcher;
+import org.eclipse.tcf.te.ui.trees.Pending;
+import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
+
+/**
+ * The abstract implementation of ITreeSearcher which provides common utility methods
+ * for traversing.
+ */
+public abstract class AbstractSearcher implements ITreeSearcher {
+ // The tree viewer to be searched.
+ protected TreeViewer fViewer;
+ // The searchable element.
+ protected ISearchable fSearchable;
+
+ /**
+ * Create a searcher with the specified viewer and matcher.
+ *
+ * @param viewer The tree viewer to be searched.
+ * @param searchable The matcher used to match tree nodes.
+ */
+ protected AbstractSearcher(TreeViewer viewer, ISearchable searchable) {
+ fViewer = viewer;
+ this.fSearchable = searchable;
+ }
+
+ /**
+ * Update the children of the specified parent. If the data of the parent
+ * is lazily loaded and not loaded yet, then load the data first, before getting
+ * the children.
+ *
+ * @param parent The parent node to get the updated children from.
+ * @param monitor The progress monitor used while loading data.
+ * @return The updated children of the parent node.
+ */
+ protected Object[] getUpdatedChildren(final Object parent, final IProgressMonitor monitor) {
+ if (parent instanceof Pending) return new Object[0];
+ final ILazyLoader lazyLoader = getLazyLoader(parent);
+ if (lazyLoader != null) {
+ if(lazyLoader.isLeaf()) {
+ return new Object[0];
+ }
+ if (!lazyLoader.isDataLoaded()) {
+ try{
+ lazyLoader.loadData(monitor);
+ }catch(Exception e) {
+ return new Object[0];
+ }
+ }
+ }
+ Object[] children = TreeViewerUtil.getSortedChildren(fViewer, parent);
+ return children;
+ }
+
+ /**
+ * Get a lazy loader from the specified element if it could be
+ * adapted to a lazy loader.
+ *
+ * @param element The element to get the lazy loader from.
+ * @return A lazy loader or null if it is not adapted to a lazy loader.
+ */
+ private ILazyLoader getLazyLoader(Object element) {
+ ILazyLoader loader = null;
+ if(element instanceof ILazyLoader) {
+ loader = (ILazyLoader) element;
+ }
+ if(loader == null && element instanceof IAdaptable) {
+ loader = (ILazyLoader)((IAdaptable)element).getAdapter(ILazyLoader.class);
+ }
+ if(loader == null) {
+ loader = (ILazyLoader) Platform.getAdapterManager().getAdapter(element, ILazyLoader.class);
+ }
+ return loader;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/BreadthFirstSearcher.java
index 58b62e2e5..e98ab80f4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/BreadthFirstSearcher.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import java.lang.reflect.InvocationTargetException;
import java.util.Queue;
@@ -26,7 +26,7 @@ import org.eclipse.tcf.te.ui.interfaces.ISearchable;
*/
public class BreadthFirstSearcher extends AbstractSearcher{
// The queue to pre-populate the nodes to be matched
- private Queue<TreePath> queue;
+ private final Queue<TreePath> queue = new ConcurrentLinkedQueue<TreePath>();
/**
* Create a breadth-first searcher with the specified viewer and a
@@ -45,7 +45,7 @@ public class BreadthFirstSearcher extends AbstractSearcher{
*/
@Override
public void setStartPath(TreePath path) {
- this.queue = new ConcurrentLinkedQueue<TreePath>();
+ this.queue.clear();
Assert.isTrue(this.queue.offer(path));
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DelegateProgressMonitor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DelegateProgressMonitor.java
index a8ee84759..a22c6fe39 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DelegateProgressMonitor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DelegateProgressMonitor.java
@@ -1,174 +1,174 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ProgressMonitorWrapper;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * A progress monitor delegate that wraps the parent monitor
- * and delegates to a progress monitor part.
- */
-class DelegateProgressMonitor extends ProgressMonitorWrapper {
- // The progress monitor part to delegate the monitor call.
- ProgressMonitorPart fPmPart;
-
- /**
- * Create an instance with the parent monitor and a progress
- * monitor part.
- *
- * @param parent a parent monitor to wrap
- * @param mpart a progress monitor part to delegate to.
- */
- public DelegateProgressMonitor(IProgressMonitor parent, ProgressMonitorPart mpart) {
- super(parent);
- fPmPart = mpart;
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.attachToCancelComponent(null);
- fPmPart.setCanceled(false);
- fPmPart.setVisible(true);
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#beginTask(java.lang.String, int)
- */
- @Override
- public void beginTask(final String name, final int totalWork) {
- super.beginTask(name, totalWork);
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.beginTask(name, totalWork);
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#isCanceled()
- */
- @Override
- public boolean isCanceled() {
- return fPmPart != null && fPmPart.isCanceled() || super.isCanceled();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#subTask(java.lang.String)
- */
- @Override
- public void subTask(final String name) {
- super.subTask(name);
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.subTask(name);
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#done()
- */
- @Override
- public void done() {
- super.done();
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.done();
- fPmPart.setVisible(false);
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setTaskName(java.lang.String)
- */
- @Override
- public void setTaskName(final String name) {
- super.setTaskName(name);
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.setTaskName(name);
- }
- }
- });
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setCanceled(boolean)
- */
- @Override
- public void setCanceled(final boolean b) {
- super.setCanceled(b);
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.setCanceled(b);
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.ProgressMonitorWrapper#worked(int)
- */
- @Override
- public void worked(final int work) {
- super.worked(work);
- safeRun(new Runnable() {
- @Override
- public void run() {
- if (fPmPart != null && !fPmPart.isDisposed()) {
- fPmPart.worked(work);
- }
- }
- });
- }
-
- /**
- * Run the runnable in a UI thread asynchronously.
- *
- * @param runnable The runnable to schedule.
- */
- void safeRun(Runnable runnable) {
- if(Display.getCurrent() != null) {
- runnable.run();
- }
- else {
- PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * A progress monitor delegate that wraps the parent monitor
+ * and delegates to a progress monitor part.
+ */
+class DelegateProgressMonitor extends ProgressMonitorWrapper {
+ // The progress monitor part to delegate the monitor call.
+ ProgressMonitorPart fPmPart;
+
+ /**
+ * Create an instance with the parent monitor and a progress
+ * monitor part.
+ *
+ * @param parent a parent monitor to wrap
+ * @param mpart a progress monitor part to delegate to.
+ */
+ public DelegateProgressMonitor(IProgressMonitor parent, ProgressMonitorPart mpart) {
+ super(parent);
+ fPmPart = mpart;
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.attachToCancelComponent(null);
+ fPmPart.setCanceled(false);
+ fPmPart.setVisible(true);
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#beginTask(java.lang.String, int)
+ */
+ @Override
+ public void beginTask(final String name, final int totalWork) {
+ super.beginTask(name, totalWork);
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.beginTask(name, totalWork);
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#isCanceled()
+ */
+ @Override
+ public boolean isCanceled() {
+ return fPmPart != null && fPmPart.isCanceled() || super.isCanceled();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#subTask(java.lang.String)
+ */
+ @Override
+ public void subTask(final String name) {
+ super.subTask(name);
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.subTask(name);
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#done()
+ */
+ @Override
+ public void done() {
+ super.done();
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.done();
+ fPmPart.setVisible(false);
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setTaskName(java.lang.String)
+ */
+ @Override
+ public void setTaskName(final String name) {
+ super.setTaskName(name);
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.setTaskName(name);
+ }
+ }
+ });
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setCanceled(boolean)
+ */
+ @Override
+ public void setCanceled(final boolean b) {
+ super.setCanceled(b);
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.setCanceled(b);
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.ProgressMonitorWrapper#worked(int)
+ */
+ @Override
+ public void worked(final int work) {
+ super.worked(work);
+ safeRun(new Runnable() {
+ @Override
+ public void run() {
+ if (fPmPart != null && !fPmPart.isDisposed()) {
+ fPmPart.worked(work);
+ }
+ }
+ });
+ }
+
+ /**
+ * Run the runnable in a UI thread asynchronously.
+ *
+ * @param runnable The runnable to schedule.
+ */
+ void safeRun(Runnable runnable) {
+ if(Display.getCurrent() != null) {
+ runnable.run();
+ }
+ else {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DepthFirstSearcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DepthFirstSearcher.java
index 19a1f013b..f31de7950 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/DepthFirstSearcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/DepthFirstSearcher.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import java.lang.reflect.InvocationTargetException;
import java.util.LinkedList;
@@ -38,38 +38,38 @@ public class DepthFirstSearcher extends AbstractSearcher {
}
}
// The searching stack in which searching contexts are stored.
- private LinkedList<StackElement> fSearchStack;
+ private final LinkedList<StackElement> fSearchStack = new LinkedList<StackElement>();
// The searching direction.
private boolean fForeward;
/**
* Create a depth-first searcher with the specified viewer and a
* matcher.
- *
+ *
* @param viewer The tree viewer.
* @param matcher The search matcher used match a single tree node.
*/
public DepthFirstSearcher(TreeViewer viewer, ISearchable searchable) {
super(viewer, searchable);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ITreeSearcher#setStartPath(org.eclipse.jface.viewers.TreePath)
*/
@Override
public void setStartPath(TreePath path) {
- fSearchStack = new LinkedList<StackElement>();
+ fSearchStack.clear();
if (path == null) {
Object obj = fViewer.getInput();
path = new TreePath(new Object[] { obj });
}
initSearchContext(path);
}
-
+
/**
* Set the searching direction.
- *
+ *
* @param foreward searching direction.
*/
public void setForeward(boolean foreward) {
@@ -78,7 +78,7 @@ public class DepthFirstSearcher extends AbstractSearcher {
/**
* Populate the stacks with initial path.
- *
+ *
* @param start The initial path.
*/
private void initSearchContext(TreePath start) {
@@ -105,7 +105,7 @@ public class DepthFirstSearcher extends AbstractSearcher {
/**
* Search the tree using a matcher using DFS algorithm.
- *
+ *
* @param monitor The monitor reporting the progress.
* @return The tree path whose leaf node satisfies the searching rule.
*/
@@ -147,10 +147,10 @@ public class DepthFirstSearcher extends AbstractSearcher {
}
return result;
}
-
+
/**
* Create a path using the current elements of the stack.
- *
+ *
* @return The tree path representing the path of the stack.
*/
private TreePath createContextPath() {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/FilteringImageDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/FilteringImageDescriptor.java
index 5d7229273..838bc0dc0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/FilteringImageDescriptor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/FilteringImageDescriptor.java
@@ -8,7 +8,7 @@
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilter.java
index bd363ba43..88de170f0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilter.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilterPopup.java
index 9dc1cdcfb..002f1b147 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/QuickFilterPopup.java
@@ -1,216 +1,216 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import org.eclipse.jface.dialogs.PopupDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.tcf.te.ui.nls.Messages;
-
-/**
- * A pop up dialog to input the filter text for the quick filter.
- * The filter will to listen to the change of the input and
- * filter the tree viewer accordingly.
- */
-public class QuickFilterPopup extends PopupDialog {
- // The quick filter used filter the content of the tree viewer.
- QuickFilter quickFilter;
- // The text field used to enter filters.
- Text filterText;
- // The initial filter displayed in the filter text field.
- String filter;
- // The tree viewer that it works on.
- TreeViewer treeViewer;
-
- /**
- * Create a pop up for the specified tree viewer using the quick filter.
- *
- * @param viewer The tree viewer to be filtered.
- * @param qFilter The quick filter used to filter the tree viewer.
- */
- public QuickFilterPopup(TreeViewer viewer, QuickFilter qFilter) {
- super(viewer.getTree().getShell(), SWT.TOOL, true, true, false, false, false, null, null);
- quickFilter = qFilter;
- treeViewer = viewer;
- if(quickFilter.getFilterText() != null) {
- filter = quickFilter.getFilterText();
- }
- else {
- filter = Messages.QuickFilterPopup_PromptMessage;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- GridLayout layout = (GridLayout) composite.getLayout();
- layout.marginHeight = 2;
- filterText = new Text(composite, SWT.SINGLE);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = 185;
- filterText.setLayoutData(data);
- filterText.setText(filter);
- filterText.setFont(composite.getFont());
- filterText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- getAccessibleName(e);
- }
- });
- filterText.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- filterTextFocusGained(e);
- }
- });
- filterText.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- filterTextMouseUp(e);
- }
- });
- filterText.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- filterTextKeyPressed(e);
- }
- });
- // enter key set focus to tree
- filterText.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- filterTextKeyTraversed(e);
- }
- });
- filterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- filterTextModifyText(e);
- }
- });
- return composite;
- }
-
- /**
- * Get accessible name for the filter text field.
- *
- * @param e The accessible event.
- */
- protected void getAccessibleName(AccessibleEvent e) {
- String filterTextString = filterText.getText();
- if (filterTextString.length() == 0) {
- e.result = filter;
- }
- else {
- e.result = filterTextString;
- }
- }
-
- /**
- * Called when the filter text field gains focus.
- *
- * @param e The focus event.
- */
- protected void filterTextFocusGained(FocusEvent e) {
- if (filter.equals(filterText.getText().trim())) {
- filterText.selectAll();
- }
- }
-
- /**
- * Called when a mouse up event happens to the filter text field.
- *
- * @param e The mouse up event.
- */
- protected void filterTextMouseUp(MouseEvent e) {
- if (filter.equals(filterText.getText().trim())) {
- filterText.selectAll();
- }
- }
-
- /**
- * Called when a key event happens to the filter text field.
- *
- * @param e The key event.
- */
- protected void filterTextKeyPressed(KeyEvent e) {
- boolean hasItems = treeViewer.getTree().getItemCount() > 0;
- if (hasItems && e.keyCode == SWT.ARROW_DOWN) {
- treeViewer.getTree().setFocus();
- }
- }
-
- /**
- * Called when a traverse event happens to the filter text field.
- *
- * @param e The traverse event.
- */
- protected void filterTextKeyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_ESCAPE) {
- quickFilter.resetViewer();
- }
- if (e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- if (treeViewer.getTree().getItemCount() == 0) {
- Display.getCurrent().beep();
- }
- else {
- // if the initial filter text hasn't changed, do not try to match
- boolean hasFocus = treeViewer.getTree().setFocus();
- boolean textChanged = !filter.equals(filterText.getText().trim());
- if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
- TreeItem[] items = treeViewer.getTree().getItems();
- for (TreeItem item : items) {
- if (quickFilter.match(item.getText())) {
- treeViewer.getTree().setSelection(new TreeItem[] { item });
- ISelection sel = treeViewer.getSelection();
- treeViewer.setSelection(sel, true);
- break;
- }
- }
- }
- }
- }
- }
-
- /**
- * Called when a text modification event happens.
- *
- * @param e The modification event.
- */
- protected void filterTextModifyText(ModifyEvent e) {
- quickFilter.setPattern(filterText.getText());
- quickFilter.adjustPopup(getShell());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import org.eclipse.jface.dialogs.PopupDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.tcf.te.ui.nls.Messages;
+
+/**
+ * A pop up dialog to input the filter text for the quick filter.
+ * The filter will to listen to the change of the input and
+ * filter the tree viewer accordingly.
+ */
+public class QuickFilterPopup extends PopupDialog {
+ // The quick filter used filter the content of the tree viewer.
+ QuickFilter quickFilter;
+ // The text field used to enter filters.
+ Text filterText;
+ // The initial filter displayed in the filter text field.
+ String filter;
+ // The tree viewer that it works on.
+ TreeViewer treeViewer;
+
+ /**
+ * Create a pop up for the specified tree viewer using the quick filter.
+ *
+ * @param viewer The tree viewer to be filtered.
+ * @param qFilter The quick filter used to filter the tree viewer.
+ */
+ public QuickFilterPopup(TreeViewer viewer, QuickFilter qFilter) {
+ super(viewer.getTree().getShell(), SWT.TOOL, true, true, false, false, false, null, null);
+ quickFilter = qFilter;
+ treeViewer = viewer;
+ if(quickFilter.getFilterText() != null) {
+ filter = quickFilter.getFilterText();
+ }
+ else {
+ filter = Messages.QuickFilterPopup_PromptMessage;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridLayout layout = (GridLayout) composite.getLayout();
+ layout.marginHeight = 2;
+ filterText = new Text(composite, SWT.SINGLE);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 185;
+ filterText.setLayoutData(data);
+ filterText.setText(filter);
+ filterText.setFont(composite.getFont());
+ filterText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ getAccessibleName(e);
+ }
+ });
+ filterText.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ filterTextFocusGained(e);
+ }
+ });
+ filterText.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ filterTextMouseUp(e);
+ }
+ });
+ filterText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ filterTextKeyPressed(e);
+ }
+ });
+ // enter key set focus to tree
+ filterText.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ filterTextKeyTraversed(e);
+ }
+ });
+ filterText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ filterTextModifyText(e);
+ }
+ });
+ return composite;
+ }
+
+ /**
+ * Get accessible name for the filter text field.
+ *
+ * @param e The accessible event.
+ */
+ protected void getAccessibleName(AccessibleEvent e) {
+ String filterTextString = filterText.getText();
+ if (filterTextString.length() == 0) {
+ e.result = filter;
+ }
+ else {
+ e.result = filterTextString;
+ }
+ }
+
+ /**
+ * Called when the filter text field gains focus.
+ *
+ * @param e The focus event.
+ */
+ protected void filterTextFocusGained(FocusEvent e) {
+ if (filter.equals(filterText.getText().trim())) {
+ filterText.selectAll();
+ }
+ }
+
+ /**
+ * Called when a mouse up event happens to the filter text field.
+ *
+ * @param e The mouse up event.
+ */
+ protected void filterTextMouseUp(MouseEvent e) {
+ if (filter.equals(filterText.getText().trim())) {
+ filterText.selectAll();
+ }
+ }
+
+ /**
+ * Called when a key event happens to the filter text field.
+ *
+ * @param e The key event.
+ */
+ protected void filterTextKeyPressed(KeyEvent e) {
+ boolean hasItems = treeViewer.getTree().getItemCount() > 0;
+ if (hasItems && e.keyCode == SWT.ARROW_DOWN) {
+ treeViewer.getTree().setFocus();
+ }
+ }
+
+ /**
+ * Called when a traverse event happens to the filter text field.
+ *
+ * @param e The traverse event.
+ */
+ protected void filterTextKeyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_ESCAPE) {
+ quickFilter.resetViewer();
+ }
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
+ if (treeViewer.getTree().getItemCount() == 0) {
+ Display.getCurrent().beep();
+ }
+ else {
+ // if the initial filter text hasn't changed, do not try to match
+ boolean hasFocus = treeViewer.getTree().setFocus();
+ boolean textChanged = !filter.equals(filterText.getText().trim());
+ if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
+ TreeItem[] items = treeViewer.getTree().getItems();
+ for (TreeItem item : items) {
+ if (quickFilter.match(item.getText())) {
+ treeViewer.getTree().setSelection(new TreeItem[] { item });
+ ISelection sel = treeViewer.getSelection();
+ treeViewer.setSelection(sel, true);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Called when a text modification event happens.
+ *
+ * @param e The modification event.
+ */
+ protected void filterTextModifyText(ModifyEvent e) {
+ quickFilter.setPattern(filterText.getText());
+ quickFilter.adjustPopup(getShell());
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchEngine.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchEngine.java
index 263133719..2a6f639b5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchEngine.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchEngine.java
@@ -1,223 +1,223 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.tcf.te.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.interfaces.ISearchCallback;
-import org.eclipse.tcf.te.ui.interfaces.ISearchable;
-import org.eclipse.tcf.te.ui.nls.Messages;
-
-/**
- * The search engine used to search a tree viewer.
- */
-public class SearchEngine {
- // The search engine used search the tree
- AbstractSearcher fSearcher;
- // The searching job.
- Job fSearchJob;
- // The viewer being searched.
- TreeViewer fViewer;
- // If the search algorithm is depth preferable
- boolean fDepthFirst;
- // The search matcher used to match tree nodes during traversing.
- ISearchable fSearchable;
- // The current starting path of the searcher engine.
- TreePath fStartPath;
- // Whether it is wrap search.
- boolean fWrap;
- // The last result being searched.
- TreePath fLastResult;
-
- /**
- * Create an instance for the tree viewer.
- *
- * @param viewer The tree viewer.
- * @param depthFirst
- */
- public SearchEngine(TreeViewer viewer, boolean depthFirst, ISearchable searchable, TreePath path) {
- fViewer = viewer;
- fDepthFirst = depthFirst;
- fSearchable = searchable;
- fStartPath = path;
- fSearcher = fDepthFirst ? new DepthFirstSearcher(fViewer, fSearchable) : new BreadthFirstSearcher(fViewer, fSearchable);
- fSearcher.setStartPath(path);
- }
-
- /**
- * If the current algorithm is DFS.
- *
- * @return true if it is DFS.
- */
- public boolean isDepthFirst() {
- return fDepthFirst;
- }
-
- /**
- * Set the algorithm to depth-first according the boolean.
- *
- * @param depthFirst
- */
- public void setDepthFirst(boolean depthFirst) {
- if (fDepthFirst != depthFirst) {
- fDepthFirst = depthFirst;
- fSearcher = fDepthFirst ? new DepthFirstSearcher(fViewer, fSearchable) : new BreadthFirstSearcher(fViewer, fSearchable);
- fSearcher.setStartPath(fStartPath);
- }
- }
-
- /**
- * Set the initial searching path.
- *
- * @param path The initial searching path.
- */
- public void setStartPath(TreePath path) {
- fStartPath = path;
- fSearcher.setStartPath(path);
- }
-
- /**
- * Reset the searching path.
- */
- public void resetPath() {
- fSearcher.setStartPath(fStartPath);
- }
-
- /**
- * Clean up the searching job.
- */
- public void endSearch() {
- if (fSearchJob != null) {
- fSearchJob.cancel();
- fSearchJob = null;
- }
- }
-
- /**
- * Start searching using the progress monitor part and invoke the callback
- * after a node is found.
- *
- * @param callback The callback to invoked.
- * @param pmpart The progress monitor part.
- */
- public void startSearch(final ISearchCallback callback, final ProgressMonitorPart pmpart) {
- final TreePath[] result = new TreePath[1];
- fSearchJob = new Job(Messages.TreeViewerSearchDialog_JobName) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor = new DelegateProgressMonitor(monitor, pmpart);
- monitor.beginTask(Messages.TreeViewerSearchDialog_MainTaskName, IProgressMonitor.UNKNOWN);
- try {
- result[0] = fSearcher.searchNext(monitor);
- }
- catch (InvocationTargetException e) {
- Status status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getMessage(), e);
- return status;
- }
- catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- }
- finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
- };
- fSearchJob.setSystem(true);
- fSearchJob.addJobChangeListener(new JobChangeAdapter() {
- @Override
- public void done(final IJobChangeEvent event) {
- fViewer.getTree().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- IStatus status = event.getResult();
- TreePath treePath = result[0];
- if (callback != null) callback.searchDone(status, treePath);
- searchDone(status, treePath);
- fSearchJob = null;
- if (status.isOK() && treePath == null && fWrap && fLastResult != null) {
- fLastResult = null;
- startSearch(callback, pmpart);
- }
- }
- });
- }
- });
- fSearchJob.schedule();
- }
-
- /**
- * Set the searching direction, only valid for DFS.
- *
- * @param foreward The searching direction.
- */
- public void setForeward(boolean foreward) {
- if (fDepthFirst && fSearcher instanceof DepthFirstSearcher) {
- ((DepthFirstSearcher) fSearcher).setForeward(foreward);
- }
- }
-
- /**
- * The method called after the searching is done.
- *
- * @param status The searching result status.
- * @param path The searching result, or null if no path is found.
- */
- void searchDone(IStatus status, TreePath path) {
- if (status.isOK()) {
- if (path != null) {
- fLastResult = path;
- fViewer.expandToLevel(path, 0);
- fViewer.setSelection(new StructuredSelection(new Object[] { path }), true);
- }
- else if (fWrap && fLastResult != null) {
- setStartPath(fLastResult);
- }
- }
- }
-
- /**
- * If the current search is wrap search.
- *
- * @return true if it is wrap search.
- */
- public boolean isWrap() {
- return fWrap;
- }
-
- /**
- * Set the current searching to wrap search.
- *
- * @param wrap
- */
- public void setWrap(boolean wrap) {
- fWrap = wrap;
- }
-
- /**
- * Get the last searched path.
- *
- * @return The last searched path.
- */
- public TreePath getLastResult() {
- return fLastResult;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.interfaces.ISearchCallback;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+import org.eclipse.tcf.te.ui.nls.Messages;
+
+/**
+ * The search engine used to search a tree viewer.
+ */
+public class SearchEngine {
+ // The search engine used search the tree
+ AbstractSearcher fSearcher;
+ // The searching job.
+ Job fSearchJob;
+ // The viewer being searched.
+ TreeViewer fViewer;
+ // If the search algorithm is depth preferable
+ boolean fDepthFirst;
+ // The search matcher used to match tree nodes during traversing.
+ ISearchable fSearchable;
+ // The current starting path of the searcher engine.
+ TreePath fStartPath;
+ // Whether it is wrap search.
+ boolean fWrap;
+ // The last result being searched.
+ TreePath fLastResult;
+
+ /**
+ * Create an instance for the tree viewer.
+ *
+ * @param viewer The tree viewer.
+ * @param depthFirst
+ */
+ public SearchEngine(TreeViewer viewer, boolean depthFirst, ISearchable searchable, TreePath path) {
+ fViewer = viewer;
+ fDepthFirst = depthFirst;
+ fSearchable = searchable;
+ fStartPath = path;
+ fSearcher = fDepthFirst ? new DepthFirstSearcher(fViewer, fSearchable) : new BreadthFirstSearcher(fViewer, fSearchable);
+ fSearcher.setStartPath(path);
+ }
+
+ /**
+ * If the current algorithm is DFS.
+ *
+ * @return true if it is DFS.
+ */
+ public boolean isDepthFirst() {
+ return fDepthFirst;
+ }
+
+ /**
+ * Set the algorithm to depth-first according the boolean.
+ *
+ * @param depthFirst
+ */
+ public void setDepthFirst(boolean depthFirst) {
+ if (fDepthFirst != depthFirst) {
+ fDepthFirst = depthFirst;
+ fSearcher = fDepthFirst ? new DepthFirstSearcher(fViewer, fSearchable) : new BreadthFirstSearcher(fViewer, fSearchable);
+ fSearcher.setStartPath(fStartPath);
+ }
+ }
+
+ /**
+ * Set the initial searching path.
+ *
+ * @param path The initial searching path.
+ */
+ public void setStartPath(TreePath path) {
+ fStartPath = path;
+ fSearcher.setStartPath(path);
+ }
+
+ /**
+ * Reset the searching path.
+ */
+ public void resetPath() {
+ fSearcher.setStartPath(fStartPath);
+ }
+
+ /**
+ * Clean up the searching job.
+ */
+ public void endSearch() {
+ if (fSearchJob != null) {
+ fSearchJob.cancel();
+ fSearchJob = null;
+ }
+ }
+
+ /**
+ * Start searching using the progress monitor part and invoke the callback
+ * after a node is found.
+ *
+ * @param callback The callback to invoked.
+ * @param pmpart The progress monitor part.
+ */
+ public void startSearch(final ISearchCallback callback, final ProgressMonitorPart pmpart) {
+ final TreePath[] result = new TreePath[1];
+ fSearchJob = new Job(Messages.TreeViewerSearchDialog_JobName) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor = new DelegateProgressMonitor(monitor, pmpart);
+ monitor.beginTask(Messages.TreeViewerSearchDialog_MainTaskName, IProgressMonitor.UNKNOWN);
+ try {
+ result[0] = fSearcher.searchNext(monitor);
+ }
+ catch (InvocationTargetException e) {
+ Status status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getMessage(), e);
+ return status;
+ }
+ catch (InterruptedException e) {
+ return Status.CANCEL_STATUS;
+ }
+ finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ fSearchJob.setSystem(true);
+ fSearchJob.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(final IJobChangeEvent event) {
+ fViewer.getTree().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IStatus status = event.getResult();
+ TreePath treePath = result[0];
+ if (callback != null) callback.searchDone(status, treePath);
+ searchDone(status, treePath);
+ fSearchJob = null;
+ if (status.isOK() && treePath == null && fWrap && fLastResult != null) {
+ fLastResult = null;
+ startSearch(callback, pmpart);
+ }
+ }
+ });
+ }
+ });
+ fSearchJob.schedule();
+ }
+
+ /**
+ * Set the searching direction, only valid for DFS.
+ *
+ * @param foreward The searching direction.
+ */
+ public void setForeward(boolean foreward) {
+ if (fDepthFirst && fSearcher instanceof DepthFirstSearcher) {
+ ((DepthFirstSearcher) fSearcher).setForeward(foreward);
+ }
+ }
+
+ /**
+ * The method called after the searching is done.
+ *
+ * @param status The searching result status.
+ * @param path The searching result, or null if no path is found.
+ */
+ void searchDone(IStatus status, TreePath path) {
+ if (status.isOK()) {
+ if (path != null) {
+ fLastResult = path;
+ fViewer.expandToLevel(path, 0);
+ fViewer.setSelection(new StructuredSelection(new Object[] { path }), true);
+ }
+ else if (fWrap && fLastResult != null) {
+ resetPath();
+ }
+ }
+ }
+
+ /**
+ * If the current search is wrap search.
+ *
+ * @return true if it is wrap search.
+ */
+ public boolean isWrap() {
+ return fWrap;
+ }
+
+ /**
+ * Set the current searching to wrap search.
+ *
+ * @param wrap
+ */
+ public void setWrap(boolean wrap) {
+ fWrap = wrap;
+ }
+
+ /**
+ * Get the last searched path.
+ *
+ * @return The last searched path.
+ */
+ public TreePath getLastResult() {
+ return fLastResult;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchMatcher.java
index 904743d11..7547d9d44 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/SearchMatcher.java
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * A search matcher implementation that support
- * common searching options.
- */
-public class SearchMatcher implements ISearchMatcher {
- // The text to be searched.
- private String fSearchTarget;
- // Whether it is case sensitive
- private boolean fCaseSensitive;
- // Whether it is precise matching.
- private boolean fMatchPrecise;
- // The viewer being searched.
- private TreeViewer fViewer;
-
- /**
- * Create a search matcher with the tree viewer.
- *
- * @param viewer The tree viewer to create a matcher for.
- */
- public SearchMatcher(TreeViewer viewer) {
- fViewer = viewer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
- */
- @Override
- public boolean match(Object context) {
- if (context == null) return false;
- String text = getElementText(context);
- if (text == null) return false;
- String target = fSearchTarget;
- if (!fCaseSensitive) {
- text = text.toLowerCase();
- target = fSearchTarget != null ? fSearchTarget.toLowerCase() : null;
- }
- if (fMatchPrecise) return text.equals(target);
- return text.indexOf(target) != -1;
- }
-
- /**
- * Get the text representation of a element using the label provider of the tree viewer. Note:
- * this method could be called at any thread.
- *
- * @param element The element.
- * @return The text representation.
- */
- public String getElementText(final Object element) {
- if (Display.getCurrent() != null) {
- if (element == fViewer.getInput()) return null;
- ILabelProvider labelProvider = (ILabelProvider) fViewer.getLabelProvider();
- if (labelProvider != null) {
- return labelProvider.getText(element);
- }
- return element == null ? "" : element.toString(); //$NON-NLS-1$
- }
- final String[] result = new String[1];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- result[0] = getElementText(element);
- }
- });
- return result[0];
- }
-
- /**
- * Set the searching target.
- *
- * @param target The target node's matching string.
- */
- public void setMatchTarget(String target) {
- fSearchTarget = target;
- }
-
- /**
- * Set if the searching is case-sensitive.
- *
- * @param caseSensitive
- */
- public void setCaseSensitive(boolean caseSensitive) {
- fCaseSensitive = caseSensitive;
- }
-
- /**
- * Set if the searching is to match precisely.
- *
- * @param matchPrecise
- */
- public void setMatchPrecise(boolean matchPrecise) {
- fMatchPrecise = matchPrecise;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * A search matcher implementation that support
+ * common searching options.
+ */
+public class SearchMatcher implements ISearchMatcher {
+ // The text to be searched.
+ private String fSearchTarget;
+ // Whether it is case sensitive
+ private boolean fCaseSensitive;
+ // Whether it is precise matching.
+ private boolean fMatchPrecise;
+ // The viewer being searched.
+ private TreeViewer fViewer;
+
+ /**
+ * Create a search matcher with the tree viewer.
+ *
+ * @param viewer The tree viewer to create a matcher for.
+ */
+ public SearchMatcher(TreeViewer viewer) {
+ fViewer = viewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
+ */
+ @Override
+ public boolean match(Object context) {
+ if (context == null) return false;
+ String text = getElementText(context);
+ if (text == null) return false;
+ String target = fSearchTarget;
+ if (!fCaseSensitive) {
+ text = text.toLowerCase();
+ target = fSearchTarget != null ? fSearchTarget.toLowerCase() : null;
+ }
+ if (fMatchPrecise) return text.equals(target);
+ return text.indexOf(target) != -1;
+ }
+
+ /**
+ * Get the text representation of a element using the label provider of the tree viewer. Note:
+ * this method could be called at any thread.
+ *
+ * @param element The element.
+ * @return The text representation.
+ */
+ public String getElementText(final Object element) {
+ if (Display.getCurrent() != null) {
+ if (element == fViewer.getInput()) return null;
+ ILabelProvider labelProvider = (ILabelProvider) fViewer.getLabelProvider();
+ if (labelProvider != null) {
+ return labelProvider.getText(element);
+ }
+ return element == null ? "" : element.toString(); //$NON-NLS-1$
+ }
+ final String[] result = new String[1];
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = getElementText(element);
+ }
+ });
+ return result[0];
+ }
+
+ /**
+ * Set the searching target.
+ *
+ * @param target The target node's matching string.
+ */
+ public void setMatchTarget(String target) {
+ fSearchTarget = target;
+ }
+
+ /**
+ * Set if the searching is case-sensitive.
+ *
+ * @param caseSensitive
+ */
+ public void setCaseSensitive(boolean caseSensitive) {
+ fCaseSensitive = caseSensitive;
+ }
+
+ /**
+ * Set if the searching is to match precisely.
+ *
+ * @param matchPrecise
+ */
+ public void setMatchPrecise(boolean matchPrecise) {
+ fMatchPrecise = matchPrecise;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/StringMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/StringMatcher.java
index 4ee0d2b2d..bc43e7af1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/StringMatcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/StringMatcher.java
@@ -1,493 +1,493 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012, 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
-
-import java.util.Vector;
-
-/**
- * A string pattern matcher, supporting "*" and "?" wild cards.
- * <p>
- * Copied from org.eclipse.ui.internal.navigator.StringMatcher
- */
-class StringMatcher {
- protected String fPattern;
-
- protected int fLength; // pattern length
-
- protected boolean fIgnoreWildCards;
-
- protected boolean fIgnoreCase;
-
- protected boolean fHasLeadingStar;
-
- protected boolean fHasTrailingStar;
-
- protected String fSegments[]; // the given pattern is split into *
-
- // separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound = 0;
-
- protected static final char fSingleWildCard = '\u0000';
-
- /**
- *
- */
- static class Position {
- int start; // inclusive
-
- int end; // exclusive
-
- Position(int start, int end) {
- this.start = start;
- this.end = end;
- }
-
- int getStart() {
- return start;
- }
-
- int getEnd() {
- return end;
- }
- }
-
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain '*' for 0 and many characters and '?' for
- * exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
- * means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern. e.g., "\a" means "a" and
- * "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param pattern
- * the pattern to match text against
- * @param ignoreCase
- * if true, case is ignored
- * @param ignoreWildCards
- * if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String pattern, boolean ignoreCase,
- boolean ignoreWildCards) {
- if (pattern == null) {
- throw new IllegalArgumentException();
- }
- fIgnoreCase = ignoreCase;
- fIgnoreWildCards = ignoreWildCards;
- fPattern = pattern;
- fLength = pattern.length();
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
-
- /**
- * Find the first occurrence of the pattern between
- * <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param text the String object to search in
- * @param start the starting index of the search range, inclusive
- * @param end the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
- public StringMatcher.Position find(String text, int start, int end) {
- if (text == null) {
- throw new IllegalArgumentException();
- }
-
- int tlen = text.length();
- if (start < 0) {
- start = 0;
- }
- if (end > tlen) {
- end = tlen;
- }
- if (end < 0 || start >= end) {
- return null;
- }
- if (fLength == 0) {
- return new Position(start, start);
- }
- if (fIgnoreWildCards) {
- int x = posIn(text, start, end);
- if (x < 0) {
- return null;
- }
- return new Position(x, x + fLength);
- }
-
- int segCount = fSegments.length;
- if (segCount == 0) {
- return new Position(start, end);
- }
-
- int curPos = start;
- int matchStart = -1;
- int i;
- for (i = 0; i < segCount && curPos < end; ++i) {
- String current = fSegments[i];
- int nextMatch = regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0) {
- return null;
- }
- if (i == 0) {
- matchStart = nextMatch;
- }
- curPos = nextMatch + current.length();
- }
- if (i < segCount) {
- return null;
- }
- return new Position(matchStart, curPos);
- }
-
- /**
- * match the given <code>text</code> with the pattern
- *
- * @return true if matched eitherwise false
- * @param text
- * a String object
- */
- public boolean match(String text) {
- if (text == null) {
- return false;
- }
- return match(text, 0, text.length());
- }
-
- /**
- * Given the starting (inclusive) and the ending (exclusive) positions in
- * the <code>text</code>, determine if the given substring matches with
- * aPattern
- *
- * @return true if the specified portion of the text matches the pattern
- * @param text
- * a String object that contains the substring to match
- * @param start
- * marks the starting position (inclusive) of the substring
- * @param end
- * marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == text) {
- throw new IllegalArgumentException();
- }
-
- if (start > end) {
- return false;
- }
-
- if (fIgnoreWildCards) {
- return (end - start == fLength)
- && fPattern.regionMatches(fIgnoreCase, 0, text, start,
- fLength);
- }
- int segCount = fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) {
- // contains
- // only
- // '*'(s)
- return true;
- }
- if (start == end) {
- return fLength == 0;
- }
- if (fLength == 0) {
- return start == end;
- }
-
- int tlen = text.length();
- if (start < 0) {
- start = 0;
- }
- if (end > tlen) {
- end = tlen;
- }
-
- int tCurPos = start;
- int bound = end - fBound;
- if (bound < 0) {
- return false;
- }
- int i = 0;
- String current = fSegments[i];
- int segLength = current.length();
-
- /* process first segment */
- if (!fHasLeadingStar) {
- if (!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- }
- ++i;
- tCurPos = tCurPos + segLength;
-
- }
- if ((fSegments.length == 1) && (!fHasLeadingStar)
- && (!fHasTrailingStar)) {
- // only one segment to match, no wildcards specified
- return tCurPos == end;
- }
- /* process middle segments */
- while (i < segCount) {
- current = fSegments[i];
- int currentMatch;
- int k = current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch = textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0) {
- return false;
- }
- } else {
- currentMatch = regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0) {
- return false;
- }
- }
- tCurPos = currentMatch + current.length();
- i++;
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen = current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount;
- }
-
- /**
- * This method parses the given pattern into segments seperated by wildcard
- * '*' characters. Since wildcards are not being used in this case, the
- * pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments = new String[1];
- fSegments[0] = fPattern;
- fBound = fLength;
- }
-
- /**
- * Parses the given pattern into segments seperated by wildcard '*'
- * characters.
- *
- */
- private void parseWildCards() {
- if (fPattern.startsWith("*")) { //$NON-NLS-1$
- fHasLeadingStar = true;
- }
- if (fPattern.endsWith("*")) {//$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar = true;
- }
- }
-
- Vector<Object> temp = new Vector<Object>();
-
- int pos = 0;
- StringBuffer buf = new StringBuffer();
- while (pos < fLength) {
- char c = fPattern.charAt(pos++);
- switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next = fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- fBound += buf.length();
- }
-
- fSegments = new String[temp.size()];
- temp.copyInto(fSegments);
- }
-
- /**
- * @param text
- * a string which contains no wildcard
- * @param start
- * the starting index in the text for search, inclusive
- * @param end
- * the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not
- * found
- */
- protected int posIn(String text, int start, int end) {// no wild card in
- // pattern
- int max = end - fLength;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(fPattern, start);
- if (i == -1 || i > max) {
- return -1;
- }
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength)) {
- return i;
- }
- }
-
- return -1;
- }
-
- /**
- * @param text
- * a simple regular expression that may only contain '?'(s)
- * @param start
- * the starting index in the text for search, inclusive
- * @param end
- * the stopping point of search, exclusive
- * @param p
- * a simple regular expression that may contains '?'
- * @return the starting index in the text of the pattern , or -1 if not
- * found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen = p.length();
-
- int max = end - plen;
- for (int i = start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen)) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- *
- * @return boolean
- * @param text
- * a String to match
- * @param tStart
- * indicates the starting index of match, inclusive
- * @param p
- * a simple regular expression that may contain '?'
- * @param pStart
- * @param plen
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p,
- int pStart, int plen) {
- while (plen-- > 0) {
- char tchar = text.charAt(tStart++);
- char pchar = p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar) {
- continue;
- }
- if (fIgnoreCase) {
- if (Character.toUpperCase(tchar) == Character
- .toUpperCase(pchar)) {
- continue;
- }
- // comparing after converting to upper case doesn't handle all
- // cases;
- // also compare after converting to lower case
- if (Character.toLowerCase(tchar) == Character
- .toLowerCase(pchar)) {
- continue;
- }
- }
- return false;
- }
- return true;
- }
-
- /**
- * @param text
- * the string to match
- * @param start
- * the starting index in the text for search, inclusive
- * @param end
- * the stopping point of search, exclusive
- * @param p
- * a string that has no wildcard
- * @return the starting index in the text of the pattern , or -1 if not
- * found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen = p.length();
- int max = end - plen;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(p, start);
- if (i == -1 || i > max) {
- return -1;
- }
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen)) {
- return i;
- }
- }
-
- return -1;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2000, 2012, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.search;
+
+import java.util.Vector;
+
+/**
+ * A string pattern matcher, supporting "*" and "?" wild cards.
+ * <p>
+ * Copied from org.eclipse.ui.internal.navigator.StringMatcher
+ */
+class StringMatcher {
+ protected String fPattern;
+
+ protected int fLength; // pattern length
+
+ protected boolean fIgnoreWildCards;
+
+ protected boolean fIgnoreCase;
+
+ protected boolean fHasLeadingStar;
+
+ protected boolean fHasTrailingStar;
+
+ protected String fSegments[]; // the given pattern is split into *
+
+ // separated segments
+
+ /* boundary value beyond which we don't need to search in the text */
+ protected int fBound = 0;
+
+ protected static final char fSingleWildCard = '\u0000';
+
+ /**
+ *
+ */
+ static class Position {
+ int start; // inclusive
+
+ int end; // exclusive
+
+ Position(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ int getStart() {
+ return start;
+ }
+
+ int getEnd() {
+ return end;
+ }
+ }
+
+ /**
+ * StringMatcher constructor takes in a String object that is a simple
+ * pattern which may contain '*' for 0 and many characters and '?' for
+ * exactly one character.
+ *
+ * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
+ * means literal "*", etc.
+ *
+ * Escaping any other character (including the escape character itself),
+ * just results in that character in the pattern. e.g., "\a" means "a" and
+ * "\\" means "\"
+ *
+ * If invoking the StringMatcher with string literals in Java, don't forget
+ * escape characters are represented by "\\".
+ *
+ * @param pattern
+ * the pattern to match text against
+ * @param ignoreCase
+ * if true, case is ignored
+ * @param ignoreWildCards
+ * if true, wild cards and their escape sequences are ignored
+ * (everything is taken literally).
+ */
+ public StringMatcher(String pattern, boolean ignoreCase,
+ boolean ignoreWildCards) {
+ if (pattern == null) {
+ throw new IllegalArgumentException();
+ }
+ fIgnoreCase = ignoreCase;
+ fIgnoreWildCards = ignoreWildCards;
+ fPattern = pattern;
+ fLength = pattern.length();
+
+ if (fIgnoreWildCards) {
+ parseNoWildCards();
+ } else {
+ parseWildCards();
+ }
+ }
+
+ /**
+ * Find the first occurrence of the pattern between
+ * <code>start</code)(inclusive)
+ * and <code>end</code>(exclusive).
+ * @param text the String object to search in
+ * @param start the starting index of the search range, inclusive
+ * @param end the ending index of the search range, exclusive
+ * @return an <code>StringMatcher.Position</code> object that keeps the starting
+ * (inclusive) and ending positions (exclusive) of the first occurrence of the
+ * pattern in the specified range of the text; return null if not found or subtext
+ * is empty (start==end). A pair of zeros is returned if pattern is empty string
+ * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
+ * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
+ */
+ public StringMatcher.Position find(String text, int start, int end) {
+ if (text == null) {
+ throw new IllegalArgumentException();
+ }
+
+ int tlen = text.length();
+ if (start < 0) {
+ start = 0;
+ }
+ if (end > tlen) {
+ end = tlen;
+ }
+ if (end < 0 || start >= end) {
+ return null;
+ }
+ if (fLength == 0) {
+ return new Position(start, start);
+ }
+ if (fIgnoreWildCards) {
+ int x = posIn(text, start, end);
+ if (x < 0) {
+ return null;
+ }
+ return new Position(x, x + fLength);
+ }
+
+ int segCount = fSegments.length;
+ if (segCount == 0) {
+ return new Position(start, end);
+ }
+
+ int curPos = start;
+ int matchStart = -1;
+ int i;
+ for (i = 0; i < segCount && curPos < end; ++i) {
+ String current = fSegments[i];
+ int nextMatch = regExpPosIn(text, curPos, end, current);
+ if (nextMatch < 0) {
+ return null;
+ }
+ if (i == 0) {
+ matchStart = nextMatch;
+ }
+ curPos = nextMatch + current.length();
+ }
+ if (i < segCount) {
+ return null;
+ }
+ return new Position(matchStart, curPos);
+ }
+
+ /**
+ * match the given <code>text</code> with the pattern
+ *
+ * @return true if matched eitherwise false
+ * @param text
+ * a String object
+ */
+ public boolean match(String text) {
+ if (text == null) {
+ return false;
+ }
+ return match(text, 0, text.length());
+ }
+
+ /**
+ * Given the starting (inclusive) and the ending (exclusive) positions in
+ * the <code>text</code>, determine if the given substring matches with
+ * aPattern
+ *
+ * @return true if the specified portion of the text matches the pattern
+ * @param text
+ * a String object that contains the substring to match
+ * @param start
+ * marks the starting position (inclusive) of the substring
+ * @param end
+ * marks the ending index (exclusive) of the substring
+ */
+ public boolean match(String text, int start, int end) {
+ if (null == text) {
+ throw new IllegalArgumentException();
+ }
+
+ if (start > end) {
+ return false;
+ }
+
+ if (fIgnoreWildCards) {
+ return (end - start == fLength)
+ && fPattern.regionMatches(fIgnoreCase, 0, text, start,
+ fLength);
+ }
+ int segCount = fSegments.length;
+ if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) {
+ // contains
+ // only
+ // '*'(s)
+ return true;
+ }
+ if (start == end) {
+ return fLength == 0;
+ }
+ if (fLength == 0) {
+ return start == end;
+ }
+
+ int tlen = text.length();
+ if (start < 0) {
+ start = 0;
+ }
+ if (end > tlen) {
+ end = tlen;
+ }
+
+ int tCurPos = start;
+ int bound = end - fBound;
+ if (bound < 0) {
+ return false;
+ }
+ int i = 0;
+ String current = fSegments[i];
+ int segLength = current.length();
+
+ /* process first segment */
+ if (!fHasLeadingStar) {
+ if (!regExpRegionMatches(text, start, current, 0, segLength)) {
+ return false;
+ }
+ ++i;
+ tCurPos = tCurPos + segLength;
+
+ }
+ if ((fSegments.length == 1) && (!fHasLeadingStar)
+ && (!fHasTrailingStar)) {
+ // only one segment to match, no wildcards specified
+ return tCurPos == end;
+ }
+ /* process middle segments */
+ while (i < segCount) {
+ current = fSegments[i];
+ int currentMatch;
+ int k = current.indexOf(fSingleWildCard);
+ if (k < 0) {
+ currentMatch = textPosIn(text, tCurPos, end, current);
+ if (currentMatch < 0) {
+ return false;
+ }
+ } else {
+ currentMatch = regExpPosIn(text, tCurPos, end, current);
+ if (currentMatch < 0) {
+ return false;
+ }
+ }
+ tCurPos = currentMatch + current.length();
+ i++;
+ }
+
+ /* process final segment */
+ if (!fHasTrailingStar && tCurPos != end) {
+ int clen = current.length();
+ return regExpRegionMatches(text, end - clen, current, 0, clen);
+ }
+ return i == segCount;
+ }
+
+ /**
+ * This method parses the given pattern into segments seperated by wildcard
+ * '*' characters. Since wildcards are not being used in this case, the
+ * pattern consists of a single segment.
+ */
+ private void parseNoWildCards() {
+ fSegments = new String[1];
+ fSegments[0] = fPattern;
+ fBound = fLength;
+ }
+
+ /**
+ * Parses the given pattern into segments seperated by wildcard '*'
+ * characters.
+ *
+ */
+ private void parseWildCards() {
+ if (fPattern.startsWith("*")) { //$NON-NLS-1$
+ fHasLeadingStar = true;
+ }
+ if (fPattern.endsWith("*")) {//$NON-NLS-1$
+ /* make sure it's not an escaped wildcard */
+ if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
+ fHasTrailingStar = true;
+ }
+ }
+
+ Vector<Object> temp = new Vector<Object>();
+
+ int pos = 0;
+ StringBuffer buf = new StringBuffer();
+ while (pos < fLength) {
+ char c = fPattern.charAt(pos++);
+ switch (c) {
+ case '\\':
+ if (pos >= fLength) {
+ buf.append(c);
+ } else {
+ char next = fPattern.charAt(pos++);
+ /* if it's an escape sequence */
+ if (next == '*' || next == '?' || next == '\\') {
+ buf.append(next);
+ } else {
+ /* not an escape sequence, just insert literally */
+ buf.append(c);
+ buf.append(next);
+ }
+ }
+ break;
+ case '*':
+ if (buf.length() > 0) {
+ /* new segment */
+ temp.addElement(buf.toString());
+ fBound += buf.length();
+ buf.setLength(0);
+ }
+ break;
+ case '?':
+ /* append special character representing single match wildcard */
+ buf.append(fSingleWildCard);
+ break;
+ default:
+ buf.append(c);
+ }
+ }
+
+ /* add last buffer to segment list */
+ if (buf.length() > 0) {
+ temp.addElement(buf.toString());
+ fBound += buf.length();
+ }
+
+ fSegments = new String[temp.size()];
+ temp.copyInto(fSegments);
+ }
+
+ /**
+ * @param text
+ * a string which contains no wildcard
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
+ */
+ protected int posIn(String text, int start, int end) {// no wild card in
+ // pattern
+ int max = end - fLength;
+
+ if (!fIgnoreCase) {
+ int i = text.indexOf(fPattern, start);
+ if (i == -1 || i > max) {
+ return -1;
+ }
+ return i;
+ }
+
+ for (int i = start; i <= max; ++i) {
+ if (text.regionMatches(true, i, fPattern, 0, fLength)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * @param text
+ * a simple regular expression that may only contain '?'(s)
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a simple regular expression that may contains '?'
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
+ */
+ protected int regExpPosIn(String text, int start, int end, String p) {
+ int plen = p.length();
+
+ int max = end - plen;
+ for (int i = start; i <= max; ++i) {
+ if (regExpRegionMatches(text, i, p, 0, plen)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ *
+ * @return boolean
+ * @param text
+ * a String to match
+ * @param tStart
+ * indicates the starting index of match, inclusive
+ * @param p
+ * a simple regular expression that may contain '?'
+ * @param pStart
+ * @param plen
+ */
+ protected boolean regExpRegionMatches(String text, int tStart, String p,
+ int pStart, int plen) {
+ while (plen-- > 0) {
+ char tchar = text.charAt(tStart++);
+ char pchar = p.charAt(pStart++);
+
+ /* process wild cards */
+ if (!fIgnoreWildCards) {
+ /* skip single wild cards */
+ if (pchar == fSingleWildCard) {
+ continue;
+ }
+ }
+ if (pchar == tchar) {
+ continue;
+ }
+ if (fIgnoreCase) {
+ if (Character.toUpperCase(tchar) == Character
+ .toUpperCase(pchar)) {
+ continue;
+ }
+ // comparing after converting to upper case doesn't handle all
+ // cases;
+ // also compare after converting to lower case
+ if (Character.toLowerCase(tchar) == Character
+ .toLowerCase(pchar)) {
+ continue;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @param text
+ * the string to match
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a string that has no wildcard
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
+ */
+ protected int textPosIn(String text, int start, int end, String p) {
+
+ int plen = p.length();
+ int max = end - plen;
+
+ if (!fIgnoreCase) {
+ int i = text.indexOf(p, start);
+ if (i == -1 || i > max) {
+ return -1;
+ }
+ return i;
+ }
+
+ for (int i = start; i <= max; ++i) {
+ if (text.regionMatches(true, i, p, 0, plen)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TablePatternFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TablePatternFilter.java
index 9a2074d1b..0ca3b5b9d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TablePatternFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TablePatternFilter.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TreeViewerSearchDialog.java
index 40fe55858..3429df1d5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/search/TreeViewerSearchDialog.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.internal.utils;
+package org.eclipse.tcf.te.ui.search;
import java.util.EventObject;
@@ -28,10 +28,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
import org.eclipse.tcf.te.ui.interfaces.IPreferenceKeys;
@@ -51,8 +48,6 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
private static final int DEFAULT_WIDTH_TRIM = 20;
private static final int DEFAULT_HEIGHT_TRIM = 160;
- // The dropdown combo box to select an algorithm
- private Combo fCmbAlg;
// The searching orientation check box.
private Button fBtnBackward;
// The wrap search check box.
@@ -137,8 +132,7 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
fSearcher.startSearch(this, fPmPart);
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -148,8 +142,8 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
fSearchable.restoreValues(getDialogSettings());
updateButtonState();
}
- /*
- * (non-Javadoc)
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.dialogs.ISearchCallback#searchDone(org.eclipse.core.runtime.IStatus, org.eclipse.jface.viewers.TreePath)
*/
@Override
@@ -163,11 +157,13 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
if (path == null) {
if (fSearcher.isWrap()) {
if (fSearcher.getLastResult() == null) {
- setMessage(Messages.TreeViewerSearchDialog_NoSuchNode, IMessageProvider.WARNING);
+ String message = fSearchable.getCustomMessage(rootElement, "TreeViewerSearchDialog_NoSuchNode"); //$NON-NLS-1$
+ setMessage(message != null ? message: Messages.TreeViewerSearchDialog_NoSuchNode, IMessageProvider.WARNING);
}
}
else {
- setMessage(Messages.TreeViewerSearchDialog_NoMoreNodeFound, IMessageProvider.WARNING);
+ String message = fSearchable.getCustomMessage(rootElement, "TreeViewerSearchDialog_NoMoreNodeFound"); //$NON-NLS-1$
+ setMessage(message != null ? message: Messages.TreeViewerSearchDialog_NoMoreNodeFound, IMessageProvider.WARNING);
}
}
else {
@@ -192,8 +188,8 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
container.setLayout(new GridLayout());
container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fSearchable.createCommonPart(container);
- fSearchable.createAdvancedPart(container);
+ fSearchable.createCommonPart(this, container);
+ fSearchable.createAdvancedPart(this, container);
// Progress monitor part to display or cancel searching process.
fPmPart = new ProgressMonitorPart(container, null, true);
@@ -207,11 +203,13 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
}
/**
- * Create the part to input the general search options.
+ * Create the search direction options in the given container.
*
- * @param container The parent container
+ * @param container The parent container. Must not be <code>null</code>.
*/
- protected void createGeneralOptions(Composite container) {
+ public void createSearchDirectionOptions(Composite container) {
+ Assert.isNotNull(container);
+
SelectionListener l = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -219,45 +217,19 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
}
};
- Group generalGroup = new Group(container, SWT.NONE);
- generalGroup.setText(Messages.TreeViewerSearchDialog_GeneralOptions);
- generalGroup.setLayout(new GridLayout(3, false));
- generalGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Label label = new Label(generalGroup, SWT.NONE);
- label.setLayoutData(new GridData());
- label.setText(Messages.TreeViewerSearchDialog_SearchNodesUsing);
-
- fCmbAlg = new Combo(generalGroup, SWT.BORDER | SWT.READ_ONLY);
- fCmbAlg.setLayoutData(new GridData());
- fCmbAlg.setItems(new String[]{Messages.TreeViewerSearchDialog_BFS, Messages.TreeViewerSearchDialog_DFS});
- fCmbAlg.select(0);
- fCmbAlg.addSelectionListener(l);
-
- label = new Label(generalGroup, SWT.NONE);
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
- label.setText(Messages.TreeViewerSearchDialog_UseOptions);
-
// Wrap search
- fBtnWrap = new Button(generalGroup, SWT.CHECK);
+ fBtnWrap = new Button(container, SWT.CHECK);
fBtnWrap.setText(Messages.TreeViewerSearchDialog_BtnWrapText);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- data.horizontalSpan = 3;
- data.horizontalIndent = 10;
- fBtnWrap.setLayoutData(data);
+ fBtnWrap.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fBtnWrap.addSelectionListener(l);
- // Search backward.
- fBtnBackward = new Button(generalGroup, SWT.CHECK);
- fBtnBackward.setText(Messages.TreeViewerSearchDialog_BtnBackText);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- data.horizontalSpan = 3;
- data.horizontalIndent = 10;
- fBtnBackward.setLayoutData(data);
- fBtnBackward.addSelectionListener(l);
- // Hidden if it is breadth-first search
- fBtnBackward.setEnabled(fSearcher.isDepthFirst());
+ if (fSearcher.isDepthFirst()) {
+ // Search backward.
+ fBtnBackward = new Button(container, SWT.CHECK);
+ fBtnBackward.setText(Messages.TreeViewerSearchDialog_BtnBackText);
+ fBtnBackward.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ fBtnBackward.addSelectionListener(l);
+ }
}
/**
@@ -299,15 +271,6 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
else if (src == fBtnWrap) {
fSearcher.setWrap(fBtnWrap.getSelection());
}
- else if (src == fCmbAlg) {
- int index = fCmbAlg.getSelectionIndex();
- fSearcher.endSearch();
- boolean selection = index == 1;
- fSearcher.setDepthFirst(selection);
- fBtnBackward.setEnabled(selection);
- fSearcher.resetPath();
- fSearcher.setForeward(!fBtnBackward.getSelection());
- }
}
/* (non-Javadoc)
@@ -324,8 +287,7 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
return super.getInitialSize();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.IOptionListener#optionChanged(java.util.EventObject)
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
index 7381d8631..04952dd9a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
@@ -15,14 +15,15 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
/**
* The base class that implements ISearchable and provide basic implementation method
* for adding and removing listeners.
*/
public abstract class AbstractSearchable extends EventManager implements ISearchable {
- /*
- * (non-Javadoc)
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#addOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
*/
@Override
@@ -30,8 +31,7 @@ public abstract class AbstractSearchable extends EventManager implements ISearch
super.addListenerObject(listener);
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#removeOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
*/
@Override
@@ -50,24 +50,21 @@ public abstract class AbstractSearchable extends EventManager implements ISearch
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.tcf.te.ui.internal.utils.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createCommonPart(Composite parent) {
- }
+ public void createCommonPart(TreeViewerSearchDialog dialog, Composite parent) {
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.tcf.te.ui.internal.utils.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createAdvancedPart(Composite parent) {
- }
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
+ }
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#isInputValid()
*/
@Override
@@ -83,8 +80,7 @@ public abstract class AbstractSearchable extends EventManager implements ISearch
return null;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
*/
@Override
@@ -92,24 +88,29 @@ public abstract class AbstractSearchable extends EventManager implements ISearch
return null;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getCustomMessage(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public String getCustomMessage(Object rootElement, String key) {
+ return null;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
*/
@Override
public void restoreValues(IDialogSettings settings) {
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
*/
@Override
public void persistValues(IDialogSettings settings) {
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
index abd8dd34c..c634862ba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
@@ -22,6 +22,7 @@ import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
import org.eclipse.tcf.te.ui.interfaces.ISearchable;
import org.eclipse.tcf.te.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -55,21 +56,21 @@ public abstract class CompositeSearchable implements ISearchable {
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createCommonPart(Composite parent) {
+ public void createCommonPart(TreeViewerSearchDialog dialog, Composite parent) {
Assert.isNotNull(searchables, "setSearchables must be called before!"); //$NON-NLS-1$
for (ISearchable searchable : searchables) {
- searchable.createCommonPart(parent);
+ searchable.createCommonPart(dialog, parent);
}
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog, org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createAdvancedPart(Composite parent) {
+ public void createAdvancedPart(TreeViewerSearchDialog dialog, Composite parent) {
Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
section.setText(Messages.TreeViewerSearchDialog_AdvancedOptions);
section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
@@ -97,7 +98,7 @@ public abstract class CompositeSearchable implements ISearchable {
shell.setSize(p.x, p.y);
}});
for(ISearchable searchable : searchables) {
- searchable.createAdvancedPart(advancedPart);
+ searchable.createAdvancedPart(dialog, advancedPart);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/TreeViewerUtil.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/TreeViewerUtil.java
index fb748228d..5de1acc3b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/TreeViewerUtil.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/TreeViewerUtil.java
@@ -1,372 +1,372 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.utils;
-
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.tcf.te.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.internal.utils.FilteringImageDescriptor;
-import org.eclipse.tcf.te.ui.internal.utils.QuickFilter;
-import org.eclipse.tcf.te.ui.internal.utils.TreeViewerSearchDialog;
-import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
-import org.eclipse.ui.PlatformUI;
-/**
- * The utilities to search and filter a tree viewer.
- */
-public class TreeViewerUtil {
- // The method to access AbstractTreeViewer#getSortedChildren in order to the children visually on the tree.
- static volatile Method methodGetSortedChildren;
- static {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose.
- }
- @Override
- public void run() throws Exception {
- // Initialize the method object.
- methodGetSortedChildren = AbstractTreeViewer.class.getDeclaredMethod("getSortedChildren", new Class[]{Object.class}); //$NON-NLS-1$
- // Because "getSortedChildren" is a protected method, we need to make it accessible.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- methodGetSortedChildren.setAccessible(true);
- return null;
- }
- });
- }
- });
- }
-
- /**
- * Decorate the image using the filtering image.
- *
- * @param image
- * @param viewer
- * @param path
- * @return
- */
- public static Image getDecoratedImage(Image image, TreeViewer viewer, TreePath path) {
- AbstractImageDescriptor descriptor = new FilteringImageDescriptor(UIPlugin.getDefault().getImageRegistry(), image);
- return UIPlugin.getSharedImage(descriptor);
- }
-
- /**
- * Decorate the text using the filter text.
- *
- * @param text
- * @param viewer
- * @param path
- * @return
- */
- public static String getDecoratedText(String text, TreeViewer viewer, TreePath path) {
- String pattern = TreeViewerUtil.getFilteringString(viewer, path);
- if (pattern != null) {
- return text + " Filtered (" + pattern + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return text;
- }
-
-
- /**
- * Reset the viewer to the original view.
- *
- * @param viewer The viewer to be reset.
- */
- public static void doReset(TreeViewer viewer) {
- ViewerFilter[] vFilters = viewer.getFilters();
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters != null && vFilters != null && !filters.isEmpty() && vFilters.length > 0) {
- List<ViewerFilter> filterList = new ArrayList<ViewerFilter>(Arrays.asList(vFilters));
- for(Map.Entry<TreePath, QuickFilter> entry : filters.entrySet()) {
- QuickFilter quickFilter = entry.getValue();
- filterList.remove(quickFilter);
- quickFilter.setPattern(null);
- }
- vFilters = filterList.toArray(new ViewerFilter[filterList.size()]);
- viewer.setFilters(vFilters);
- }
- viewer.setData("quick.filter", null); //$NON-NLS-1$
- }
-
- /**
- * Provide a pop up to enter filter to filter the tree viewer.
- *
- * @param viewer The tree viewer to be filtered.
- */
- public static void doCommonViewerFilter(TreeViewer viewer) {
- TreePath rootPath = getSelectedPath(viewer);
- TreePath root = getViewFilterRoot(viewer, rootPath);
- if (root != null && (root.getSegmentCount() == 0 || viewer.getExpandedState(root))) {
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters == null) {
- filters = new HashMap<TreePath, QuickFilter>();
- viewer.setData("quick.filter", filters); //$NON-NLS-1$
- }
- QuickFilter filter = filters.get(root);
- if(filter == null) {
- filter = new QuickFilter(viewer, root);
- filters.put(root, filter);
- }
- filter.showFilterPopup(false);
- }
- }
-
- /**
- * Provide a pop up to enter filter to filter the tree viewer.
- *
- * @param viewer The tree viewer to be filtered.
- */
- public static void doEditorFilter(TreeViewer viewer) {
- TreePath rootPath = getSelectedPath(viewer);
- TreePath root = getEditorFilterRoot(viewer, rootPath);
- if (root != null && (root.getSegmentCount() == 0 || viewer.getExpandedState(root))) {
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters == null) {
- filters = new HashMap<TreePath, QuickFilter>();
- viewer.setData("quick.filter", filters); //$NON-NLS-1$
- }
- QuickFilter filter = filters.get(root);
- if(filter == null) {
- filter = new QuickFilter(viewer, root);
- filters.put(root, filter);
- }
- filter.showFilterPopup(root.getSegmentCount() == 0);
- }
- }
-
- /**
- * Search a tree viewer for specified name specified in the pop up dialog.
- *
- * @param viewer The tree viewer to be searched.
- */
- public static void doSearch(TreeViewer viewer) {
- TreePath rootPath = getSelectedPath(viewer);
- rootPath = getSearchRoot(viewer, rootPath);
- Assert.isNotNull(rootPath);
- TreeViewerSearchDialog dialog = new TreeViewerSearchDialog(viewer, rootPath);
- dialog.open();
- }
-
- /**
- * If the specified element is being filtered.
- *
- * @param path
- * @return
- */
- public static boolean isFiltering(TreeViewer viewer, TreePath path) {
- if(path != null) {
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters != null) {
- QuickFilter filter = filters.get(path);
- if(filter != null) {
- return filter.isFiltering(path);
- }
- }
- }
- return false;
- }
-
- /**
- * Test if the specified tree viewer is being filtered.
- *
- * @param viewer The tree viewer to be tested.
- * @return true if there's at least a filter.
- */
- public static boolean isFiltering(TreeViewer viewer) {
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters != null && !filters.isEmpty()) {
- for(Map.Entry<TreePath, QuickFilter> entry : filters.entrySet()) {
- TreePath path = entry.getKey();
- QuickFilter filter = entry.getValue();
- if (filter!= null && filter.isFiltering(path)) return true;
- }
- }
- return false;
- }
-
- /**
- * Get the filter root for the viewer based on the root path.
- *
- * @param viewer The tree viewer.
- * @param rootPath The root path of the filter.
- * @return An adjust filter.
- */
- private static TreePath getViewFilterRoot(TreeViewer viewer, TreePath rootPath) {
- if (rootPath != null) {
- if (!isEligibleRoot(rootPath, viewer)) {
- return null;
- }
- if (rootPath.getSegmentCount() == 0) {
- viewer.setSelection(StructuredSelection.EMPTY);
- return TreePath.EMPTY;
- }
- return rootPath;
- }
- viewer.setSelection(StructuredSelection.EMPTY);
- return TreePath.EMPTY;
- }
- /**
- * Get the filter root for the viewer based on the root path.
- *
- * @param viewer The tree viewer.
- * @param rootPath The root path of the filter.
- * @return An adjust filter.
- */
- private static TreePath getEditorFilterRoot(TreeViewer viewer, TreePath rootPath) {
- if (rootPath != null) {
- if (!isEligibleRoot(rootPath, viewer)) {
- return TreePath.EMPTY;
- }
- if (rootPath.getSegmentCount() == 0) {
- return TreePath.EMPTY;
- }
- return rootPath;
- }
- return TreePath.EMPTY;
- }
- /**
- * Get the current visible/sorted children under the specified parent element or path
- * by invoking the reflective method. This method is UI thread-safe.
- *
- * @param viewer the viewer to get the children from.
- * @param parentElementOrTreePath The parent element or path.
- * @return The current visible/sorted children of the parent path/element.
- */
- public static Object[] getSortedChildren(final TreeViewer viewer, final Object parentElementOrTreePath) {
- if (Display.getCurrent() != null) {
- try {
- if (methodGetSortedChildren != null) {
- return (Object[]) methodGetSortedChildren.invoke(viewer, parentElementOrTreePath);
- }
- }
- catch (Exception e) {
- }
- return new Object[0];
- }
- final Object[][] result = new Object[1][];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- result[0] = getSortedChildren(viewer, parentElementOrTreePath);
- }
- });
- return result[0];
- }
-
- /**
- * Reposition the starting search path.
- */
- private static TreePath getSearchRoot(TreeViewer viewer, TreePath rootPath) {
- if (rootPath != null) {
- if (!hasChildren(rootPath, viewer)) {
- rootPath = rootPath.getParentPath();
- }
- if (rootPath.getSegmentCount() == 0) {
- return new TreePath(new Object[] { viewer.getInput() });
- }
- return rootPath;
- }
- return new TreePath(new Object[] { viewer.getInput() });
- }
-
- /**
- * Test if the root for the tree viewer is eligible as a root path
- * of a quick filter.
- *
- * @param root The root path to be tested.
- * @param viewer The tree viewer to be filtered.
- * @return true if it is eligible as a root path or else false.
- */
- private static boolean isEligibleRoot(TreePath root, TreeViewer viewer) {
- if (viewer.getExpandedState(root)) {
- return hasChildren(root, viewer);
- }
- return false;
- }
-
- /**
- * Judges if the specified root has children nodes.
- */
- private static boolean hasChildren(TreePath root, TreeViewer viewer) {
- ITreeContentProvider contentProvider = (ITreeContentProvider) viewer.getContentProvider();
- Object rootElement = root.getLastSegment();
- Object[] children = contentProvider.getChildren(rootElement);
- if (children != null && children.length > 0) {
- ViewerFilter[] filters = viewer.getFilters();
- if (filters != null && filters.length > 0) {
- for (ViewerFilter filter : filters) {
- if (!(filter instanceof QuickFilter)) {
- children = filter.filter(viewer, rootElement, children);
- }
- if (children == null || children.length == 0) break;
- }
- }
- return children != null && children.length > 0;
- }
- return false;
- }
-
- /**
- * Get the selected path of the viewer.
- *
- * @param viewer The tree viewer to get the selected path from.
- * @return the first selected path or null if no selected path.
- */
- private static TreePath getSelectedPath(TreeViewer viewer) {
- ISelection selection = viewer.getSelection();
- if (selection instanceof TreeSelection) {
- TreeSelection treeSelection = (TreeSelection) selection;
- TreePath[] paths = treeSelection.getPaths();
- if (paths != null && paths.length > 0) {
- return paths[0];
- }
- }
- return null;
- }
-
- /**
- * Get the filtering text of the filter attached to the specified tree viewer at the specified path.
- *
- * @param viewer The tree viewer.
- * @param path The path at which the filter applies to.
- * @return The filter text.
- */
- public static String getFilteringString(TreeViewer viewer, TreePath path) {
- Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
- if (filters != null) {
- QuickFilter filter = filters.get(path);
- if (filter != null) {
- return filter.getFilterText();
- }
- }
- return null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.utils;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
+import org.eclipse.tcf.te.ui.search.FilteringImageDescriptor;
+import org.eclipse.tcf.te.ui.search.QuickFilter;
+import org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog;
+import org.eclipse.ui.PlatformUI;
+/**
+ * The utilities to search and filter a tree viewer.
+ */
+public class TreeViewerUtil {
+ // The method to access AbstractTreeViewer#getSortedChildren in order to the children visually on the tree.
+ static volatile Method methodGetSortedChildren;
+ static {
+ SafeRunner.run(new ISafeRunnable(){
+ @Override
+ public void handleException(Throwable exception) {
+ // Ignore on purpose.
+ }
+ @Override
+ public void run() throws Exception {
+ // Initialize the method object.
+ methodGetSortedChildren = AbstractTreeViewer.class.getDeclaredMethod("getSortedChildren", new Class[]{Object.class}); //$NON-NLS-1$
+ // Because "getSortedChildren" is a protected method, we need to make it accessible.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ methodGetSortedChildren.setAccessible(true);
+ return null;
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Decorate the image using the filtering image.
+ *
+ * @param image
+ * @param viewer
+ * @param path
+ * @return
+ */
+ public static Image getDecoratedImage(Image image, TreeViewer viewer, TreePath path) {
+ AbstractImageDescriptor descriptor = new FilteringImageDescriptor(UIPlugin.getDefault().getImageRegistry(), image);
+ return UIPlugin.getSharedImage(descriptor);
+ }
+
+ /**
+ * Decorate the text using the filter text.
+ *
+ * @param text
+ * @param viewer
+ * @param path
+ * @return
+ */
+ public static String getDecoratedText(String text, TreeViewer viewer, TreePath path) {
+ String pattern = TreeViewerUtil.getFilteringString(viewer, path);
+ if (pattern != null) {
+ return text + " Filtered (" + pattern + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return text;
+ }
+
+
+ /**
+ * Reset the viewer to the original view.
+ *
+ * @param viewer The viewer to be reset.
+ */
+ public static void doReset(TreeViewer viewer) {
+ ViewerFilter[] vFilters = viewer.getFilters();
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters != null && vFilters != null && !filters.isEmpty() && vFilters.length > 0) {
+ List<ViewerFilter> filterList = new ArrayList<ViewerFilter>(Arrays.asList(vFilters));
+ for(Map.Entry<TreePath, QuickFilter> entry : filters.entrySet()) {
+ QuickFilter quickFilter = entry.getValue();
+ filterList.remove(quickFilter);
+ quickFilter.setPattern(null);
+ }
+ vFilters = filterList.toArray(new ViewerFilter[filterList.size()]);
+ viewer.setFilters(vFilters);
+ }
+ viewer.setData("quick.filter", null); //$NON-NLS-1$
+ }
+
+ /**
+ * Provide a pop up to enter filter to filter the tree viewer.
+ *
+ * @param viewer The tree viewer to be filtered.
+ */
+ public static void doCommonViewerFilter(TreeViewer viewer) {
+ TreePath rootPath = getSelectedPath(viewer);
+ TreePath root = getViewFilterRoot(viewer, rootPath);
+ if (root != null && (root.getSegmentCount() == 0 || viewer.getExpandedState(root))) {
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters == null) {
+ filters = new HashMap<TreePath, QuickFilter>();
+ viewer.setData("quick.filter", filters); //$NON-NLS-1$
+ }
+ QuickFilter filter = filters.get(root);
+ if(filter == null) {
+ filter = new QuickFilter(viewer, root);
+ filters.put(root, filter);
+ }
+ filter.showFilterPopup(false);
+ }
+ }
+
+ /**
+ * Provide a pop up to enter filter to filter the tree viewer.
+ *
+ * @param viewer The tree viewer to be filtered.
+ */
+ public static void doEditorFilter(TreeViewer viewer) {
+ TreePath rootPath = getSelectedPath(viewer);
+ TreePath root = getEditorFilterRoot(viewer, rootPath);
+ if (root != null && (root.getSegmentCount() == 0 || viewer.getExpandedState(root))) {
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters == null) {
+ filters = new HashMap<TreePath, QuickFilter>();
+ viewer.setData("quick.filter", filters); //$NON-NLS-1$
+ }
+ QuickFilter filter = filters.get(root);
+ if(filter == null) {
+ filter = new QuickFilter(viewer, root);
+ filters.put(root, filter);
+ }
+ filter.showFilterPopup(root.getSegmentCount() == 0);
+ }
+ }
+
+ /**
+ * Search a tree viewer for specified name specified in the pop up dialog.
+ *
+ * @param viewer The tree viewer to be searched.
+ */
+ public static void doSearch(TreeViewer viewer) {
+ TreePath rootPath = getSelectedPath(viewer);
+ rootPath = getSearchRoot(viewer, rootPath);
+ Assert.isNotNull(rootPath);
+ TreeViewerSearchDialog dialog = new TreeViewerSearchDialog(viewer, rootPath);
+ dialog.open();
+ }
+
+ /**
+ * If the specified element is being filtered.
+ *
+ * @param path
+ * @return
+ */
+ public static boolean isFiltering(TreeViewer viewer, TreePath path) {
+ if(path != null) {
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters != null) {
+ QuickFilter filter = filters.get(path);
+ if(filter != null) {
+ return filter.isFiltering(path);
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test if the specified tree viewer is being filtered.
+ *
+ * @param viewer The tree viewer to be tested.
+ * @return true if there's at least a filter.
+ */
+ public static boolean isFiltering(TreeViewer viewer) {
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters != null && !filters.isEmpty()) {
+ for(Map.Entry<TreePath, QuickFilter> entry : filters.entrySet()) {
+ TreePath path = entry.getKey();
+ QuickFilter filter = entry.getValue();
+ if (filter!= null && filter.isFiltering(path)) return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the filter root for the viewer based on the root path.
+ *
+ * @param viewer The tree viewer.
+ * @param rootPath The root path of the filter.
+ * @return An adjust filter.
+ */
+ private static TreePath getViewFilterRoot(TreeViewer viewer, TreePath rootPath) {
+ if (rootPath != null) {
+ if (!isEligibleRoot(rootPath, viewer)) {
+ return null;
+ }
+ if (rootPath.getSegmentCount() == 0) {
+ viewer.setSelection(StructuredSelection.EMPTY);
+ return TreePath.EMPTY;
+ }
+ return rootPath;
+ }
+ viewer.setSelection(StructuredSelection.EMPTY);
+ return TreePath.EMPTY;
+ }
+ /**
+ * Get the filter root for the viewer based on the root path.
+ *
+ * @param viewer The tree viewer.
+ * @param rootPath The root path of the filter.
+ * @return An adjust filter.
+ */
+ private static TreePath getEditorFilterRoot(TreeViewer viewer, TreePath rootPath) {
+ if (rootPath != null) {
+ if (!isEligibleRoot(rootPath, viewer)) {
+ return TreePath.EMPTY;
+ }
+ if (rootPath.getSegmentCount() == 0) {
+ return TreePath.EMPTY;
+ }
+ return rootPath;
+ }
+ return TreePath.EMPTY;
+ }
+ /**
+ * Get the current visible/sorted children under the specified parent element or path
+ * by invoking the reflective method. This method is UI thread-safe.
+ *
+ * @param viewer the viewer to get the children from.
+ * @param parentElementOrTreePath The parent element or path.
+ * @return The current visible/sorted children of the parent path/element.
+ */
+ public static Object[] getSortedChildren(final TreeViewer viewer, final Object parentElementOrTreePath) {
+ if (Display.getCurrent() != null) {
+ try {
+ if (methodGetSortedChildren != null) {
+ return (Object[]) methodGetSortedChildren.invoke(viewer, parentElementOrTreePath);
+ }
+ }
+ catch (Exception e) {
+ }
+ return new Object[0];
+ }
+ final Object[][] result = new Object[1][];
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = getSortedChildren(viewer, parentElementOrTreePath);
+ }
+ });
+ return result[0];
+ }
+
+ /**
+ * Reposition the starting search path.
+ */
+ private static TreePath getSearchRoot(TreeViewer viewer, TreePath rootPath) {
+ if (rootPath != null) {
+ if (!hasChildren(rootPath, viewer)) {
+ rootPath = rootPath.getParentPath();
+ }
+ if (rootPath.getSegmentCount() == 0) {
+ return new TreePath(new Object[] { viewer.getInput() });
+ }
+ return rootPath;
+ }
+ return new TreePath(new Object[] { viewer.getInput() });
+ }
+
+ /**
+ * Test if the root for the tree viewer is eligible as a root path
+ * of a quick filter.
+ *
+ * @param root The root path to be tested.
+ * @param viewer The tree viewer to be filtered.
+ * @return true if it is eligible as a root path or else false.
+ */
+ private static boolean isEligibleRoot(TreePath root, TreeViewer viewer) {
+ if (viewer.getExpandedState(root)) {
+ return hasChildren(root, viewer);
+ }
+ return false;
+ }
+
+ /**
+ * Judges if the specified root has children nodes.
+ */
+ private static boolean hasChildren(TreePath root, TreeViewer viewer) {
+ ITreeContentProvider contentProvider = (ITreeContentProvider) viewer.getContentProvider();
+ Object rootElement = root.getLastSegment();
+ Object[] children = contentProvider.getChildren(rootElement);
+ if (children != null && children.length > 0) {
+ ViewerFilter[] filters = viewer.getFilters();
+ if (filters != null && filters.length > 0) {
+ for (ViewerFilter filter : filters) {
+ if (!(filter instanceof QuickFilter)) {
+ children = filter.filter(viewer, rootElement, children);
+ }
+ if (children == null || children.length == 0) break;
+ }
+ }
+ return children != null && children.length > 0;
+ }
+ return false;
+ }
+
+ /**
+ * Get the selected path of the viewer.
+ *
+ * @param viewer The tree viewer to get the selected path from.
+ * @return the first selected path or null if no selected path.
+ */
+ private static TreePath getSelectedPath(TreeViewer viewer) {
+ ISelection selection = viewer.getSelection();
+ if (selection instanceof TreeSelection) {
+ TreeSelection treeSelection = (TreeSelection) selection;
+ TreePath[] paths = treeSelection.getPaths();
+ if (paths != null && paths.length > 0) {
+ return paths[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the filtering text of the filter attached to the specified tree viewer at the specified path.
+ *
+ * @param viewer The tree viewer.
+ * @param path The path at which the filter applies to.
+ * @return The filter text.
+ */
+ public static String getFilteringString(TreeViewer viewer, TreePath path) {
+ Map<TreePath, QuickFilter> filters = (Map<TreePath, QuickFilter>) viewer.getData("quick.filter"); //$NON-NLS-1$
+ if (filters != null) {
+ QuickFilter filter = filters.get(path);
+ if (filter != null) {
+ return filter.getFilterText();
+ }
+ }
+ return null;
+ }
+}

Back to the top