Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-06-14 09:43:49 +0000
committerWilliam Chen2012-06-14 09:43:49 +0000
commit59b3a48d35c739d1da490f1320c8a12a24b35e19 (patch)
tree440088542148043a909b183f22c4fae0e31479ba /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui
parenta804c0d58533b437a6e5489550cfea42c7e63f95 (diff)
downloadorg.eclipse.tcf-59b3a48d35c739d1da490f1320c8a12a24b35e19.tar.gz
org.eclipse.tcf-59b3a48d35c739d1da490f1320c8a12a24b35e19.tar.xz
org.eclipse.tcf-59b3a48d35c739d1da490f1320c8a12a24b35e19.zip
Target Explorer: Add new files that are forgotten to be checked in.
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSBaseSearchable.java66
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSGeneralSearchable.java176
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSModifiedSearchable.java161
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSSizeSearchable.java162
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeMatcher.java62
5 files changed, 627 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSBaseSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSBaseSearchable.java
new file mode 100644
index 000000000..b055960b6
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSBaseSearchable.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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
+ * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+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;
+
+public abstract class FSBaseSearchable extends AbstractSearchable implements ISearchMatcher {
+ /**
+ * Create a collapseable section with the specified title and return the
+ * content composite.
+ *
+ * @param parent The parent where the section is to be created.
+ * @param title The title of the section.
+ * @return The content composite.
+ */
+ protected Composite createSection(Composite parent, String title) {
+ Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
+ section.setText(title);
+ section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ section.setLayoutData(layoutData);
+
+ final Composite client = new Composite(section, SWT.NONE);
+ client.setBackground(section.getBackground());
+ section.setClient(client);
+
+ 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;
+ }
+
+ @Override
+ public ISearchMatcher getMatcher() {
+ return this;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSGeneralSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSGeneralSearchable.java
new file mode 100644
index 000000000..1057f274a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSGeneralSearchable.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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
+ * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+
+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.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.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
+
+public class FSGeneralSearchable extends AbstractSearchable {
+ // The case sensitive check box.
+ Button fBtnCase;
+ // The matching rule check box.
+ Button fBtnMatch;
+ // The input field for searching conditions.
+ protected Text fSearchField;
+ // The current target names.
+ protected String fTargetName;
+ // Whether it is case sensitive
+ boolean fCaseSensitive;
+ // Whether it is precise matching.
+ boolean fMatchPrecise;
+ //
+ boolean fIncludeSystem = true;
+ boolean fIncludeHidden = true;
+ // The types of target files.
+ Combo fCmbTypes;
+ // The current selected target type index.
+ int fTargetType;
+
+ // The root directory node.
+ FSTreeNode rootNode;
+ private Button fBtnSystem;
+ private Button fBtnHidden;
+ public FSGeneralSearchable(FSTreeNode node) {
+ rootNode = node;
+ }
+ @Override
+ public void createCommonPart(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout(2, false);
+ glayout.marginHeight = 0;
+ glayout.marginWidth = 0;
+ comp.setLayout(glayout);
+ comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Searching field.
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.FSGeneralSearchable_Find);
+ fSearchField = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ fSearchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ fSearchField.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(2, true));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite cmpType = new Composite(group, SWT.NONE);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ 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.select(0);
+ fCmbTypes.addSelectionListener(l);
+
+ // Case sensitive
+ fBtnCase = new Button(group, SWT.CHECK);
+ fBtnCase.setText(Messages.TreeViewerSearchDialog_BtnCaseText);
+ data = new GridData();
+ fBtnCase.setLayoutData(data);
+ fBtnCase.addSelectionListener(l);
+
+ // Matching precisely
+ fBtnMatch = new Button(group, SWT.CHECK);
+ fBtnMatch.setText(Messages.TreeViewerSearchDialog_BtnPreciseText);
+ data = new GridData();
+ fBtnMatch.setLayoutData(data);
+ fBtnMatch.addSelectionListener(l);
+
+ if(rootNode.isWindowsNode()) {
+ fBtnSystem = new Button(group, SWT.CHECK);
+ fBtnSystem.setText(Messages.FSGeneralSearchable_SearchSystemFiles);
+ fBtnSystem.setSelection(true);
+ data = new GridData();
+ fBtnSystem.setLayoutData(data);
+ fBtnSystem.addSelectionListener(l);
+
+ fBtnHidden = new Button(group, SWT.CHECK);
+ fBtnHidden.setText(Messages.FSGeneralSearchable_SearchHiddenFiles);
+ fBtnHidden.setSelection(true);
+ data = new GridData();
+ fBtnHidden.setLayoutData(data);
+ fBtnHidden.addSelectionListener(l);
+ }
+ }
+ /**
+ * The text for searching is modified.
+ */
+ protected void searchTextModified() {
+ fireOptionChanged();
+ fTargetName = fSearchField.getText().trim();
+ }
+
+ 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();
+ }
+ }
+
+ @Override
+ public ISearchMatcher getMatcher() {
+ return new FSTreeNodeMatcher(fCaseSensitive, fMatchPrecise, fTargetType, fTargetName, fIncludeSystem, fIncludeHidden);
+ }
+
+ @Override
+ public boolean isInputValid() {
+ String txt = fSearchField.getText();
+ boolean valid = txt != null && txt.trim().length() > 0;
+ return valid;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSModifiedSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSModifiedSearchable.java
new file mode 100644
index 000000000..0330ae1b6
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSModifiedSearchable.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * 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
+ * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+
+import org.eclipse.swt.SWT;
+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;
+
+public class FSModifiedSearchable extends FSBaseSearchable {
+ 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;
+
+ 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;
+
+ private int option;
+ private long lowDate;
+ private long topDate;
+
+ private Button fBtnLmNotRem;
+ private Button fBtnLmLastWeek;
+ private Button fBtnLmPastMonth;
+ private Button fBtnLmPastYear;
+ private Button fBtnLmSpecified;
+ private Text txtLmFrom;
+ private Text txtLmTo;
+
+ public FSModifiedSearchable(FSTreeNode node) {
+ }
+
+ @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);
+
+ txtLmFrom = new Text(modifiedComp, SWT.BORDER | SWT.SINGLE);
+ data = new GridData();
+ data.widthHint = 50;
+ txtLmFrom.setLayoutData(data);
+ txtLmFrom.setEnabled(false);
+
+ Label label = new Label(modifiedComp, SWT.NONE);
+ label.setText(Messages.FSModifiedSearchable_ToDate);
+
+ txtLmTo = new Text(modifiedComp, SWT.BORDER | SWT.SINGLE);
+ data = new GridData();
+ data.widthHint = 50;
+ txtLmTo.setLayoutData(data);
+ txtLmTo.setEnabled(false);
+ }
+
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ boolean spec = false;
+ if(src == fBtnLmNotRem) {
+ option = OPTION_NOT_REMEMBER;
+ }
+ else if(src == fBtnLmLastWeek) {
+ option = OPTION_LAST_WEEK;
+ }
+ else if(src == fBtnLmPastMonth) {
+ option = OPTION_LAST_MONTH;
+ }
+ else if(src == fBtnLmPastYear) {
+ option = OPTION_LAST_YEAR;
+ }
+ else if(src == fBtnLmSpecified) {
+ option = OPTION_SPECIFIED;
+ spec = true;
+ }
+ txtLmFrom.setEnabled(spec);
+ txtLmTo.setEnabled(spec);
+ }
+
+ @Override
+ public boolean match(Object element) {
+ if (element instanceof FSTreeNode) {
+ FSTreeNode node = (FSTreeNode) element;
+ long now = System.currentTimeMillis();
+ switch (option) {
+ 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 >= lowDate && node.attr.mtime < topDate;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSSizeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSSizeSearchable.java
new file mode 100644
index 000000000..c33604b0b
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSSizeSearchable.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * 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
+ * William Chen (Wind River)- [345552] Edit the remote files with a proper editor
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+
+import org.eclipse.swt.SWT;
+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;
+
+public class FSSizeSearchable extends FSBaseSearchable {
+ 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;
+
+ 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;
+
+ private int option;
+ private int lowSize;
+ private int topSize;
+
+ private Button fBtnSizeNotRem;
+ private Button fBtnSizeSmall;
+ private Button fBtnSizeMedium;
+ private Button fBtnSizeLarge;
+ private Button fBtnSizeSpecified;
+ private Text txtSizeFrom;
+ private Text txtSizeTo;
+
+ public FSSizeSearchable(FSTreeNode node) {
+ }
+
+ @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);
+
+ txtSizeFrom = new Text(sizeComp, SWT.BORDER | SWT.SINGLE);
+ data = new GridData();
+ data.widthHint = 50;
+ txtSizeFrom.setLayoutData(data);
+ txtSizeFrom.setEnabled(false);
+
+ Label label = new Label(sizeComp, SWT.NONE);
+ label.setText(Messages.FSSizeSearchable_ToText);
+
+ txtSizeTo = new Text(sizeComp, SWT.BORDER | SWT.SINGLE);
+ data = new GridData();
+ data.widthHint = 50;
+ txtSizeTo.setLayoutData(data);
+ txtSizeTo.setEnabled(false);
+
+ label = new Label(sizeComp, SWT.NONE);
+ label.setText(Messages.FSSizeSearchable_KBS);
+ }
+
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ boolean spec = false;
+ if(src == fBtnSizeNotRem) {
+ option = OPTION_NOT_REMEMBER;
+ }
+ else if(src == fBtnSizeSmall) {
+ option = OPTION_SIZE_SMALL;
+ }
+ else if(src == fBtnSizeMedium) {
+ option = OPTION_SIZE_MEDIUM;
+ }
+ else if(src == fBtnSizeLarge) {
+ option = OPTION_SIZE_LARGE;
+ }
+ else if(src == fBtnSizeSpecified) {
+ option = OPTION_SIZE_SPECIFIED;
+ spec = true;
+ }
+ txtSizeFrom.setEnabled(spec);
+ txtSizeTo.setEnabled(spec);
+ }
+
+ @Override
+ public boolean match(Object element) {
+ if (element instanceof FSTreeNode) {
+ FSTreeNode node = (FSTreeNode) element;
+ switch (option) {
+ 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 >= lowSize && node.attr.size < topSize;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeMatcher.java
new file mode 100644
index 000000000..05b7b8177
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeMatcher.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.tcf.filesystem.ui.internal.adapters;
+
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+/**
+ * The ISearchMatcher implementation for FSTreeNode.
+ */
+public class FSTreeNodeMatcher implements ISearchMatcher {
+ // Whether it is case sensitive
+ boolean fCaseSensitive;
+ // Whether it is precise matching.
+ boolean fMatchPrecise;
+ // The current selected target type index.
+ int fTargetType;
+ // The current target names.
+ String fTargetName;
+ boolean fIncludeSystem;
+ boolean fIncludeHidden;
+
+ public FSTreeNodeMatcher(boolean caseSensitive, boolean matchPrecise, int targetType, String targetName, boolean includeSystem, boolean includeHidden) {
+ fCaseSensitive = caseSensitive;
+ fMatchPrecise = matchPrecise;
+ fTargetName = targetName;
+ fTargetType = targetType;
+ fIncludeSystem = includeSystem;
+ fIncludeHidden = includeHidden;
+ }
+
+ /*
+ * (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;
+ if (context instanceof FSTreeNode) {
+ FSTreeNode node = (FSTreeNode) context;
+ if(fTargetType == 1 && !node.isFile() || fTargetType == 2 && !node.isDirectory()) return false;
+ if(!fIncludeSystem && node.isSystem()) return false;
+ if(!fIncludeHidden && node.isHidden()) return false;
+ String text = node.name;
+ if (text == null) return false;
+ String target = fTargetName;
+ if (!fCaseSensitive) {
+ text = text.toLowerCase();
+ target = target != null ? target.toLowerCase() : null;
+ }
+ if (fMatchPrecise) return text.equals(target);
+ return text.indexOf(target) != -1;
+ }
+ return false;
+ }
+}

Back to the top