public JSon listElements(JSon head, List <JSon> tail) { var values = new JList(head); values.AddRange(tail); return(values); }
private void AssertObject(JList list, int index, int count) { Assert.True(list[index].IsObject); var val = (JObject)list[index]; Assert.Equal(count, val.Count); }
public void Find_JListNotInJList_ReturnNegativeOne() { // Arrange int itemsToAdd = 40; JList <int> j = new JList <int>(); JList <int> find = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } find.Add(50); find.Add(60); find.Add(70); find.Add(80); find.Add(90); find.Add(100); // Act int actual = j.Find(find); // Assert int expected = -1; Assert.AreEqual(expected, actual); }
public void OperatorPlus_TwoListsWithItems_CountEqualsSumOfCount() { // Arrange int itemsToAdd = 10; JList <int> j = new JList <int>(); JList <int> k = new JList <int>(); JList <int> l = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } for (int i = 0; i < itemsToAdd; i++) { k.Add(i * 10); } // Act l = j + k; // Assert int expected = j.Count + k.Count; int actual = l.Count; Assert.AreEqual(expected, actual); }
/// <summary> /// Constructor. </summary> /// <param name="annotationDataList"> list of annotation data, if available (can pass null and reset the list /// later by calling setAnnotationData()). </param> /// <param name="hideIfEmpty"> if true, set the panel to not visible if the list is empty - this may be appropriate /// if UI real estate is in short supply and annotations should only be shown if used </param> public StateMod_Network_AnnotationDataListJPanel(IList <StateMod_Network_AnnotationData> annotationDataList, StateMod_Network_JComponent networkJComponent, bool hideIfEmpty) : base() { // Set up the layout manager this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createTitledBorder("Annotations")); int y = 0; Insets insetsTLBR = new Insets(0, 0, 0, 0); __annotationJList = new JList(); if (annotationDataList != null) { setAnnotationData(annotationDataList); } JGUIUtil.addComponent(this, new JScrollPane(__annotationJList), 0, y, 1, 1, 1.0, 1.0, insetsTLBR, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); __hideIfEmpty = hideIfEmpty; __networkJComponent = networkJComponent; // Add popup for actions on annotations //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final javax.swing.JPopupMenu popupMenu = new javax.swing.JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem removeAllAnnotationsJMenuItem = new JMenuItem(__RemoveAllAnnotationsString); removeAllAnnotationsJMenuItem.addActionListener(this); popupMenu.add(removeAllAnnotationsJMenuItem); __annotationJList.addMouseListener(new MouseAdapterAnonymousInnerClass(this, popupMenu)); checkVisibility(); }
public JSon listElements(JSon head, List <Group <JsonToken, JSon> > tail) { var values = new JList(head); values.AddRange(tail.Select(group => group.Value(0)).ToList()); return(values); }
public void Find_JListInJList_ReturnIndexWhereJListStarts() { // Arrange int itemsToAdd = 40; JList <int> j = new JList <int>(); JList <int> find = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } find.Add(5); find.Add(6); find.Add(7); find.Add(8); find.Add(9); find.Add(10); // Act int actual = j.Find(find); // Assert int expected = 5; Assert.AreEqual(expected, actual); }
public void foreach_async_test2() { var manager = LiteDbFlexerManager.Instance.Create <UserDto>(); manager.LiteDatabase.DropCollection(manager.TableName); var users = new JList <UserDto>(); users.Add(new UserDto() { Name = "a", Age = 1 }); users.Add(new UserDto() { Name = "b", Age = 2 }); users.Add(new UserDto() { Name = "c", Age = 3 }); users.forEachAsync(item => { var inserted = LiteDbFlexerManager.Instance.Create <UserDto>().LiteCollection.Insert(item); Assert.NotNull(inserted.AsObjectId); return(Task.CompletedTask); }); }
public JSon ListElementsMany(JSon value, object comma, JList tail) { var elements = new JList(value); elements.AddRange(tail); return(elements); }
public void Iteration_ListWitItems_ForLoopResultsMatchForEachLoop() { // Arrange int itemsToAdd = 40; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } // Act string actual = ""; foreach (int number in j) { actual += number.ToString() + ", "; } // Assert string expected = ""; for (int i = 0; i < j.Count; i++) { expected += j[i].ToString() + ", "; } Assert.AreEqual(expected, actual); }
public void OperatorMinus_JListNotInJList_CountRemainsSame() { // Arrange int itemsToAdd = 40; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } var k = new JList <int>() { 2, 3, 4, 59 }; var l = new JList <int>(); // Act l = j - k; // Assert int expected = j.Count; int actual = l.Count; Assert.AreEqual(expected, actual); }
public JSon ListElementsMany(JSon value, Token <JsonToken> comma, JList tail) { var elements = new JList(value); elements.AddRange(tail); return(elements); }
private void AssertInt(JList list, int index, int value) { Assert.True(list[index].IsValue); var val = (JValue)list[index]; Assert.True(val.IsInt); Assert.Equal(value, val.GetValue <int>()); }
private void AssertBool(JList list, int index, bool value) { Assert.True(list[index].IsValue); var val = (JValue)list[index]; Assert.True(val.IsBool); Assert.Equal(value, val.GetValue <bool>()); }
private void AssertDouble(JList list, int index, double value) { Assert.True(list[index].IsValue); var val = (JValue)list[index]; Assert.True(val.IsDouble); Assert.Equal(value, val.GetValue <double>()); }
private void AssertString(JList list, int index, string value) { Assert.True(list[index].IsValue); var val = (JValue)list[index]; Assert.True(val.IsString); Assert.Equal(value, val.GetValue <string>()); }
private void showJList(JScrollPane view, Point pt) { JList list = (JList)view.Viewport.View; Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, list); int row = list.locationToIndex(p); if (row == -1) { hide(); return; } Rectangle bds = list.getCellBounds(row, row); //GetCellBounds returns a width that is the //full component width; we want only what //the renderer really needs. ListCellRenderer ren = list.CellRenderer; Dimension rendererSize = ren.getListCellRendererComponent(list, list.Model.getElementAt(row), row, false, false).PreferredSize; // fix for possible npe spotted by SCO // http://pspsharp.org/forum/viewtopic.php?p=3387#p3387 if (bds == null) { hide(); return; } bds.width = rendererSize.width; if (!bds.contains(p)) { hide(); return; } //bds.width = rendererSize.width; //if (bds == null || !bds.contains(p)) { // hide(); // return; //} // end "fix for possible npe spotted by SCO" if (setCompAndRow(list, row)) { Rectangle visible = getShowingRect(view); Rectangle[] rects = getRects(bds, visible); if (rects.Length > 0) { ensureOldPopupsHidden(); painter.configure(list.Model.getElementAt(row), view, list, row); showPopups(rects, bds, visible, list, view); } else { hide(); } } }
public void TestSingleListValue() { ParseResult <JsonToken, JSon> r = Parser.Parse("[1]"); Assert.False(r.IsError); Assert.NotNull(r.Result); Assert.True(r.Result.IsList); JList list = (JList)r.Result; Assert.Equal(1, list.Count); AssertInt(list, 0, 1); }
public void ToString_NoItemsInList_EmptyString() { // Arrange string expected = "{ }"; JList <int> j = new JList <int>(); // Act string actual = j.ToString(); // Assert Assert.AreEqual(expected, actual); }
public virtual string ShowListSelectionDialog(IList <string> files, Point location) { Frame frame = new Frame(); //System.out.println(location); //frame.setLocation(location); JDialog dialog = new JDialog(frame, "Jar File Chooser", true); dialog.SetLocation(location); JList fileList = new JList(new Vector <string>(files)); fileList.SetSelectionMode(ListSelectionModelConstants.SingleSelection); IMouseListener mouseListener = new _MouseAdapter_68(dialog); // double clicked fileList.AddMouseListener(mouseListener); JScrollPane scroll = new JScrollPane(fileList); JButton okay = new JButton(); okay.SetText("Okay"); okay.SetToolTipText("Okay"); okay.AddActionListener(null); JButton cancel = new JButton(); cancel.SetText("Cancel"); cancel.SetToolTipText("Cancel"); cancel.AddActionListener(null); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); dialog.SetLayout(gridbag); constraints.gridwidth = GridBagConstraints.Remainder; constraints.fill = GridBagConstraints.Both; constraints.weightx = 1.0; constraints.weighty = 1.0; gridbag.SetConstraints(scroll, constraints); dialog.Add(scroll); constraints.gridwidth = GridBagConstraints.Relative; constraints.fill = GridBagConstraints.None; constraints.weighty = 0.0; gridbag.SetConstraints(okay, constraints); dialog.Add(okay); constraints.gridwidth = GridBagConstraints.Remainder; gridbag.SetConstraints(cancel, constraints); dialog.Add(cancel); dialog.Pack(); dialog.SetSize(dialog.GetPreferredSize()); dialog.SetVisible(true); if (fileList.IsSelectionEmpty()) { return(null); } return(files[fileList.GetSelectedIndex()]); }
public void TestManyListValue() { ParseResult <JsonTokenGeneric, JSon> r = Parser.Parse("[1,2]"); Assert.False(r.IsError); Assert.NotNull(r.Result); Assert.True(r.Result.IsList); JList list = (JList)r.Result; Assert.Equal(2, list.Count); AssertInt(list, 0, 1); AssertInt(list, 1, 2); }
public override void Execute() { JList <GetConfigResult> results = new JList <GetConfigResult>(); this.Request.forEach(item => { var doc = this.Collection.FindOne($"$.key='{item.Key}'"); results.Add(new GetConfigResult() { Key = item.Key, Content = doc["value"].AsString, }); }); this.Result = results; }
public void Add_AddItem_CountIncreasesByOne() { // Arrange JList <int> j = new JList <int>(); // Act j.Add(10); // Assert int expected = 1; int actual = j.Count; Assert.AreEqual(expected, actual); }
public void OperatorPlus_TwoListsWithItems_NewListContainsBothOldLists() { // Arrange int itemsToAdd = 10; JList <int> j = new JList <int>(); JList <int> k = new JList <int>(); JList <int> l = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } for (int i = 0; i < itemsToAdd; i++) { k.Add(i * 10); } // Act l = j + k; // Assert bool validNewList = true; for (int i = 0; i < l.Count; i++) { if (i < j.Count) { if (j[i] != l[i]) { validNewList = false; break; } } else if (i < j.Count + k.Count) { if (k[i - (j.Count - 1)] != l[i]) { validNewList = false; break; } } else { validNewList = false; break; } } Assert.IsTrue(validNewList); }
public void Add_AddItem_ItemAddedToEnd() { // Arrange int expected = 20; JList <int> j = new JList <int>(); // Act j.Add(10); j.Add(expected); // Assert int actual = j[j.Count - 1]; Assert.AreEqual(expected, actual); }
protected IEnumerable <TResult> CreateBulkService <TServiceExecutor, TRequest, TResult>(TServiceExecutor serviceExecutor, IEnumerable <TRequest> requests, Func <TServiceExecutor, bool> func = null) where TServiceExecutor : IServiceExecutor <TRequest, TResult> { var results = new JList <TResult>(); using var bulkExecutor = new BulkServiceExecutorManager <TServiceExecutor, TRequest>(requests); bulkExecutor.SetRequest((o, c) => o.Request = c) .AddFilter(func) .OnExecuted(o => { results.Add(o.Result); return(true); }); return(results); }
/// <summary> /// Configures a list cell renderer and sets up sizing and the /// backing image from it /// </summary> public bool configure(object nd, JScrollPane tv, JList list, int row) { LastRendereredObject = nd; LastRenderedScrollPane = tv; Component renderer = null; bg = list.BackgRound; bool sel = list.SelectionEmpty ? false : list.SelectionModel.isSelectedIndex(row); renderer = list.CellRenderer.getListCellRendererComponent(list, nd, row, sel, false); if (renderer != null) { Component = renderer; } return(true); }
public Hider(JComponent comp, JScrollPane pane) { if (comp is JTree) { tree = (JTree)comp; list = null; } else { list = (JList)comp; tree = null; } System.Diagnostics.Debug.Assert(tree != null || list != null); this.pane = pane; attach(); }
public void OperatorPlus_TwoEmptyLists_CountEqualsZero() { // Arrange JList <int> j = new JList <int>(); JList <int> k = new JList <int>(); JList <int> l = new JList <int>(); // Act l = j + k; // Assert int expected = j.Count + k.Count; int actual = l.Count; Assert.AreEqual(expected, actual); }
public void Sort_ListOfUnsortedValues_StringOutputInSortedOrder() { // Arrange var j = new JList <int>() { 5, 3, 7, 2, 6, 4, 1 }; // Act j = JList <int> .Sort <int>(j); // Assert string expected = "{ 1, 2, 3, 4, 5, 6, 7 }"; string actual = j.ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Default constructor /// </summary> public JStateMachine() { currentState = null; statesList = new JList<JState>(); }
public FontChooserPanel(Font font) { base.\u002Ector(); FontChooserPanel fontChooserPanel = this; string[] availableFontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); ((Container) this).setLayout((LayoutManager) new BorderLayout()); JPanel.__\u003Cclinit\u003E(); JPanel jpanel1 = new JPanel((LayoutManager) new BorderLayout()); JPanel.__\u003Cclinit\u003E(); JPanel jpanel2 = new JPanel((LayoutManager) new BorderLayout()); ((JComponent) jpanel2).setBorder((Border) BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), FontChooserPanel.localizationResources.getString("Font"))); this.fontlist = new JList((object[]) availableFontFamilyNames); JScrollPane.__\u003Cclinit\u003E(); JScrollPane jscrollPane1 = new JScrollPane((Component) this.fontlist); ((JComponent) jscrollPane1).setBorder(BorderFactory.createEtchedBorder()); ((Container) jpanel2).add((Component) jscrollPane1); ((Container) this).add((Component) jpanel2); JPanel.__\u003Cclinit\u003E(); JPanel jpanel3 = new JPanel((LayoutManager) new BorderLayout()); ((JComponent) jpanel3).setBorder((Border) BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), FontChooserPanel.localizationResources.getString("Size"))); JList.__\u003Cclinit\u003E(); this.sizelist = new JList((object[]) FontChooserPanel.__\u003C\u003ESIZES); JScrollPane.__\u003Cclinit\u003E(); JScrollPane jscrollPane2 = new JScrollPane((Component) this.sizelist); ((JComponent) jscrollPane2).setBorder(BorderFactory.createEtchedBorder()); ((Container) jpanel3).add((Component) jscrollPane2); JPanel.__\u003Cclinit\u003E(); JPanel jpanel4 = new JPanel((LayoutManager) new GridLayout(1, 2)); JCheckBox.__\u003Cclinit\u003E(); this.bold = new JCheckBox(FontChooserPanel.localizationResources.getString("Bold")); JCheckBox.__\u003Cclinit\u003E(); this.italic = new JCheckBox(FontChooserPanel.localizationResources.getString("Italic")); ((Container) jpanel4).add((Component) this.bold); ((Container) jpanel4).add((Component) this.italic); ((JComponent) jpanel4).setBorder((Border) BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), FontChooserPanel.localizationResources.getString("Attributes"))); ((Container) jpanel1).add((Component) jpanel3, (object) "Center"); ((Container) jpanel1).add((Component) jpanel4, (object) "South"); ((Container) this).add((Component) jpanel1, (object) "East"); this.setSelectedFont(font); }
public void AddList(JList<int?> lst) { JObject.JInvokeMethod(nCahceType, "AddList", this, new object[] { lst }); }
public virtual Component getListCellRendererComponent(JList list, object value, int index, bool isSelected, bool cellHasFocus) { if (value is Stroke) this.setStroke((Stroke) value); else this.setStroke((Stroke) null); return (Component) this; }
public virtual Component getListCellRendererComponent(JList list, object value, int index, bool isSelected, bool cellHasFocus) { if (value is PaletteSample) this.setPalette(((PaletteSample) value).getPalette()); return (Component) this; }
private MultiSlotEditor(FactEditor enclosingInstance) { InitBlock(enclosingInstance); popupMenu = new JPopupMenu(); addMenuItem = new JMenuItem("add value", IconLoader.getImageIcon("add")); addMenuItem.addActionListener(this); editMenuItem = new JMenuItem("edit value", IconLoader.getImageIcon("pencil")); editMenuItem.addActionListener(this); deleteMenuItem = new JMenuItem("remove value", IconLoader.getImageIcon("delete")); deleteMenuItem.addActionListener(this); popupMenu.add(addMenuItem); popupMenu.add(editMenuItem); popupMenu.add(deleteMenuItem); popupMenu.addPopupMenuListener(this); list = new JList(listModel); list.setVisibleRowCount(4); //list.setComponentPopupMenu(popupMenu); }
private void initPreselectionPanel() { //UPGRADE_ISSUE: Class 'java.awt.GridBagLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagLayout"' //UPGRADE_ISSUE: Constructor 'java.awt.GridBagLayout.GridBagLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagLayout"' GridBagLayout gridbag = new GridBagLayout(); //UPGRADE_ISSUE: Class 'java.awt.GridBagConstraints' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Constructor 'java.awt.GridBagConstraints.GridBagConstraints' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' GridBagConstraints c = new GridBagConstraints(); JPanel preselectionPanel = new JPanel(gridbag); preselectionPanel.setBorder(BorderFactory.createTitledBorder("Module and Template Selection")); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.fill' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.BOTH' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.fill = GridBagConstraints.BOTH; moduleList = new JList(moduleListModel); moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); moduleList.SelectionModel.addListSelectionListener(this); Collection modules = engine.WorkingMemory.Modules; Iterator itr = modules.iterator(); while (itr.hasNext()) { Module mod = (Module) itr.next(); moduleListModel.addElement(mod.ModuleName); } JPanel modulePanel = new JPanel(); modulePanel.setLayout(new BoxLayout(modulePanel, BoxLayout.Y_AXIS)); modulePanel.add(new JLabel("Select a Module:")); modulePanel.add(new JScrollPane(moduleList)); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.weightx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.weightx = 0.5; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridy' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = c.gridy = 0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.weighty' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.weighty = 1.0; // c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(modulePanel, c); preselectionPanel.add(modulePanel); templateList = new JList(templateListModel); templateList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); templateList.SelectionModel.addListSelectionListener(this); initTemplateList(); JPanel templatePanel = new JPanel(); templatePanel.setLayout(new BoxLayout(templatePanel, BoxLayout.Y_AXIS)); templatePanel.add(new JLabel("Select a Template:")); templatePanel.add(new JScrollPane(templateList)); // c.gridwidth = GridBagConstraints.REMAINDER; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = 1; gridbag.setConstraints(templatePanel, c); preselectionPanel.add(templatePanel); JPanel dumpAreaPanel = new JPanel(); dumpAreaPanel.setLayout(new BoxLayout(dumpAreaPanel, BoxLayout.Y_AXIS)); dumpAreaPanel.add(new JLabel("Template Definition:")); dumpAreaPanel.add(new JScrollPane(dumpAreaTemplate)); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.weightx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.weightx = 0.0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridwidth' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridwidth = 2; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridy' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridy = 1; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = 0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.fill' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.BOTH' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(dumpAreaPanel, c); preselectionPanel.add(dumpAreaPanel); contentPanel.add(preselectionPanel, "preselection"); }