X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.ui%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fui%2Feditor%2FSpreadsheetSelectionProcessor.java;h=11da9ac7b1779a22c59e4f6c0dd33195dad72aa0;hb=refs%2Fchanges%2F38%2F238%2F2;hp=59475f3bbed1cdf4f8e153264dfe73649f6e5fad;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/editor/SpreadsheetSelectionProcessor.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/editor/SpreadsheetSelectionProcessor.java index 59475f3bb..11da9ac7b 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/editor/SpreadsheetSelectionProcessor.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/editor/SpreadsheetSelectionProcessor.java @@ -1,77 +1,77 @@ -package org.simantics.spreadsheet.ui.editor; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; -import org.simantics.selectionview.ComparableTabContributor; -import org.simantics.selectionview.SelectionProcessor; -import org.simantics.spreadsheet.resource.SpreadsheetResource; -import org.simantics.spreadsheet.ui.TableSelection; -import org.simantics.spreadsheet.ui.editor.NoCellTab.NoCellInput; -import org.simantics.spreadsheet.util.SpreadsheetUtils; - -/** - * @author Tuukka Lehtonen - */ -public class SpreadsheetSelectionProcessor implements SelectionProcessor, ReadGraph> { - - @Override - public Collection process(Collection selection, ReadGraph graph) { - try { - if(selection == null) return Collections.emptyList(); - if(selection.size() != 3) return Collections.emptyList(); - Iterator it = selection.iterator(); - final Variable variable = (Variable)it.next(); - it.next(); - final TableSelection sel = (TableSelection)it.next(); - int row = sel.getRows()[0]; - int column = sel.getColumns()[0]; - String location = SpreadsheetUtils.cellName(row, column); - ArrayList result = new ArrayList(); - final Variable cell = variable.getPossibleChild(graph, location); - if(cell != null) { - SpreadsheetResource sr = SpreadsheetResource.getInstance(graph); - //result.add(new ComparableTabContributor(new SheetTab(), 2, variable, "Sheet")); - final Resource type = cell.getPossiblePropertyValue(graph, Variables.TYPE); - if(sr.TextCell.equals(type)) { - result.add(new ComparableTabContributor(new TextCellTab(), 3, cell, "Configuration")); -// if(sr.ExpressionRealization.equals(type)) { -// Variable expression = cell.getPossibleProperty(graph, "Expression"); -// if(expression != null) { -// result.add(new ComparableTabContributor(new ExpressionCellTab(), 3, cell, "Configuration")); -// } else { -// -// } -// } else if(sr.CommandRealization.equals(type)) { -// result.add(new ComparableTabContributor(new CommandCellTab(), 3, cell, "Configuration")); -// } else if(sr.TextRealization.equals(type)) { -// result.add(new ComparableTabContributor(new TextCellTab(), 3, cell, "Configuration")); -// } else if(sr.MatrixRealization.equals(type)) { -// result.add(new ComparableTabContributor(new MatrixCellTab(), 3, cell, "Configuration")); -// } -// System.out.println("cell type = " + type); -// final String content = cell.getPossiblePropertyValue(graph, "Content"); -// if(content != null) { -// final Variable contentVariable = Variables.getVariable(graph, content); -// if(variable == null) return Collections.emptyList(); -// return Collections.singleton(new ComparableTabContributor(new SpreadsheetTab(), 3, contentVariable, "Configuration")); - } else { - return Collections.emptyList(); - } - } else { - result.add(new ComparableTabContributor(new NoCellTab(), 3, new NoCellInput(variable, location), "Configuration")); - } - return result; - } catch (Throwable t) { - t.printStackTrace(); - return Collections.emptyList(); - } - } - +package org.simantics.spreadsheet.ui.editor; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; +import org.simantics.selectionview.ComparableTabContributor; +import org.simantics.selectionview.SelectionProcessor; +import org.simantics.spreadsheet.resource.SpreadsheetResource; +import org.simantics.spreadsheet.ui.TableSelection; +import org.simantics.spreadsheet.ui.editor.NoCellTab.NoCellInput; +import org.simantics.spreadsheet.util.SpreadsheetUtils; + +/** + * @author Tuukka Lehtonen + */ +public class SpreadsheetSelectionProcessor implements SelectionProcessor, ReadGraph> { + + @Override + public Collection process(Collection selection, ReadGraph graph) { + try { + if(selection == null) return Collections.emptyList(); + if(selection.size() != 3) return Collections.emptyList(); + Iterator it = selection.iterator(); + final Variable variable = (Variable)it.next(); + it.next(); + final TableSelection sel = (TableSelection)it.next(); + int row = sel.getRows()[0]; + int column = sel.getColumns()[0]; + String location = SpreadsheetUtils.cellName(row, column); + ArrayList result = new ArrayList(); + final Variable cell = variable.getPossibleChild(graph, location); + if(cell != null) { + SpreadsheetResource sr = SpreadsheetResource.getInstance(graph); + //result.add(new ComparableTabContributor(new SheetTab(), 2, variable, "Sheet")); + final Resource type = cell.getPossiblePropertyValue(graph, Variables.TYPE); + if(sr.TextCell.equals(type)) { + result.add(new ComparableTabContributor(new TextCellTab(), 3, cell, "Configuration")); +// if(sr.ExpressionRealization.equals(type)) { +// Variable expression = cell.getPossibleProperty(graph, "Expression"); +// if(expression != null) { +// result.add(new ComparableTabContributor(new ExpressionCellTab(), 3, cell, "Configuration")); +// } else { +// +// } +// } else if(sr.CommandRealization.equals(type)) { +// result.add(new ComparableTabContributor(new CommandCellTab(), 3, cell, "Configuration")); +// } else if(sr.TextRealization.equals(type)) { +// result.add(new ComparableTabContributor(new TextCellTab(), 3, cell, "Configuration")); +// } else if(sr.MatrixRealization.equals(type)) { +// result.add(new ComparableTabContributor(new MatrixCellTab(), 3, cell, "Configuration")); +// } +// System.out.println("cell type = " + type); +// final String content = cell.getPossiblePropertyValue(graph, "Content"); +// if(content != null) { +// final Variable contentVariable = Variables.getVariable(graph, content); +// if(variable == null) return Collections.emptyList(); +// return Collections.singleton(new ComparableTabContributor(new SpreadsheetTab(), 3, contentVariable, "Configuration")); + } else { + return Collections.emptyList(); + } + } else { + result.add(new ComparableTabContributor(new NoCellTab(), 3, new NoCellInput(variable, location), "Configuration")); + } + return result; + } catch (Throwable t) { + t.printStackTrace(); + return Collections.emptyList(); + } + } + } \ No newline at end of file