Commit b026199e authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

Merge remote-tracking branch 'origin/next' into jay/projectSupport

parents bcfbe814 0d1cef03
......@@ -14,3 +14,4 @@
=======
>>>>>>> refs/remotes/origin/jay/reflectivity
>>>>>>> refs/remotes/origin/master
/ice_moose_2015050.synctex.gz
......@@ -63,7 +63,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import com.jme3.math.Vector3f;
/**
......
......@@ -126,7 +126,5 @@ Require-Bundle: org.eclipse.ice.client.compatibility;bundle-version="2.0.0",
org.eclipse.ice.datastructures,
org.eclipse.ice.viz.service;bundle-version="2.0.0"
Bundle-ClassPath: .
Service-Component: OSGI-INF/MasterApplicationFactory.xml,
OSGI-INF/MasterApplicationHolder.xml
Bundle-Vendor: Oak Ridge National Laboratory
Bundle-ActivationPolicy: lazy
......@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: ICEEclipseWidgets
Bundle-SymbolicName: org.eclipse.ice.client.widgets;singleton:=true
Bundle-Version: 2.1.7.20150825
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.ice.datastructures,
org.eclipse.ice.client.compatibility;bundle-version="2.0.0",
org.eclipse.jface,
......@@ -47,6 +47,5 @@ Import-Package: com.jme3.app,
org.slf4j;version="1.7.2"
Export-Package: org.eclipse.ice.client.widgets
Service-Component: OSGI-INF/eclipseWidgetsComponent.xml,
OSGI-INF/meshPageVizService.xml,
OSGI-INF/formEditorVizService.xml
Bundle-Vendor: Oak Ridge National Laboratory
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.ice.client.widgets.ICEFormEditor">
<implementation class="org.eclipse.ice.client.widgets.ICEMeshPage"/>
<reference bind="setVizServiceFactory" cardinality="1..1" interface="org.eclipse.ice.viz.service.IVizServiceFactory" name="IVizServiceFactory" policy="dynamic"/>
</scr:component>
......@@ -169,7 +169,7 @@
<extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections contributorId="org.eclipse.ice.client.widgets.TreeCompositeViewer">
<propertySection
class="org.eclipse.ice.clientwidgets.TreePropertySection"
class="org.eclipse.ice.client.widgets.TreePropertySection"
id="DataSection"
tab="TreeViewer.Data">
<input type="org.eclipse.ice.datastructures.form.TreeComposite"/>
......@@ -202,7 +202,7 @@
<propertySections
contributorId="org.eclipse.ice.client.widgets.EMFTreeCompositeViewer">
<propertySection
class="org.eclipse.ice.clientwidgets.TreePropertySection"
class="org.eclipse.ice.client.widgets.TreePropertySection"
id="DataSection"
tab="TreeViewer.Data">
<input
......
......@@ -14,17 +14,26 @@ package org.eclipse.ice.client.widgets;
import java.net.URL;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import org.eclipse.core.internal.runtime.Activator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.ice.datastructures.form.TreeComposite;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
import org.eclipse.ui.dialogs.ListDialog;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
......@@ -51,8 +60,7 @@ public class AddNodeTreeAction extends AbstractTreeAction {
// Set the image to be the green plus button.
Bundle bundle = FrameworkUtil.getBundle(AddNodeTreeAction.class);
Path imagePath = new Path("icons"
+ System.getProperty("file.separator") + "add.png");
Path imagePath = new Path("icons" + System.getProperty("file.separator") + "add.png");
URL imageURL = FileLocator.find(bundle, imagePath, null);
setImageDescriptor(ImageDescriptor.createFromURL(imageURL));
......@@ -77,7 +85,7 @@ public class AddNodeTreeAction extends AbstractTreeAction {
public void run() {
addToNode(getSelectedNode());
}
/**
* Determines whether or not a child node can be added to a TreeComposite.
*
......@@ -113,25 +121,26 @@ public class AddNodeTreeAction extends AbstractTreeAction {
// Create a selection dialog so that they can make a choice
IWorkbench bench = PlatformUI.getWorkbench();
IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
ListDialog addNodeDialog = new ListDialog(window.getShell());
addNodeDialog.setAddCancelButton(true);
addNodeDialog.setContentProvider(new ArrayContentProvider());
addNodeDialog.setLabelProvider(new LabelProvider());
addNodeDialog.setInput(exemplarMap.keySet().toArray());
TreeNodeFilteredItemsSelectionDialog addNodeDialog = new TreeNodeFilteredItemsSelectionDialog(
window.getShell(), true, exemplarMap.keySet());
addNodeDialog.setInitialSelections(exemplarMap.keySet().toArray());
addNodeDialog.setTitle("Child Selector");
addNodeDialog.setMessage("Select a new child from the list");
addNodeDialog.setInitialPattern("?");
addNodeDialog.refresh();
addNodeDialog.open();
if (addNodeDialog.getResult() != null) {
// Get the exemplar
TreeComposite exemplar = exemplarMap.get(addNodeDialog
.getResult()[0]);
// Clone it. This lets you pull a sub-class of TreeComposite if
// the clone() method is overridden.
TreeComposite child = (TreeComposite) exemplar.clone();
// Add it to the tree
tree.setNextChild(child);
for (Object result : addNodeDialog.getResult()) {
// Get the exemplar
TreeComposite exemplar = exemplarMap.get(result);
// Clone it. This lets you pull a sub-class of TreeComposite
// if
// the clone() method is overridden.
TreeComposite child = (TreeComposite) exemplar.clone();
// Add it to the tree
tree.setNextChild(child);
}
} else {
// Close the list dialog otherwise
addNodeDialog.close();
......
/*******************************************************************************
* Copyright (c) 2013, 2014 UT-Battelle, LLC.
* 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:
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
*******************************************************************************/
package org.eclipse.ice.client.widgets;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
/**
* This class extends the FilteredItemsSelectionDialog for a basic list
* dialog for Tree Node Child Exemplars with a search bar that allows for
* filtering the list.
*
* @author Alex McCaskey
*
*/
public class TreeNodeFilteredItemsSelectionDialog extends FilteredItemsSelectionDialog {
/**
* The set of elements that this dialog displays.
*/
private Set<String> elements;
/**
* The constructor.
*
* @param shell
* @param list
*/
public TreeNodeFilteredItemsSelectionDialog(Shell shell, Set<String> list) {
super(shell);
elements = list;
}
/**
* The constructor for selecting multiple elements at once.
*
* @param shell
* @param multi
* @param list
*/
public TreeNodeFilteredItemsSelectionDialog(Shell shell, boolean multi, Set<String> list) {
super(shell, multi);
elements = list;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#
* createExtendedContentArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createExtendedContentArea(Composite parent) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getDialogSettings()
*/
protected IDialogSettings getDialogSettings() {
return new DialogSettings("root");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.
* lang.Object)
*/
@Override
protected IStatus validateItem(Object item) {
return Status.OK_STATUS;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
*/
@Override
protected ItemsFilter createFilter() {
return new ItemsFilter() {
public boolean matchItem(Object item) {
return matches(item.toString());
}
public boolean isConsistentItem(Object item) {
return true;
}
};
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getItemsComparator()
*/
@Override
protected Comparator getItemsComparator() {
return new Comparator() {
public int compare(Object arg0, Object arg1) {
return arg0.toString().compareTo(arg1.toString());
}
};
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.
* AbstractContentProvider,
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter,
* org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter,
IProgressMonitor progressMonitor) throws CoreException {
progressMonitor.beginTask("Searching", elements.size()); //$NON-NLS-1$
for (Iterator iter = elements.iterator(); iter.hasNext();) {
contentProvider.add(iter.next(), itemsFilter);
progressMonitor.worked(1);
}
progressMonitor.done();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.
* lang.Object)
*/
@Override
public String getElementName(Object item) {
return item.toString();
}
}
......@@ -16,6 +16,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.ice.datastructures.form.AllowedValueType;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
......@@ -46,7 +47,7 @@ public class ComboCellEditingSupport extends TextCellEditingSupport {
* is used to restrict displayed values to a set of allowed values from the
* {@link #contentProvider}.
*/
private final ComboBoxCellEditor comboCell;
private ComboBoxCellEditor comboCell;
/**
* A Map used to quickly look up an index of an element's value in its list
......@@ -55,6 +56,11 @@ public class ComboCellEditingSupport extends TextCellEditingSupport {
*/
private final Map<String, Integer> valueMap;
/**
*
*/
private Composite parent;
/**
* Overrides the default {@link ICellContentProvider} to gain access to the
* additional methods provided by {@link IComboCellContentProvider}.
......@@ -74,20 +80,14 @@ public class ComboCellEditingSupport extends TextCellEditingSupport {
* <code>EditingSupport</code> are passed to this content
* provider.
*/
public ComboCellEditingSupport(ColumnViewer viewer,
IComboCellContentProvider contentProvider) {
public ComboCellEditingSupport(ColumnViewer viewer, IComboCellContentProvider contentProvider) {
super(viewer, contentProvider);
// Store a reference to the IComboCellContentProvider.
this.contentProvider = contentProvider;
// Get the viewer's Composite so we can create the CellEditors.
Composite parent = (Composite) viewer.getControl();
// Create the ComboBoxCellEditor.
comboCell = new ComboBoxCellEditor(parent, new String[] {},
SWT.DROP_DOWN | SWT.READ_ONLY);
comboCell.getControl().setBackground(parent.getBackground());
parent = (Composite) viewer.getControl();
// Create a HashMap to contain values for discrete Entry values.
valueMap = new HashMap<String, Integer>();
......@@ -108,11 +108,23 @@ public class ComboCellEditingSupport extends TextCellEditingSupport {
// For elements that need a Combo, use the ComboBoxCellEditor.
if (contentProvider.requiresCombo(element)) {
TreeProperty property = (TreeProperty) element;
boolean isFile = property.getEntry().getValueType() == AllowedValueType.File;
if (isFile) {
comboCell = new FileComboBoxCellEditor(parent, new String[] {}, SWT.DROP_DOWN | SWT.READ_ONLY, this, property);
} else {
// Create the ComboBoxCellEditor.
comboCell = new ComboBoxCellEditor(parent, new String[] {}, SWT.DROP_DOWN | SWT.READ_ONLY);
}
comboCell.getControl().setBackground(parent.getBackground());
editor = comboCell;
// Update the Combo's items.
List<String> allowedValues = contentProvider
.getAllowedValues(element);
List<String> allowedValues = contentProvider.getAllowedValues(element);
String[] items = new String[allowedValues.size()];
comboCell.setItems(allowedValues.toArray(items));
......@@ -165,4 +177,4 @@ public class ComboCellEditingSupport extends TextCellEditingSupport {
return;
}
}
}
\ No newline at end of file
package org.eclipse.ice.client.common.properties;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.ice.client.common.internal.ClientHolder;
import org.eclipse.ice.datastructures.form.AllowedValueType;
import org.eclipse.ice.datastructures.form.BasicEntryContentProvider;
import org.eclipse.ice.datastructures.form.IEntryContentProvider;
import org.eclipse.ice.iclient.IClient;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
public class FileComboBoxCellEditor extends ComboBoxCellEditor {
/**
* Image registry key for three dot image (value
* <code>"cell_editor_dots_button_image"</code>).
*/
public static final String CELL_EDITOR_IMG_DOTS_BUTTON = "cell_editor_dots_button_image";//$NON-NLS-1$
/**
* Listens for 'focusLost' events and fires the 'apply' event as long as the
* focus wasn't lost because the dialog was opened.
*/
private FocusListener buttonFocusListener;
/**
* The editor control.
*/
private Composite editor;
/**
* The current contents.
*/
private CCombo contents;
/**
* The label that gets reused by <code>updateLabel</code>.
*/
private Label defaultLabel;
/**
* The value of this cell editor; initially <code>null</code>.
*/
private Object value = null;
/**
* The button.
*/
private Button button;
private ComboCellEditingSupport support;
private TreeProperty element;
/**
*/
public FileComboBoxCellEditor() {
super();
}
/**
*/
public FileComboBoxCellEditor(Composite parent, String[] items) {
super(parent, items, SWT.NONE);
}
/**
*/
public FileComboBoxCellEditor(Composite parent, String[] items, int style, ComboCellEditingSupport supp,
TreeProperty element) {
super(parent, items, style);
support = supp;
this.element = element;
}
@Override
protected Control createControl(Composite parent) {
Font font = parent.getFont();
Color bg = parent.getBackground();
editor = new Composite(parent, getStyle());
editor.setFont(font);
editor.setBackground(bg);
editor.setLayout(new DialogCellLayout());
contents = (CCombo) createContents(editor);
// updateContents(value);
button = createButton(editor);
button.setFont(font);
button.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == '\u001b') { // Escape
fireCancelEditor();
}
}
});
button.addFocusListener(getButtonFocusListener());
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Remove the button's focus listener since it's guaranteed
// to lose focus when the dialog opens
button.removeFocusListener(getButtonFocusListener());
IClient client = ClientHolder.getClient();
String newValue = (String) openDialogBox(editor);
System.out.println("THE NEW FILE: " + newValue);
// Re-add the listener once the dialog closes
button.addFocusListener(getButtonFocusListener());
if (newValue != null) {
// Import the files
File importedFile = new File(newValue);
client.importFile(importedFile.toURI());
String[] currentItems = FileComboBoxCellEditor.this.getItems();
String[] newItems = new String[currentItems.length + 1];
for (int i = 0; i < currentItems.length; i++) {
newItems[i] = currentItems[i];
}
newItems[currentItems.length] = importedFile.getName();
FileComboBoxCellEditor.this.setItems(newItems);
doSetValue(new Integer(currentItems.length));
IEntryContentProvider prov = new BasicEntryContentProvider();
ArrayList<String> valueList = new ArrayList<String>(Arrays.asList(newItems));
prov.setAllowedValueType(AllowedValueType.File);
// Finish setting the allowed values and default
// value
prov.setAllowedValues(valueList);
// Set the new provider
element.getEntry().setContentProvider(prov);
support.setValue(element, currentItems.length);
markDirty();
setValueValid(true);
fireApplyEditorValue();