blob: 0c4a0e80ca39e22c14c833a8a2bec065bdc91007 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* 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:
* Pierre Allard,
* Regent L'Archeveque,
<<<<<<< HEAD
* Sebastien Gemme
*
=======
* Sebastien Gemme - initial API and implementation
*
>>>>>>> refs/heads/eclipse_pa
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.common.topology.ui.dialogs;
import org.eclipse.apogy.common.topology.Node;
import org.eclipse.apogy.common.topology.ui.composites.NodeSearchComposite;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
public class NodeSelectionDialog extends Dialog {
private Node root;
private Node selectedNode;
private NodeSearchComposite nodeSearchComposite;
public NodeSelectionDialog(Shell parentShell) {
super(parentShell);
}
/**
* @wbp.parser.constructor
*/
public NodeSelectionDialog(Shell parentShell, Node root) {
this(parentShell);
this.root = root;
}
public Node getSelectedNode() {
return this.selectedNode;
}
/**
* Return the NodeSearchComposite used by the Dialog.
*
* @return The NodeSearchComposite.
*/
public NodeSearchComposite getNodeSearchComposite() {
return this.nodeSearchComposite;
}
protected void setSelectedNode(Node newNodeSelected) {
this.selectedNode = newNodeSelected;
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Select a Node");
}
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
area.setLayout(new GridLayout(1, false));
this.nodeSearchComposite = createNodeSearchComposite(area);
return area;
}
/**
* Method called to create the NodeSearchComposite used in the composite.
* Overload to customize the NodeSearchComposite.
*
* @param parent The parent composite,
* @return The NodeSearchComposite.
*/
protected NodeSearchComposite createNodeSearchComposite(Composite parent) {
return new NodeSearchComposite(parent, SWT.NONE, this.root) {
@Override
public void nodeSelectedChanged(Node nodeSelected) {
NodeSelectionDialog.this.setSelectedNode(nodeSelected);
}
};
}
}