Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-06-15 06:53:12 +0000
committerUwe Stieber2012-06-15 06:53:12 +0000
commit16c1a1d886ea7cb2a09226c641fcc8712ac4d2d9 (patch)
tree44385c674cd02c87960bada6e47f184585a25ce3 /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui
parent5f0f2f1290a8a192bb72f1e19f9147cedf38a3e8 (diff)
downloadorg.eclipse.tcf-16c1a1d886ea7cb2a09226c641fcc8712ac4d2d9.tar.gz
org.eclipse.tcf-16c1a1d886ea7cb2a09226c641fcc8712ac4d2d9.tar.xz
org.eclipse.tcf-16c1a1d886ea7cb2a09226c641fcc8712ac4d2d9.zip
Target Explorer: Fix New File/Folder wizards show proxies/value-add's in target selection
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/wizards/TargetContentProvider.java97
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java604
2 files changed, 304 insertions, 397 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetContentProvider.java
deleted file mode 100644
index 8043715da..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetContentProvider.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * 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.wizards;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.ui.views.interfaces.IRoot;
-
-/**
- * The content provider used by TargetSelectionPage to provide the current
- * target list.
- */
-public class TargetContentProvider implements ITreeContentProvider {
- private final static Object[] NO_ELEMENTS = new Object[0];
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object parentElement) {
- Object[] children = NO_ELEMENTS;
- // If it is the locator model, get the peers
- if (parentElement instanceof ILocatorModel) {
- children = ((ILocatorModel)parentElement).getPeers();
- }
- return children;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object element) {
- // If it is a peer model node, return the parent locator model
- if (element instanceof IPeerModel) {
- return ((IPeerModel)element).getModel();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object element) {
- boolean hasChildren = false;
- if (element instanceof ILocatorModel) {
- hasChildren = ((ILocatorModel)element).getPeers().length > 0;
- }
- return hasChildren;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- @Override
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- final ILocatorModel model = Model.getModel();
- if (model != null && newInput instanceof IRoot) {
- // Refresh the model asynchronously
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- model.getService(ILocatorModelRefreshService.class).refresh();
- }
- });
- }
- }
-}
-
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
index e5a86955d..58161e84e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java
@@ -1,300 +1,304 @@
-/*******************************************************************************
- * 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.wizards;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-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.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
-import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
-import org.eclipse.tcf.te.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-
-/**
- * The New Target creation wizard selection page implementation.
- * <p>
- * This class is copied and adapted from <code>org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardSelectionPage</code>.
- *
- * @since 3.8
- */
-public class TargetSelectionPage extends AbstractValidatingWizardPage {
- // References to the page subcontrol's
- private FilteredTree filteredTree;
- private PatternFilter filteredTreeFilter;
-
- // The tree viewer to display the targets.
- private TreeViewer treeViewer;
-
- /**
- * Internal class. The wizard viewer comparator is responsible for the sorting in the tree.
- * Current implementation is not prioritizing categories.
- */
- /* default */static class TargetViewerComparator extends ViewerComparator {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object,
- * java.lang.String)
- */
- @Override
- public boolean isSorterProperty(Object element, String property) {
- // The comparator is affected if the label of the elements should change.
- return property.equals(IBasicPropertyConstants.P_TEXT);
- }
- }
-
- /**
- * Constructor.
- *
- * @param wizardRegistry The new target wizard registry. Must not be <code>null</code>.
- */
- public TargetSelectionPage() {
- super(TargetSelectionPage.class.getSimpleName());
- setTitle(getDefaultTitle());
- setDescription(getDefaultDescription());
- initialize();
- }
-
- /**
- * Refresh the remote services in target peers.
- */
- private void initialize() {
- // Refresh the information of remote services.
- ILocatorModel model = Model.getModel();
- IPeerModel[] peers = model.getPeers();
- if(peers != null) {
- ILocatorModelPeerNodeQueryService service = model.getService(ILocatorModelPeerNodeQueryService.class);
- for (IPeerModel peer : peers) {
- service.queryRemoteServices(peer);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.wizard.WizardPage#getWizard()
- */
- @Override
- public NewNodeWizard getWizard() {
- return (NewNodeWizard) super.getWizard();
- }
-
- /**
- * Returns the default page title.
- *
- * @return The default page title. Must be never <code>null</code>.
- */
- protected String getDefaultTitle() {
- return Messages.TargetSelectionPage_Title;
- }
-
- /**
- * Returns the default page description.
- *
- * @return The default page description. Must be never <code>null</code>.
- */
- protected String getDefaultDescription() {
- return Messages.TargetSelectionPage_Description;
- }
-
- /**
- * A styled label provider for the target selection list.
- */
- static class TargetStyledLabelProvider extends LabelProviderDelegate implements IStyledLabelProvider {
- @Override
- public StyledString getStyledText(Object element) {
- return new StyledString(getText(element));
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label = new Label(composite, SWT.NONE);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- label.setText(Messages.TargetSelectionPage_Targets);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- filteredTreeFilter = new TargetPatternFilter();
- filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter, true);
- filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- GridData layoutData = new GridData(GridData.FILL_BOTH);
- layoutData.heightHint = 250;
- layoutData.widthHint = 450;
- filteredTree.setLayoutData(layoutData);
-
- treeViewer = filteredTree.getViewer();
- treeViewer.setContentProvider(new TargetContentProvider());
- IBaseLabelProvider labelProvider = new DecoratingStyledCellLabelProvider(new TargetStyledLabelProvider(), new LabelProviderDelegate(), null);
- treeViewer.setLabelProvider(labelProvider);
- treeViewer.setComparator(new TargetViewerComparator());
- ViewerFilter fsPeerFilter = new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IPeerModel) {
- IPeerModel peer = (IPeerModel) element;
- NewNodeWizard wizard = getWizard();
- return wizard.hasFileSystem(peer);
- }
- return false;
- }
- };
- treeViewer.addFilter(fsPeerFilter);
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- onSelectionChanged();
- }
- });
- treeViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- // Double-click on a connection type is triggering the sub wizard
- if (event.getSelection() instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- // The tree is single selection, so look for the first element only.
- Object element = selection.getFirstElement();
- if (element instanceof IPeerModel) {
- // Double-click on a connection type is triggering the sub wizard
- getWizard().getContainer().showPage(getNextPage());
- }
- else if (event.getViewer() instanceof TreeViewer) {
- TreeViewer viewer = (TreeViewer) event.getViewer();
- if (viewer.isExpandable(element)) {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- }
- }
- }
- });
-
- treeViewer.setInput(Model.getModel());
- NewNodeWizard wizard = getWizard();
- IPeerModel peer = wizard.getPeer();
- if (wizard.getPeer() != null) {
- treeViewer.setSelection(new StructuredSelection(peer), true);
- }
-
- // apply the standard dialog font
- Dialog.applyDialogFont(composite);
-
- setControl(composite);
-
- // Restore the tree state
- restoreWidgetValues();
-
- // Initialize the context help id
- PlatformUI.getWorkbench().getHelpSystem()
- .setHelp(getControl(), IUIConstants.HELP_NEW_WIZARD_SELECTION_PAGE);
-
- setPageComplete(peer != null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage#validate()
- */
- @Override
- public void validate() {
- super.validate();
- if (!isPageComplete()) return;
- if (isValidationInProgress()) return;
- setValidationInProgress(true);
- boolean valid = true;
- ISelection selection = treeViewer.getSelection();
- if (selection.isEmpty()) {
- setMessage(getDefaultDescription(), IMessageProvider.ERROR);
- valid = false;
- }
- setPageComplete(valid);
- setValidationInProgress(false);
- }
-
- /**
- * Called from the selection listener to propagate the current system type selection to the
- * underlying wizard.
- */
- protected void onSelectionChanged() {
- if (filteredTree.getViewer().getSelection() instanceof IStructuredSelection) {
- IStructuredSelection filteredTreeSelection = (IStructuredSelection) filteredTree
- .getViewer().getSelection();
- NewNodeWizard wizard = getWizard();
- if (filteredTreeSelection.getFirstElement() instanceof IPeerModel) {
- wizard.setPeer((IPeerModel) filteredTreeSelection.getFirstElement());
- }
- else {
- wizard.setPeer(null);
- }
- }
-
- // Update the wizard container UI elements
- IWizardContainer container = getContainer();
- if (container != null && container.getCurrentPage() != null) {
- container.updateWindowTitle();
- container.updateTitleBar();
- container.updateButtons();
- }
- validate();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.wizard.WizardPage#getDialogSettings()
- */
- @Override
- protected IDialogSettings getDialogSettings() {
- // If the wizard is set and returns dialog settings, we re-use them here
- IDialogSettings settings = super.getDialogSettings();
- // If the dialog settings could not set from the wizard, fallback to the plugin's
- // dialog settings store.
- if (settings == null) settings = UIPlugin.getDefault().getDialogSettings();
- String sectionName = this.getClass().getName();
- if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
- settings = settings.getSection(sectionName);
-
- return settings;
- }
-}
+/*******************************************************************************
+ * 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.wizards;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+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.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
+import org.eclipse.tcf.te.tcf.locator.model.Model;
+import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+/**
+ * The New Target creation wizard selection page implementation.
+ * <p>
+ * This class is copied and adapted from <code>org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardSelectionPage</code>.
+ *
+ * @since 3.8
+ */
+public class TargetSelectionPage extends AbstractValidatingWizardPage {
+ // References to the page subcontrol's
+ private FilteredTree filteredTree;
+ private PatternFilter filteredTreeFilter;
+
+ // The tree viewer to display the targets.
+ private TreeViewer treeViewer;
+
+ /**
+ * Internal class. The wizard viewer comparator is responsible for the sorting in the tree.
+ * Current implementation is not prioritizing categories.
+ */
+ /* default */static class TargetViewerComparator extends ViewerComparator {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object,
+ * java.lang.String)
+ */
+ @Override
+ public boolean isSorterProperty(Object element, String property) {
+ // The comparator is affected if the label of the elements should change.
+ return property.equals(IBasicPropertyConstants.P_TEXT);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param wizardRegistry The new target wizard registry. Must not be <code>null</code>.
+ */
+ public TargetSelectionPage() {
+ super(TargetSelectionPage.class.getSimpleName());
+ setTitle(getDefaultTitle());
+ setDescription(getDefaultDescription());
+ initialize();
+ }
+
+ /**
+ * Refresh the remote services in target peers.
+ */
+ private void initialize() {
+ // Refresh the information of remote services.
+ ILocatorModel model = Model.getModel();
+ IPeerModel[] peers = model.getPeers();
+ if(peers != null) {
+ ILocatorModelPeerNodeQueryService service = model.getService(ILocatorModelPeerNodeQueryService.class);
+ for (IPeerModel peer : peers) {
+ service.queryRemoteServices(peer);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getWizard()
+ */
+ @Override
+ public NewNodeWizard getWizard() {
+ return (NewNodeWizard) super.getWizard();
+ }
+
+ /**
+ * Returns the default page title.
+ *
+ * @return The default page title. Must be never <code>null</code>.
+ */
+ protected String getDefaultTitle() {
+ return Messages.TargetSelectionPage_Title;
+ }
+
+ /**
+ * Returns the default page description.
+ *
+ * @return The default page description. Must be never <code>null</code>.
+ */
+ protected String getDefaultDescription() {
+ return Messages.TargetSelectionPage_Description;
+ }
+
+ /**
+ * A styled label provider for the target selection list.
+ */
+ static class TargetStyledLabelProvider extends LabelProviderDelegate implements IStyledLabelProvider {
+ @Override
+ public StyledString getStyledText(Object element) {
+ return new StyledString(getText(element));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ label.setText(Messages.TargetSelectionPage_Targets);
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ filteredTreeFilter = new TargetPatternFilter();
+ filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter, true);
+ filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ GridData layoutData = new GridData(GridData.FILL_BOTH);
+ layoutData.heightHint = 250;
+ layoutData.widthHint = 450;
+ filteredTree.setLayoutData(layoutData);
+
+ treeViewer = filteredTree.getViewer();
+ treeViewer.setContentProvider(new ContentProviderDelegate());
+ IBaseLabelProvider labelProvider = new DecoratingStyledCellLabelProvider(new TargetStyledLabelProvider(), new LabelProviderDelegate(), null);
+ treeViewer.setLabelProvider(labelProvider);
+ treeViewer.setComparator(new TargetViewerComparator());
+ ViewerFilter fsPeerFilter = new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof IPeerModel) {
+ IPeerModel peer = (IPeerModel) element;
+
+
+
+ NewNodeWizard wizard = getWizard();
+ return wizard.hasFileSystem(peer);
+ }
+ return false;
+ }
+ };
+ treeViewer.addFilter(fsPeerFilter);
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ onSelectionChanged();
+ }
+ });
+ treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ // Double-click on a connection type is triggering the sub wizard
+ if (event.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ // The tree is single selection, so look for the first element only.
+ Object element = selection.getFirstElement();
+ if (element instanceof IPeerModel) {
+ // Double-click on a connection type is triggering the sub wizard
+ getWizard().getContainer().showPage(getNextPage());
+ }
+ else if (event.getViewer() instanceof TreeViewer) {
+ TreeViewer viewer = (TreeViewer) event.getViewer();
+ if (viewer.isExpandable(element)) {
+ viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ }
+ }
+ }
+ }
+ });
+
+ treeViewer.setInput(Model.getModel());
+ NewNodeWizard wizard = getWizard();
+ IPeerModel peer = wizard.getPeer();
+ if (wizard.getPeer() != null) {
+ treeViewer.setSelection(new StructuredSelection(peer), true);
+ }
+
+ // apply the standard dialog font
+ Dialog.applyDialogFont(composite);
+
+ setControl(composite);
+
+ // Restore the tree state
+ restoreWidgetValues();
+
+ // Initialize the context help id
+ PlatformUI.getWorkbench().getHelpSystem()
+ .setHelp(getControl(), IUIConstants.HELP_NEW_WIZARD_SELECTION_PAGE);
+
+ setPageComplete(peer != null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage#validate()
+ */
+ @Override
+ public void validate() {
+ super.validate();
+ if (!isPageComplete()) return;
+ if (isValidationInProgress()) return;
+ setValidationInProgress(true);
+ boolean valid = true;
+ ISelection selection = treeViewer.getSelection();
+ if (selection.isEmpty()) {
+ setMessage(getDefaultDescription(), IMessageProvider.ERROR);
+ valid = false;
+ }
+ setPageComplete(valid);
+ setValidationInProgress(false);
+ }
+
+ /**
+ * Called from the selection listener to propagate the current system type selection to the
+ * underlying wizard.
+ */
+ protected void onSelectionChanged() {
+ if (filteredTree.getViewer().getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection filteredTreeSelection = (IStructuredSelection) filteredTree
+ .getViewer().getSelection();
+ NewNodeWizard wizard = getWizard();
+ if (filteredTreeSelection.getFirstElement() instanceof IPeerModel) {
+ wizard.setPeer((IPeerModel) filteredTreeSelection.getFirstElement());
+ }
+ else {
+ wizard.setPeer(null);
+ }
+ }
+
+ // Update the wizard container UI elements
+ IWizardContainer container = getContainer();
+ if (container != null && container.getCurrentPage() != null) {
+ container.updateWindowTitle();
+ container.updateTitleBar();
+ container.updateButtons();
+ }
+ validate();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getDialogSettings()
+ */
+ @Override
+ protected IDialogSettings getDialogSettings() {
+ // If the wizard is set and returns dialog settings, we re-use them here
+ IDialogSettings settings = super.getDialogSettings();
+ // If the dialog settings could not set from the wizard, fallback to the plugin's
+ // dialog settings store.
+ if (settings == null) settings = UIPlugin.getDefault().getDialogSettings();
+ String sectionName = this.getClass().getName();
+ if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
+ settings = settings.getSection(sectionName);
+
+ return settings;
+ }
+}

Back to the top