Beispiel #1
0
        void TaskPriorityCellDataFunc(Gtk.TreeViewColumn tree_column,
                                      Gtk.CellRenderer cell,
                                      Gtk.TreeModel tree_model,
                                      Gtk.TreeIter iter)
        {
            // TODO: Add bold (for high), light (for None), and also colors to priority?
            Gtk.CellRendererCombo crc = cell as Gtk.CellRendererCombo;
            ITask task = Model.GetValue(iter, 0) as ITask;

            if (task == null)
            {
                return;
            }

            switch (task.Priority)
            {
            case TaskPriority.Low:
                crc.Text = Catalog.GetString("3");
                break;

            case TaskPriority.Medium:
                crc.Text = Catalog.GetString("2");
                break;

            case TaskPriority.High:
                crc.Text = Catalog.GetString("1");
                break;

            default:
                crc.Text = Catalog.GetString("-");
                break;
            }
        }
Beispiel #2
0
        protected virtual void DueDateCellDataFunc(Gtk.TreeViewColumn treeColumn,
                                                   Gtk.CellRenderer renderer, Gtk.TreeModel model,
                                                   Gtk.TreeIter iter)
        {
            Gtk.CellRendererCombo crc = renderer as Gtk.CellRendererCombo;
            ITask task = Model.GetValue(iter, 0) as ITask;

            if (task == null)
            {
                return;
            }

            DateTime date = task.State == TaskState.Completed ?
                            task.CompletionDate :
                            task.DueDate;

            if (date == DateTime.MinValue || date == DateTime.MaxValue)
            {
                crc.Text = "-";
                return;
            }

            if (date.Year == DateTime.Today.Year)
            {
                crc.Text = date.ToString(Catalog.GetString("M/d - ddd"));
            }
            else
            {
                crc.Text = date.ToString(Catalog.GetString("M/d/yy - ddd"));
            }
            //Utilities.GetPrettyPrintDate (task.DueDate, false);
        }
        /// <summary>
        /// Experimental function
        /// </summary>
        /// <returns>
        /// The combo column.
        /// </returns>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        public Gtk.TreeViewColumn AppendComboColumn(string name, EditedHandler EditedHandler, bool editable, string[] comboValues)
        {
            var listStore = new Gtk.ListStore(typeof(string));

            foreach (var value in comboValues)
            {
                listStore.AppendValues(value);
            }

            var cellRenderer = new Gtk.CellRendererCombo();

            cellRenderer.Editable            = editable;
            cellRenderer.TextColumn          = 0;
            cellRenderer.HasEntry            = false;
            cellRenderer.Model               = listStore;
            cellRenderer.Data["colPosition"] = Columns.Count;
            if (EditedHandler != null)
            {
                cellRenderer.Edited += EditedHandler;
            }

            var newColumn = new Gtk.TreeViewColumn();

            newColumn.Title = name;

            newColumn.PackStart(cellRenderer, true);
            Columns.Add(newColumn);

            newColumn.Data["cellRenderer"] = cellRenderer;
            newColumn.Data["cellType"]     = "text";
            newColumn.Data["cellTypeOf"]   = typeof(string);

            return(newColumn);
        }
Beispiel #4
0
//  void CompletionDateCellDataFunc (Gtk.TreeViewColumn tree_column,
//    Gtk.CellRenderer cell, Gtk.TreeModel tree_model,
//    Gtk.TreeIter iter)
//  {
//   Gtk.Extras.CellRendererDate crd = cell as Gtk.Extras.CellRendererDate;
//   Task task = tree_model.GetValue (iter, 0) as Task;
//   if (task == null)
//    crd.Date = DateTime.MinValue;
//   else
//    crd.Date = task.CompletionDate;
//  }

        void PriorityCellDataFunc(Gtk.TreeViewColumn tree_column,
                                  Gtk.CellRenderer cell, Gtk.TreeModel tree_model,
                                  Gtk.TreeIter iter)
        {
            // FIXME: Add bold (for high), light (for None), and also colors to priority?
            Gtk.CellRendererCombo crc = cell as Gtk.CellRendererCombo;
            Task task = tree_model.GetValue(iter, 0) as Task;

            switch (task.Priority)
            {
            case TaskPriority.Low:
                crc.Text = Catalog.GetString("Low");
                break;

            case TaskPriority.Normal:
                crc.Text = Catalog.GetString("Normal");
                break;

            case TaskPriority.High:
                crc.Text = Catalog.GetString("High");
                break;

            default:
                crc.Text = Catalog.GetString("None");
                break;
            }
        }
        void BuildGui()
        {
            CellRendererText cellId = new CellRendererText();
            TreeViewColumn idColumn = new TreeViewColumn();
            idColumn.Title = GettextCatalog.GetString("ID");
            idColumn.PackStart(cellId, false);
            idColumn.AddAttribute(cellId, "text", 0);

            CellRendererText cellTitle = new CellRendererText();
            TreeViewColumn titleColumn = new TreeViewColumn();
            titleColumn.Title = "Title";
            titleColumn.Expand = true;
            titleColumn.Sizing = TreeViewColumnSizing.Fixed;
            titleColumn.PackStart(cellTitle, true);
            titleColumn.AddAttribute(cellTitle, "text", 1);

            CellRendererCombo cellAction = new CellRendererCombo();
            TreeViewColumn actionColumn = new TreeViewColumn();
            actionColumn.Title = "Action";
            actionColumn.PackStart(cellAction, false);
            actionColumn.AddAttribute(cellAction, "text", 2);
            cellAction.Editable = true;
            cellAction.Model = checkinActions;
            cellAction.TextColumn = 0;
            cellAction.HasEntry = false;
            cellAction.Edited += OnActionChanged;
            //checkinActions.AppendValues(WorkItemCheckinAction.None.ToString());
            checkinActions.AppendValues(WorkItemCheckinAction.Associate.ToString());
            //checkinActions.AppendValues(WorkItemCheckinAction.Resolve.ToString());

            workItemsView.AppendColumn(idColumn);
            workItemsView.AppendColumn(titleColumn);
            workItemsView.AppendColumn(actionColumn);

            workItemsView.Model = workItemStore;
            workItemsView.WidthRequest = 300;
            workItemsView.HeightRequest = 120;

            this.PackStart(workItemsView, true, true, 3);

            VButtonBox buttonBox = new VButtonBox();
            Button addButton = new Button();
            addButton.Label = GettextCatalog.GetString("Add Work Item");
            addButton.Clicked += OnAddWorkItem;
            removeButton.Label = GettextCatalog.GetString("Remove Work Item");
            removeButton.Sensitive = false;
            removeButton.Clicked += OnRemoveWorkItem;

            addButton.WidthRequest = removeButton.WidthRequest = 150;

            buttonBox.PackStart(addButton);
            buttonBox.PackStart(removeButton);
            buttonBox.Layout = ButtonBoxStyle.Start;

            this.PackStart(buttonBox, false, false, 3);

            this.ShowAll();
        }
        // END HERZUM BUG FIX: alignment input-output TLAB-255


        /// <summary>
        /// Creates the input mapping column with combo box.
        /// TODO improve the input mapping combo box:
        /// 1. it doesn't set values until combo box loses focus within table view confirm change - Edited event is raised only then
        /// 2. there is no indication that the field can be modified - render combo box always, OR show some icon that it can be modified
        /// </summary>
        /// <returns>
        /// The input mapping column with combo box.
        /// </returns>
        /// <param name='inputStore'>
        /// Input store.
        /// </param>
        private TreeViewColumn CreateInputMappingColumnWithComboBox(NodeStore inputStore, string columntTitle)
        {
            Gtk.CellRendererCombo comboRenderer = new Gtk.CellRendererCombo();

            comboRenderer.HasEntry   = false;
            comboRenderer.Mode       = CellRendererMode.Editable;
            comboRenderer.TextColumn = 0;
            comboRenderer.Editable   = true;

            ListStore comboBoxStore = new ListStore(typeof(string));

            comboRenderer.Model = comboBoxStore;

            //when user activates combo box, refresh combobox store with available input mapping per node
            comboRenderer.EditingStarted += delegate(object o, EditingStartedArgs args)
            {
                comboBoxStore.Clear();
                IOItemNode     currentItem = (IOItemNode)inputStore.GetNode(new TreePath(args.Path));
                ExperimentNode currentNode = m_component.ExperimentNode;
                string         currentType = currentItem.Type;
                // HERZUM SPRINT 2.4: TLAB-162
                //InputMappings availableInputMappingsPerNode = new InputMappings (currentNode.Owner);
                InputMappings availableInputMappingsPerNode = new InputMappings(m_applicationContext.Application.Experiment);
                // END HERZUM SPRINT 2.4: TLAB-162
                if (currentNode != null && availableInputMappingsPerNode.ContainsMappingsForNode(currentNode))
                {
                    foreach (string incomingOutput in availableInputMappingsPerNode[currentNode].Keys)
                    {
                        if (string.Equals(currentType, availableInputMappingsPerNode [currentNode] [incomingOutput]))
                        {
                            comboBoxStore.AppendValues(Mono.Unix.Catalog.GetString(incomingOutput));
                        }
                    }
                }
            };

            //when edition has been completed set current item node with proper mapping
            comboRenderer.Edited += delegate(object o, EditedArgs args) {
                IOItemNode n = (IOItemNode)inputStore.GetNode(new TreePath(args.Path));
                n.MappedTo = args.NewText;
                RefreshIOHighlightInExperiment(n.MappedTo);
            };

            //finally create the column with above combo renderer
            var mappedToColumn = new TreeViewColumn();

            mappedToColumn.Title = columntTitle;
            mappedToColumn.PackStart(comboRenderer, true);

            //this method sets the text view to current mapping, when combo box is not active
            mappedToColumn.SetCellDataFunc(comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, ITreeNode node) {
                IOItemNode currentItem = (IOItemNode)node;
                comboRenderer.Text     = currentItem.MappedTo;
            });

            return(mappedToColumn);
        }
Beispiel #7
0
 protected void CellEditingStartedHandler(object o, EditingStartedArgs args)
 {
     Console.WriteLine($"CellEditingStartedHandler");
     if (o is Gtk.CellRendererCombo)
     {
         Gtk.CellRendererCombo cellRendererCombo = (Gtk.CellRendererCombo)o;
         ((Gtk.ListStore)cellRendererCombo.Model).Clear();
         ((Gtk.ListStore)cellRendererCombo.Model).AppendValues("A");
         ((Gtk.ListStore)cellRendererCombo.Model).AppendValues("B");
     }
 }
Beispiel #8
0
        public PayAccrual()
        {
            this.Build ();

            ComboBox IncomeCombo = new ComboBox();
            ComboWorks.ComboFillReference(IncomeCombo,"income_items", ComboWorks.ListMode.OnlyItems);
            IncomeNameList = IncomeCombo.Model;
            IncomeCombo.Destroy ();

            //Создаем таблицу "Услуги"
            ServiceListStore = new Gtk.ListStore (typeof (bool),
                                                  typeof (int),
                                                  typeof (string),
                                                  typeof (int),
                                                  typeof (string),
                                                  typeof (int),
                                                  typeof (string),
                                                  typeof (decimal),
                                                  typeof(long));

            CellRendererToggle CellPay = new CellRendererToggle();
            CellPay.Activatable = true;
            CellPay.Toggled += onCellPayToggled;

            Gtk.TreeViewColumn IncomeItemsColumn = new Gtk.TreeViewColumn ();
            IncomeItemsColumn.Title = "Статья дохода";
            IncomeItemsColumn.MinWidth = 130;
            Gtk.CellRendererCombo CellIncomeItems = new CellRendererCombo();
            CellIncomeItems.TextColumn = 0;
            CellIncomeItems.Editable = true;
            CellIncomeItems.Model = IncomeNameList;
            CellIncomeItems.HasEntry = false;
            CellIncomeItems.Edited += OnIncomeItemComboEdited;
            IncomeItemsColumn.PackStart (CellIncomeItems, true);

            Gtk.TreeViewColumn SumColumn = new Gtk.TreeViewColumn ();
            SumColumn.Title = "Сумма";
            SumColumn.MinWidth = 90;
            Gtk.CellRendererText CellSum = new CellRendererText();
            CellSum.Editable = true;
            CellSum.Edited += OnSumTextEdited;
            SumColumn.PackStart (CellSum, true);

            treeviewServices.AppendColumn("Оплатить", CellPay, "active", (int)ServiceCol.pay);
            treeviewServices.AppendColumn ("Услуга", new Gtk.CellRendererText (), "text", (int)ServiceCol.service);
            treeviewServices.AppendColumn ("Касса", new Gtk.CellRendererText (), "text", (int)ServiceCol.cash);
            treeviewServices.AppendColumn (IncomeItemsColumn);
            IncomeItemsColumn.AddAttribute (CellIncomeItems, "text", (int)ServiceCol.income);
            treeviewServices.AppendColumn (SumColumn);
            SumColumn.SetCellDataFunc (CellSum, RenderSumColumn);

            treeviewServices.Model = ServiceListStore;
            treeviewServices.ShowAll();
        }
		public InspectionPanelWidget (string mimeType)
		{
			this.Build ();
//			this.mimeType = mimeType;
			
			
			treeviewInspections.AppendColumn ("Title", new CellRendererText (), "text", 0);
			
			
			var comboRenderer = new CellRendererCombo ();
			var col = treeviewInspections.AppendColumn ("Severity", comboRenderer);
			
			var comboBoxStore = new ListStore (typeof(string), typeof(QuickTaskSeverity));
			comboBoxStore.AppendValues (GetDescription (QuickTaskSeverity.None), QuickTaskSeverity.None);
			comboBoxStore.AppendValues (GetDescription (QuickTaskSeverity.Error), QuickTaskSeverity.Error);
			comboBoxStore.AppendValues (GetDescription (QuickTaskSeverity.Warning), QuickTaskSeverity.Warning);
			comboBoxStore.AppendValues (GetDescription (QuickTaskSeverity.Hint), QuickTaskSeverity.Hint);
			comboBoxStore.AppendValues (GetDescription (QuickTaskSeverity.Suggestion), QuickTaskSeverity.Suggestion);
			comboRenderer.Model = comboBoxStore;
			comboRenderer.Mode = CellRendererMode.Activatable;
			comboRenderer.TextColumn = 0;
			comboRenderer.Editable = true;
			comboRenderer.HasEntry = false;
			
			comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) {
				Gtk.TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path))
					return;
				
				Gtk.TreeIter storeIter;
				if (!comboBoxStore.GetIterFirst (out storeIter))
					return;
				Console.WriteLine ("new text:" + args.NewText);
				do {
					if ((string)comboBoxStore.GetValue (storeIter, 0) == args.NewText) {
						treeStore.SetValue (iter, 1, (QuickTaskSeverity)comboBoxStore.GetValue (storeIter, 1));
						return;
					}
				} while (comboBoxStore.IterNext (ref storeIter));
			};
			
			col.SetCellDataFunc (comboRenderer, delegate (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
				var severity = (QuickTaskSeverity)treeStore.GetValue (iter, 1);
				comboRenderer.Text = GetDescription (severity);
			});
			treeviewInspections.HeadersVisible = false;
			treeviewInspections.Model = treeStore;
			treeviewInspections.Selection.Changed += HandleSelectionChanged;

			foreach (var node in RefactoringService.GetInspectors (mimeType)) {
				treeStore.AppendValues (node.Title, node.GetSeverity (), node);
			}
		}
Beispiel #10
0
        public MeterType( bool New)
        {
            this.Build ();

            ComboBox ServiceCombo = new ComboBox();
            ComboWorks.ComboFillReference(ServiceCombo,"services", ComboWorks.ListMode.WithNo);
            ServiceNameList = ServiceCombo.Model;
            ServiceCombo.Destroy ();

            TariffListStore = new Gtk.ListStore (typeof (int), 	// 0 - tariff id
                                                  typeof (string),	// 1 - Name
                                                  typeof (int),		// 2 - Service id
                                                 typeof (string)	// 3 - Service name
                                                  );

            Gtk.CellRendererCombo CellService = new CellRendererCombo();
            CellService.TextColumn = 0;
            CellService.Editable = true;
            CellService.Model = ServiceNameList;
            CellService.HasEntry = false;
            CellService.Edited += OnServiceComboEdited;
            CellService.EditingStarted += OnServiceComboStartEdited;

            Gtk.CellRendererText CellName = new CellRendererText();
            CellName.Editable = true;
            CellName.Edited += OnCellNameEdited;

            //treeviewTariff.AppendColumn ("Код", new Gtk.CellRendererText (), "text", 0);
            treeviewTariff.AppendColumn ("Название", CellName, "text", 1);
            treeviewTariff.AppendColumn ("Услуга для оплаты", CellService, "text", 3);

            treeviewTariff.Model = TariffListStore;
            treeviewTariff.ShowAll();

            if(New)
            {
                NewItem = New;
                TariffListStore.AppendValues (-1,
                                              "Основной",
                                              -1,
                                              "нет");
            }
        }
Beispiel #11
0
        public static void AppendColumns(TreeView treeView, IDataReader dataReader)
        {
            tv = treeView;
            for (int index = 0; index < dataReader.FieldCount; index++)
            {
                Console.WriteLine("el indice es: {0}", index);
                treeView.AppendColumn (dataReader.GetName (index), new CellRendererText(), "text", index);

            }

            //Gtk.EditedArgs args = new Gtk.EditedArgs();
            Gtk.ListStore treeModel = new ListStore(typeof(string));

            treeView.Model = treeModel;

            // Values to be chosen in the ComboBox
            Gtk.ListStore comboModel = new ListStore(typeof(string));
            Gtk.ComboBox comboBox = new ComboBox(comboModel);
            comboBox.AppendText("Selecciona una cantidad");
            comboBox.AppendText("1");
            comboBox.AppendText("2");
            comboBox.AppendText("3");
            comboBox.Active = 0;

            Gtk.TreeViewColumn comboCol = new TreeViewColumn();
            Gtk.CellRendererCombo comboCell = new CellRendererCombo();
            comboCol.Title = "Combo Column";
            comboCol.PackStart(comboCell, true);
            comboCol.AddAttribute(comboCell, "text", 4);
            comboCell.Editable = true;
            comboCell.Edited += OnEdited;
            comboCell.TextColumn = 0;
            comboCell.Text = comboBox.ActiveText;
            comboCell.Model = comboModel;
            comboCell.WidthChars = 20;

            treeView.AppendColumn(comboCol);
        }
		//TODO: difference between columns and reference columns + combo events
		public ForeignKeyConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, TableSchemaCollection tables, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints)
		{
			if (columns == null)
				throw new ArgumentNullException ("columns");
			if (table == null)
				throw new ArgumentNullException ("table");
			if (constraints == null)
				throw new ArgumentNullException ("constraints");
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			if (tables == null)
				throw new ArgumentNullException ("tables");
			
			this.schemaProvider = schemaProvider;
			this.table = table;
			this.tables = tables;
			this.columns = columns;
			this.constraints = constraints;
			this.action = action;
			
			this.Build();
			
			store = new ListStore (typeof (string), typeof (string), typeof (bool), typeof (string), typeof (string), typeof (string), typeof (string), typeof (object));
			listFK.Model = store;
			
			storeActions = new ListStore (typeof (string), typeof (int));
			storeTables = new ListStore (typeof (string));
			
			IDbFactory fac = schemaProvider.ConnectionPool.DbFactory;
			if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action,  ForeignKeyConstraintCapabilities.Cascade))
				storeActions.AppendValues ("Cascade", ForeignKeyAction.Cascade);
			if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action,  ForeignKeyConstraintCapabilities.Restrict))
				storeActions.AppendValues ("Restrict", ForeignKeyAction.Restrict);
			if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action,  ForeignKeyConstraintCapabilities.NoAction))
				storeActions.AppendValues ("No Action", ForeignKeyAction.NoAction);
			if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action,  ForeignKeyConstraintCapabilities.SetNull))
				storeActions.AppendValues ("Set Null", ForeignKeyAction.SetNull);
			if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action,  ForeignKeyConstraintCapabilities.SetDefault))
				storeActions.AppendValues ("Set Default", ForeignKeyAction.SetDefault);

			foreach (TableSchema tbl in tables)
				if (tbl.Name != table.Name)
					storeTables.AppendValues (tbl.Name);
			
			TreeViewColumn colName = new TreeViewColumn ();
			TreeViewColumn colRefTable = new TreeViewColumn ();
			TreeViewColumn colIsColumnConstraint = new TreeViewColumn ();
			TreeViewColumn colDeleteAction = new TreeViewColumn ();
			TreeViewColumn colUpdateAction = new TreeViewColumn ();
			
			colName.Title = GettextCatalog.GetString ("Name");
			colRefTable.Title = GettextCatalog.GetString ("Reference Table");
			colIsColumnConstraint.Title = GettextCatalog.GetString ("Column Constraint");
			colDeleteAction.Title = GettextCatalog.GetString ("Delete Action");
			colUpdateAction.Title = GettextCatalog.GetString ("Update Action");
			
			colRefTable.MinWidth = 120;
			
			CellRendererText nameRenderer = new CellRendererText ();
			CellRendererCombo refTableRenderer = new CellRendererCombo ();
			CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle ();
			CellRendererCombo deleteActionRenderer = new CellRendererCombo ();
			CellRendererCombo updateActionRenderer = new CellRendererCombo ();
			
			nameRenderer.Editable = true;
			nameRenderer.Edited += new EditedHandler (NameEdited);
			
			refTableRenderer.Model = storeTables;
			refTableRenderer.TextColumn = 0;
			refTableRenderer.Editable = true;
			refTableRenderer.Edited += new EditedHandler (RefTableEdited);
			
			isColumnConstraintRenderer.Activatable = true;
			isColumnConstraintRenderer.Toggled += new ToggledHandler (IsColumnConstraintToggled);
			
			deleteActionRenderer.Model = storeActions;
			deleteActionRenderer.TextColumn = 0;
			deleteActionRenderer.Editable = true;
			deleteActionRenderer.Edited += new EditedHandler (DeleteActionEdited);
			
			updateActionRenderer.Model = storeActions;
			updateActionRenderer.TextColumn = 0;
			updateActionRenderer.Editable = true;
			updateActionRenderer.Edited += new EditedHandler (UpdateActionEdited);

			colName.PackStart (nameRenderer, true);
			colRefTable.PackStart (refTableRenderer, true);
			colIsColumnConstraint.PackStart (isColumnConstraintRenderer, true);
			colDeleteAction.PackStart (deleteActionRenderer, true);
			colUpdateAction.PackStart (updateActionRenderer, true);

			colName.AddAttribute (nameRenderer, "text", colNameIndex);
			colRefTable.AddAttribute (refTableRenderer, "text", colReferenceTableIndex);
			colIsColumnConstraint.AddAttribute (isColumnConstraintRenderer, "active", colIsColumnConstraintIndex);
			colDeleteAction.AddAttribute (deleteActionRenderer, "text", colDeleteActionIndex);			
			colUpdateAction.AddAttribute (updateActionRenderer, "text", colUpdateActionIndex);
			
			listFK.AppendColumn (colName);
			listFK.AppendColumn (colRefTable);
			listFK.AppendColumn (colIsColumnConstraint);
			listFK.AppendColumn (colDeleteAction);
			listFK.AppendColumn (colUpdateAction);
			
			columnSelecter.ColumnToggled += new EventHandler (ColumnToggled);
			referenceColumnSelecter.ColumnToggled += new EventHandler (ReferenceColumnToggled);
			listFK.Selection.Changed += new EventHandler (SelectionChanged);
			
			ShowAll ();
		}
		public TriggersEditorWidget (ISchemaProvider schemaProvider, SchemaActions action)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			this.action = action;
			
			this.Build();
			
			sqlEditor.Editable = false;
			sqlEditor.TextChanged += new EventHandler (SourceChanged);
			
			store = new ListStore (typeof (string), typeof (string), typeof (string), typeof (bool), typeof (string), typeof (bool), typeof (string), typeof (string), typeof (object));
			storeTypes = new ListStore (typeof (string));
			storeEvents = new ListStore (typeof (string));
			listTriggers.Model = store;
			listTriggers.Selection.Changed += new EventHandler (OnSelectionChanged);
			
			foreach (string name in Enum.GetNames (typeof (TriggerType)))
			         storeTypes.AppendValues (name);
			foreach (string name in Enum.GetNames (typeof (TriggerEvent)))
			         storeEvents.AppendValues (name);
			
			TreeViewColumn colName = new TreeViewColumn ();
			TreeViewColumn colType = new TreeViewColumn ();
			TreeViewColumn colEvent = new TreeViewColumn ();
			TreeViewColumn colFireType = new TreeViewColumn ();
			TreeViewColumn colPosition = new TreeViewColumn ();
			TreeViewColumn colActive = new TreeViewColumn ();
			TreeViewColumn colComment = new TreeViewColumn ();
			
			colName.Title = AddinCatalog.GetString ("Name");
			colType.Title = AddinCatalog.GetString ("Type");
			colEvent.Title = AddinCatalog.GetString ("Event");
			colFireType.Title = AddinCatalog.GetString ("Each Row");
			colPosition.Title = AddinCatalog.GetString ("Position");
			colActive.Title = AddinCatalog.GetString ("Active");
			colComment.Title = AddinCatalog.GetString ("Comment");
			
			colType.MinWidth = 120;
			colEvent.MinWidth = 120;
			
			CellRendererText nameRenderer = new CellRendererText ();
			CellRendererCombo typeRenderer = new CellRendererCombo ();
			CellRendererCombo eventRenderer = new CellRendererCombo ();
			CellRendererToggle fireTypeRenderer = new CellRendererToggle ();
			CellRendererText positionRenderer = new CellRendererText ();
			CellRendererToggle activeRenderer = new CellRendererToggle ();
			CellRendererText commentRenderer = new CellRendererText ();
			
			nameRenderer.Editable = true;
			nameRenderer.Edited += new EditedHandler (NameEdited);
			
			typeRenderer.Model = storeTypes;
			typeRenderer.TextColumn = 0;
			typeRenderer.Editable = true;
			typeRenderer.Edited += new EditedHandler (TypeEdited);
			
			eventRenderer.Model = storeEvents;
			eventRenderer.TextColumn = 0;
			eventRenderer.Editable = true;
			eventRenderer.Edited += new EditedHandler (EventEdited);
			
			fireTypeRenderer.Activatable = true;
			fireTypeRenderer.Toggled += new ToggledHandler (FireTypeToggled);
			
			positionRenderer.Editable = true;
			positionRenderer.Edited += new EditedHandler (PositionEdited);
			
			activeRenderer.Activatable = true;
			activeRenderer.Toggled += new ToggledHandler (ActiveToggled);
			
			commentRenderer.Editable = true;
			commentRenderer.Edited += new EditedHandler (CommentEdited);

			colName.PackStart (nameRenderer, true);
			colType.PackStart (typeRenderer, true);
			colEvent.PackStart (eventRenderer, true);
			colFireType.PackStart (fireTypeRenderer, true);
			colPosition.PackStart (positionRenderer, true);
			colActive.PackStart (activeRenderer, true);
			colComment.PackStart (commentRenderer, true);

			colName.AddAttribute (nameRenderer, "text", colNameIndex);
			colType.AddAttribute (typeRenderer, "text", colTypeIndex);
			colEvent.AddAttribute (eventRenderer, "text", colEventIndex);
			colFireType.AddAttribute (fireTypeRenderer, "active", colFireTypeIndex);
			colPosition.AddAttribute (positionRenderer, "text", colPositionIndex);
			colActive.AddAttribute (activeRenderer, "active", colActiveIndex);
			colComment.AddAttribute (commentRenderer, "text", colCommentIndex);
			
			listTriggers.AppendColumn (colName);
			listTriggers.AppendColumn (colType);
			listTriggers.AppendColumn (colEvent);
			listTriggers.AppendColumn (colFireType);
			listTriggers.AppendColumn (colPosition);
			listTriggers.AppendColumn (colActive);
			listTriggers.AppendColumn (colComment);
			
			ShowAll ();
		}
		private EncapsulateFieldDialog (MonoDevelop.Ide.Gui.Document editor, IType declaringType, IField field)
		{
			this.editor = editor;
			this.declaringType = declaringType;
			this.Build ();

			Title = GettextCatalog.GetString ("Encapsulate Fields");
			buttonOk.Sensitive = true;
			store = new ListStore (typeof (bool), typeof(string), typeof (string), typeof (string), typeof (bool), typeof (IField));
			visibilityStore = new ListStore (typeof (string));

			// Column #1
			CellRendererToggle cbRenderer = new CellRendererToggle ();
			cbRenderer.Activatable = true;
			cbRenderer.Toggled += OnSelectedToggled;
			TreeViewColumn cbCol = new TreeViewColumn ();
			cbCol.Title = "";
			cbCol.PackStart (cbRenderer, false);
			cbCol.AddAttribute (cbRenderer, "active", colCheckedIndex);
			treeview.AppendColumn (cbCol);

			// Column #2
			CellRendererText fieldRenderer = new CellRendererText ();
			fieldRenderer.Weight = (int) Pango.Weight.Bold;
			TreeViewColumn fieldCol = new TreeViewColumn ();
			fieldCol.Title = GettextCatalog.GetString ("Field");
			fieldCol.Expand = true;
			fieldCol.PackStart (fieldRenderer, true);
			fieldCol.AddAttribute (fieldRenderer, "text", colFieldNameIndex);
			treeview.AppendColumn (fieldCol);

			// Column #3
			CellRendererText propertyRenderer = new CellRendererText ();
			propertyRenderer.Editable = true;
			propertyRenderer.Edited += new EditedHandler (OnPropertyEdited);
			TreeViewColumn propertyCol = new TreeViewColumn ();
			propertyCol.Title = GettextCatalog.GetString ("Property");
			propertyCol.Expand = true;
			propertyCol.PackStart (propertyRenderer, true);
			propertyCol.AddAttribute (propertyRenderer, "text", colPropertyNameIndex);
			propertyCol.SetCellDataFunc (propertyRenderer, new TreeCellDataFunc (RenderPropertyName));
			treeview.AppendColumn (propertyCol);

			// Column #4
			CellRendererCombo visiComboRenderer = new CellRendererCombo ();
			visiComboRenderer.Model = visibilityStore;
			visiComboRenderer.Editable = true;
			visiComboRenderer.Edited += new EditedHandler (OnVisibilityEdited);
			visiComboRenderer.HasEntry = false;
			visiComboRenderer.TextColumn = 0;

			TreeViewColumn visiCol = new TreeViewColumn ();
			visiCol.Title = GettextCatalog.GetString ("Visibility");
			visiCol.PackStart (visiComboRenderer, false);
			visiCol.AddAttribute (visiComboRenderer, "text", colVisibilityIndex);
			treeview.AppendColumn (visiCol);

			// Column #5
			CellRendererToggle roRenderer = new CellRendererToggle ();
			roRenderer.Activatable = true;
			roRenderer.Xalign = 0.0f;
			roRenderer.Toggled += new ToggledHandler (OnReadOnlyToggled);
			TreeViewColumn roCol = new TreeViewColumn ();
			roCol.Title = GettextCatalog.GetString ("Read only");
			roCol.PackStart (roRenderer, false);
			roCol.AddAttribute (roRenderer, "active", colReadOnlyIndex);
			treeview.AppendColumn (roCol);

			visibilityStore.AppendValues ("Public");
			visibilityStore.AppendValues ("Private");
			visibilityStore.AppendValues ("Protected");
			visibilityStore.AppendValues ("Internal");

			treeview.Model = store;

			foreach (IField ifield in declaringType.Fields) {
				bool enabled = field != null && (field.Name == ifield.Name);
				string propertyName = GeneratePropertyName (ifield.Name);
				store.AppendValues (enabled, ifield.Name, propertyName,
				                    "Public", ifield.IsReadonly || ifield.IsLiteral, ifield);

				if (enabled)
					CheckAndUpdateConflictMessage (propertyName, false);
			}

			store.SetSortColumnId (colFieldNameIndex, SortType.Ascending);
			buttonSelectAll.Clicked += OnSelectAllClicked;
			buttonUnselectAll.Clicked += OnUnselectAllClicked;
			buttonOk.Clicked += OnOKClicked;
			buttonCancel.Clicked += OnCancelClicked;

			UpdateOKButton ();
		}
		public CustomPropertiesWidget (PListScheme scheme)
		{
			this.scheme = scheme = scheme ?? PListScheme.Empty;
			treeview = new PopupTreeView  (this);
			treeview.HeadersClickable = true;
			this.PackStart (treeview, true, true, 0);
			ShowAll ();
			
			var keyRenderer = new CellRendererCombo ();
			keyRenderer.Editable = true;
			keyRenderer.Model = keyStore;
			keyRenderer.Mode = CellRendererMode.Editable;
			keyRenderer.TextColumn = 0;
			keyRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter selIter;
				if (!treeStore.GetIterFromString (out selIter, args.Path)) 
					return;
				if (args.NewText == (string)treeStore.GetValue (selIter, 0))
					return;
				
				var obj = (PObject)treeStore.GetValue (selIter, 1);
				
				var dict = obj.Parent as PDictionary;
				if (dict == null)
					return;
				
				var key = scheme.Keys.FirstOrDefault (k => k.Identifier == args.NewText || k.Description == args.NewText);
				var newKey = key != null ? key.Identifier : args.NewText;
				
				dict.ChangeKey (obj, newKey, key == null || obj.TypeString == key.Type ? null : CreateNewObject (key.Type));
			};
			var col = new TreeViewColumn ();
			col.Resizable = true;
			col.Title = GettextCatalog.GetString ("Property");
			col.PackStart (keyRenderer, true);
			col.SetCellDataFunc (keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				string id = (string)tree_model.GetValue (iter, 0) ?? "";
				var obj = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Text = id;
					renderer.Editable = false;
					renderer.Sensitive = false;
					return;
				}
				
				var key = scheme.GetKey (id);
				renderer.Editable = !(obj.Parent is PArray);
				renderer.Sensitive = true;
				renderer.Text = key != null && ShowDescriptions ? GettextCatalog.GetString (key.Description) : id;
			});
			treeview.AppendColumn (col);
			
			var iconSize = IconSize.Menu;
			col = new TreeViewColumn { MinWidth = 25, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize };
			
			var removeRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-remove", IconSize.Menu));
			removeRenderer.Clicked += delegate {
				TreeIter iter;
				bool hasSelection = treeview.Selection.GetSelected (out iter);
				PObject obj = null;
				if (hasSelection) {
					obj = (PObject)treeStore.GetValue (iter, 1);
					obj.Remove ();
				}
			};
			col.PackEnd (removeRenderer, false);
			col.SetCellDataFunc (removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				removeRenderer.Visible = treeview.Selection.IterIsSelected (iter) && !AddKeyNode.Equals (treeStore.GetValue (iter, 0));
			});
			
			var addRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-add", IconSize.Menu));
			addRenderer.Clicked += delegate {
				Gtk.TreeIter iter = Gtk.TreeIter.Zero;
				if (!treeview.Selection.GetSelected (out iter))
					return;
				
				PObject obj = null;
				if (treeStore.IterParent (out iter, iter))
					obj = (PObject) treeStore.GetValue (iter, 1);
				obj = obj ?? nsDictionary;

				var newObj = new PString ("");
				if (obj is PArray) {
					var arr = (PArray) obj;
					arr.Add (newObj);
				} else if (obj is PDictionary) {
					string name = "newNode";
					var dict = (PDictionary) obj;
					while (dict.ContainsKey (name))
						name += "_";
					dict.Add (name ,newObj);
				} else {
					return;
				}
			};
			
			col.PackEnd (addRenderer, false);
			col.SetCellDataFunc (addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				addRenderer.Visible = treeview.Selection.IterIsSelected (iter) && AddKeyNode.Equals (treeStore.GetValue (iter, 0));
			});
			treeview.AppendColumn (col);
			
			treeview.RowExpanded += delegate(object o, RowExpandedArgs args) {
				var obj = (PObject)treeStore.GetValue (args.Iter, 1);
				expandedObjects.Add (obj);
			};
			treeview.RowCollapsed += delegate(object o, RowCollapsedArgs args) {
				var obj = (PObject)treeStore.GetValue (args.Iter, 1);
				expandedObjects.Remove (obj);
			};
			var comboRenderer = new CellRendererCombo ();
			
			var typeModel = new ListStore (typeof (string));
			typeModel.AppendValues ("Array");
			typeModel.AppendValues ("Dictionary");
			typeModel.AppendValues ("Boolean");
			typeModel.AppendValues ("Data");
			typeModel.AppendValues ("Date");
			typeModel.AppendValues ("Number");
			typeModel.AppendValues ("String");
			comboRenderer.Model = typeModel;
			comboRenderer.Mode = CellRendererMode.Editable;
			comboRenderer.HasEntry = false;
			comboRenderer.TextColumn = 0;
			comboRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter selIter;
				if (!treeStore.GetIterFromString (out selIter, args.Path)) 
					return;
				
				PObject oldObj = (PObject)treeStore.GetValue (selIter, 1);
				if (oldObj != null && oldObj.TypeString != args.NewText)
					oldObj.Replace (CreateNewObject (args.NewText));
			};
			
			treeview.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				string id = (string)tree_model.GetValue (iter, 0) ?? "";
				var key   = scheme.GetKey (id);
				var obj   = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Editable = false;
					renderer.Text = "";
					return; 
				}
				renderer.Editable = key == null;
				renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive);
				renderer.Text = obj.TypeString;
			});
			
			var propRenderer = new CellRendererCombo ();
			
			propRenderer.Model = valueStore;
			propRenderer.Mode = CellRendererMode.Editable;
			propRenderer.TextColumn = 0;
			propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
				valueStore.Clear ();
				if (Scheme == null)
					return;
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				var pObject = (PObject)treeStore.GetValue (iter, 1);
				if (pObject == null)
					return;
				var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null;
				if (key != null) {
					var descr = new List<string> (key.Values.Select (v => v.Description));
					descr.Sort ();
					foreach (var val in descr) {
						valueStore.AppendValues (val);
					}
				}
			};
			
			propRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				var pObject = (PObject)treeStore.GetValue (iter, 1);
				if (pObject == null)
					return;
				string newText = args.NewText;
				var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null;
				if (key != null) {
					foreach (var val in key.Values) {
						if (newText == val.Description) {
							newText = val.Identifier;
							break;
						}
					}
				}
				pObject.SetValue (newText);
			};
			
	/*		propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				PObject obj = (PObject)treeStore.GetValue (iter, 1);
				if (obj is PBoolean) {
					((PBoolean)obj).Value = !((PBoolean)obj).Value;
					propRenderer.StopEditing (false);
				}
			};*/
			
			
			treeview.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				var obj      = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Editable = false;
					renderer.Text = "";
					return;
				}
				renderer.Editable = !(obj is PArray || obj is PDictionary || obj is PData);
				obj.RenderValue (this, renderer);
			});
			treeview.EnableGridLines = TreeViewGridLines.Horizontal;
			treeview.Model = treeStore;
		}
    private void AddColumns(TreeView treeView)
    {
        {
            var column = new TreeViewColumn();
            var cell = new CellRendererText();
            cell.Editable = true;
            cell.Edited += this.TextStringEdited;
            column.Title = Column.TextString.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.TextString);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererText();
            cell.Editable = true;
            cell.Edited += this.TextDoubleEdited;
            column.Title = Column.TextDouble.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.TextDouble);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererText();
            column.Title = Column.TextBool.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.TextBool);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererToggle();
            cell.Toggled += this.ToggleCheckBoxToggled;
            cell.Active = true;
            cell.Activatable = true;
            column.Title = Column.ToggleCheckBox.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "active", (int)Column.ToggleCheckBox);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererToggle();
            cell.Toggled += this.ToggleRadioButtonToggled;
            cell.Active = true;
            cell.Activatable = true;
            cell.Radio = true;
            column.Title = Column.ToggleRadioButton.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "active", (int)Column.ToggleRadioButton);
            this.treeview1.AppendColumn(column);
        }

        {
            // Note: the text in this renderer has to be parseable as a floating point number
            var column = new TreeViewColumn();
            var cell = new CellRendererSpin();
            cell.Editable = true;
            cell.Edited += this.SpinTest1Edited;

            // Adjustment - Contains the range information for the cell.
            // Value: Must be non-null for the cell to be editable.
            cell.Adjustment = new Adjustment(0, 0, float.MaxValue, 1, 2, 0);

            // ClimbRate - Provides the acceleration rate for when the button is held down.
            // Value: Defaults to 0, must be greater than or equal to 0.
            cell.ClimbRate = 0;

            // Digits - Number of decimal places to display (seems to only work while editing the cell?!?).
            // Value: An integer between 0 and 20, default value is 0.
            cell.Digits = 3;

            column.Title = Column.Spin.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.Spin);
            this.treeview1.AppendColumn(column);
        }

        {
            ListStore model = new ListStore(typeof(string));

            model.AppendValues("Value1");
            model.AppendValues("Value2");
            model.AppendValues("Value3");

            var column = new TreeViewColumn();
            var cell = new CellRendererCombo();
            cell.Width = 75;
            cell.Editable = true;
            cell.Edited += this.ComboEdited;

            // bool. Whether to use an entry.
            // If true, the cell renderer will include an entry and allow to
            // enter values other than the ones in the popup list.
            cell.HasEntry = true;

            // TreeModel. Holds a tree model containing the possible values for the combo box.
            // Use the CellRendererCombo.TextColumn property to specify the column holding the values.
            cell.Model = model;

            // int. Specifies the model column which holds the possible values for the combo box.
            // Note: this refers to the model specified in the model property, not the model
            // backing the tree view to which this cell renderer is attached.
            cell.TextColumn = 0;

            column.Title = Column.Combo.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.Combo);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererAccel();
            cell.AccelMode = CellRendererAccelMode.Other;
            cell.Editable = true;
            cell.AccelEdited += new AccelEditedHandler(this.OnAccelEdited);
            cell.AccelCleared += new AccelClearedHandler(this.OnAccelCleared);
            column.Title = Column.Accel.ToString();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.Accel);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererProgress();
            column.Title = Column.Progress.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.ProgressText);
            column.AddAttribute(cell, "value", (int)Column.Progress);
            this.treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererText();
            column.Title = Column.PixbufStockLabel.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "text", (int)Column.PixbufStockLabel);
            treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererPixbuf();
            column.Title = Column.PixbufStockIcon.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "stock-id", (int)Column.PixbufStockIcon);
            treeview1.AppendColumn(column);
        }

        {
            var column = new TreeViewColumn();
            var cell = new CellRendererPixbuf();
            column.Title = Column.PixbufCustom.GetDescription();
            column.PackStart(cell, true);
            column.AddAttribute(cell, "pixbuf", (int)Column.PixbufCustom);
            treeview1.AppendColumn(column);
        }
    }
        /// <summary>
        /// Creates the input mapping column with combo box.
        /// TODO improve the input mapping combo box:
        /// 1. it doesn't set values until combo box loses focus within table view confirm change - Edited event is raised only then
        /// 2. there is no indication that the field can be modified - render combo box always, OR show some icon that it can be modified
        /// </summary>
        /// <returns>
        /// The input mapping column with combo box.
        /// </returns>
        /// <param name='inputStore'>
        /// Input store.
        /// </param>
        private TreeViewColumn CreateInputMappingColumnWithComboBox(NodeStore inputStore, string columntTitle)
        {
            Gtk.CellRendererCombo comboRenderer = new Gtk.CellRendererCombo();
            
            comboRenderer.HasEntry = false;
            comboRenderer.Mode = CellRendererMode.Editable;
            comboRenderer.TextColumn = 0;
            comboRenderer.Editable = true;

            ListStore comboBoxStore = new ListStore (typeof(string));
            comboRenderer.Model = comboBoxStore;

            //when user activates combo box, refresh combobox store with available input mapping per node
            comboRenderer.EditingStarted += delegate (object o, EditingStartedArgs args) 
            {
                comboBoxStore.Clear ();
                IOItemNode currentItem = (IOItemNode)inputStore.GetNode (new TreePath (args.Path));
                ExperimentNode currentNode = m_component.ExperimentNode;
                string currentType = currentItem.Type;
                InputMappings availableInputMappingsPerNode = new InputMappings (currentNode.Owner);
                if (currentNode != null && availableInputMappingsPerNode.ContainsMappingsForNode (currentNode)) {
                    foreach (string incomingOutput in availableInputMappingsPerNode [currentNode].Keys) {
                        if (string.Equals (currentType, availableInputMappingsPerNode [currentNode] [incomingOutput])) {
                            comboBoxStore.AppendValues (Mono.Unix.Catalog.GetString (incomingOutput));
                        }
                    }
                }
            };

            //when edition has been completed set current item node with proper mapping
            comboRenderer.Edited += delegate (object o, EditedArgs args) {
                IOItemNode n = (IOItemNode)inputStore.GetNode (new TreePath (args.Path));
                n.MappedTo = args.NewText;
                RefreshIOHighlightInExperiment(n.MappedTo);
            };

            //finally create the column with above combo renderer
            var mappedToColumn = new TreeViewColumn ();
            mappedToColumn.Title = columntTitle;
            mappedToColumn.PackStart (comboRenderer, true);

            //this method sets the text view to current mapping, when combo box is not active
            mappedToColumn.SetCellDataFunc (comboRenderer, delegate (TreeViewColumn tree_column, CellRenderer cell, ITreeNode node) {
                IOItemNode currentItem = (IOItemNode)node;
                comboRenderer.Text = currentItem.MappedTo;
            });

            return mappedToColumn;
        }
		public CSharpFormattingProfileDialog (CSharpFormattingPolicy profile)
		{
			// ReSharper disable once DoNotCallOverridableMethodsInConstructor
			this.Build ();
			this.profile = profile;
			this.Title = profile.IsBuiltIn ? GettextCatalog.GetString ("Show built-in profile") : GettextCatalog.GetString ("Edit Profile");
			
			notebookCategories.SwitchPage += delegate {
				TreeView treeView;
				switch (notebookCategories.Page) {
				case 0:
					treeView = treeviewIndentOptions;
					break;
				case 1:
					treeView = treeviewNewLines;
					break;
				case 2: // Blank lines
					treeView = treeviewSpacing;
					break;
				case 3:
					treeView = treeviewWrapping;
					break;
				default:
					return;
				}
				
				TreeModel model;
				TreeIter iter;
				if (treeView.Selection.GetSelected (out model, out iter))
					UpdateExample (model, iter);
			};
			notebookCategories.ShowTabs = false;
			comboboxCategories.AppendText (GettextCatalog.GetString ("Indentation"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("New Lines"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Spacing"));
//			comboboxCategories.AppendText (GettextCatalog.GetString ("Style"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Wrapping"));
			comboboxCategories.Changed += delegate {
				texteditor.Text = "";
				notebookCategories.Page = comboboxCategories.Active;
			};
			comboboxCategories.Active = 0;
			
			var options = DefaultSourceEditorOptions.Instance;
			texteditor.Options = DefaultSourceEditorOptions.PlainEditor;
			texteditor.IsReadOnly = true;
			texteditor.MimeType = CSharpFormatter.MimeType;
			scrolledwindow.Child = texteditor;
			ShowAll ();
			
			#region Indent options
			indentationOptions = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));
			
			var column = new TreeViewColumn ();
			// pixbuf column
			var pixbufCellRenderer = new CellRendererImage ();
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			var cellRendererText = new CellRendererText ();
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			 
			treeviewIndentOptions.Model = indentationOptions;
			treeviewIndentOptions.HeadersVisible = false;
			treeviewIndentOptions.Selection.Changed += TreeSelectionChanged;
			treeviewIndentOptions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			var cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = ComboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;

			cellRendererCombo.Edited += new ComboboxEditedHandler (this, indentationOptions).ComboboxEdited;
			
			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			var cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewIndentOptions, indentationOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			treeviewIndentOptions.AppendColumn (column);


			AddOption (indentationOptions, "IndentBlock", GettextCatalog.GetString ("Indent block contents"), "namespace Test { class AClass { void Method () { int x; int y; } } }");
			AddOption (indentationOptions, "IndentBraces", GettextCatalog.GetString ("Indent open and close braces"), "class AClass { int aField; void AMethod () {}}");
			AddOption (indentationOptions, "IndentSwitchSection", GettextCatalog.GetString ("Indent case contents"), "class AClass { void Method (int x) { switch (x) { case 1: break; } } }");
			AddOption (indentationOptions, "IndentSwitchCaseSection", GettextCatalog.GetString ("Indent case labels"), "class AClass { void Method (int x) { switch (x) { case 1: break; } } }");
			AddOption (indentationOptions, "LabelPositioning", GettextCatalog.GetString ("Label indentation"), "enum AEnum { A, B, C }");
			treeviewIndentOptions.ExpandAll ();
			#endregion
			
			#region New line options
			newLineOptions = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));
			
			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			cellRendererText = new CellRendererText ();
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			
			treeviewNewLines.Model = newLineOptions;
			treeviewNewLines.HeadersVisible = false;
			treeviewNewLines.Selection.Changed += TreeSelectionChanged;
			treeviewNewLines.AppendColumn (column);
			
			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = ComboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, newLineOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewNewLines, newLineOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewNewLines.AppendColumn (column);

			var category = AddOption (newLineOptions, null, GettextCatalog.GetString ("New line options for braces"), null);
			AddOption (newLineOptions, category, "NewLinesForBracesInTypes", GettextCatalog.GetString ("Place open brace on new line for types"), @"class Example
{
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInMethods", GettextCatalog.GetString ("Place open brace on new line for methods"), @"void Example()
{
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInProperties", GettextCatalog.GetString ("Place open brace on new line for properties"), @"int Example { 
	get  { 
		return 1;
	}
	set {
		// nothing
	}
}
"
);

			AddOption (newLineOptions, category, "NewLinesForBracesInAccessors", GettextCatalog.GetString ("Place open brace on new line for property accessors"), @"int Example { 
	get  { 
		return 1;
	}
	set {
		// nothing
	}
}
"
);


			AddOption (newLineOptions, category, "NewLinesForBracesInAnonymousMethods", GettextCatalog.GetString ("Place open brace on new line for anonymous methods"), @"void Example()
{
	var del = new delegate (int i, int j) {
	};
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInControlBlocks", GettextCatalog.GetString ("Place open brace on new line for control blocks"), @"void Example()
{
	if (true)
	{
	}
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInAnonymousTypes", GettextCatalog.GetString ("Place open brace on new line for anonymous types"), @"void Example()
{
	var c = new
	{
		A = 1,
		B = 2
	};
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInObjectCollectionArrayInitializers", GettextCatalog.GetString ("Place open brace on new line for object initializers"), @"void Example()
{
	new MyObject
	{
		A = 1,
		B = 2 
	};
}");
			AddOption (newLineOptions, category, "NewLinesForBracesInLambdaExpressionBody", GettextCatalog.GetString ("Place open brace on new line for lambda expression"), @"void Example()
{
	Action act = () =>
	{
	};
}");

			category = AddOption (newLineOptions, null, GettextCatalog.GetString ("New line options for keywords"), null);
			AddOption (newLineOptions, category, "NewLineForElse", GettextCatalog.GetString ("Place \"else\" on new line"), @"void Example()
{
	if (true) {
		// ...
	} else {
		// ...
	}
}");
			AddOption (newLineOptions, category, "NewLineForCatch", GettextCatalog.GetString ("Place \"catch\" on new line"), @"void Example()
{
	try {
	} catch {
	} finally {
	}
}");
			AddOption (newLineOptions, category, "NewLineForFinally", GettextCatalog.GetString ("Place \"finally\" on new line"), @"void Example()
{
	try {
	} catch {
	} finally {
	}
}");

			category = AddOption (newLineOptions, null, GettextCatalog.GetString ("New line options for expressions"), null);
			AddOption (newLineOptions, category, "NewLineForMembersInObjectInit", GettextCatalog.GetString ("Place members in object initializers on new line"), @"void Example()
{
	new MyObject {
		A = 1,
		B = 2
	};
}");
			AddOption (newLineOptions, category, "NewLineForMembersInAnonymousTypes", GettextCatalog.GetString ("Place members in anonymous types on new line"), @"void Example()
{
	var c = new
	{
		A = 1,
		B = 2
	};
}");
			AddOption (newLineOptions, category, "NewLineForClausesInQuery", GettextCatalog.GetString ("Place query expression clauses on new line"), @"void Example()
{
	from o in col select o.Foo;
}");
			treeviewNewLines.ExpandAll ();
			#endregion
			
			#region Spacing options
			spacingOptions = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);

			// text column
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);

			treeviewSpacing.Model = spacingOptions;
			treeviewSpacing.HeadersVisible = false;
			treeviewSpacing.Selection.Changed += TreeSelectionChanged;
			treeviewSpacing.AppendColumn (column);

			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = ComboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, spacingOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);

			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewSpacing, spacingOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);

			treeviewSpacing.AppendColumn (column);

			category = AddOption (spacingOptions, null, GettextCatalog.GetString ("Set spacing for method declarations"), null);
			AddOption (spacingOptions, category, "SpacingAfterMethodDeclarationName", GettextCatalog.GetString ("Insert space between method name and its opening parenthesis"), 
				@"void Example()
{
}");

			AddOption (spacingOptions, category, "SpaceWithinMethodDeclarationParenthesis", GettextCatalog.GetString ("Insert space withing argument list parentheses"), 
				@"void Example(int i, int j)
{
}");
			AddOption (spacingOptions, category, "SpaceBetweenEmptyMethodDeclarationParentheses", GettextCatalog.GetString ("Insert space within empty argument list parentheses"), @"void Example()
{
}");

			category = AddOption (spacingOptions, null, GettextCatalog.GetString ("Set spacing for method calls"), null);
			AddOption (spacingOptions, category, "SpaceAfterMethodCallName", GettextCatalog.GetString ("Insert space between method name and its opening parenthesis"), @"void Example()
{
	Test();
}");
			AddOption (spacingOptions, category, "SpaceWithinMethodCallParentheses", GettextCatalog.GetString ("Insert space withing argument list parentheses"), @"void Example()
{
	Test(1, 2);
}");
			AddOption (spacingOptions, category, "SpaceBetweenEmptyMethodCallParentheses", GettextCatalog.GetString ("Insert space within empty argument list parentheses"), @"void Example()
{
	Test();
}");

			category = AddOption (spacingOptions, null, GettextCatalog.GetString ("Set other spacing options"), null);
			AddOption (spacingOptions, category, "SpaceAfterControlFlowStatementKeyword", GettextCatalog.GetString ("Insert space after keywords in control flow statements"), @"void Example()
{
	if (condition)
	{
	}
}");

			AddOption (spacingOptions, category, "SpaceWithinExpressionParentheses", GettextCatalog.GetString ("Insert space within parentheses of expressions"), @"void Example()
{
	i = (5 + 3) * 2;
}");
			AddOption (spacingOptions, category, "SpaceWithinCastParentheses", GettextCatalog.GetString ("Insert space within parentheses of type casts"), @"void Example()
{
	test = (ITest)o;
}");
			AddOption (spacingOptions, category, "SpaceWithinOtherParentheses", GettextCatalog.GetString ("Insert space within parentheses of control flow statements"), @"void Example()
{
	if (condition)
	{
	}
}");

			AddOption (spacingOptions, category, "SpaceAfterCast", GettextCatalog.GetString ("Insert space after casts"), @"void Example()
{
	test = (ITest)o;
}");
			AddOption (spacingOptions, category, "SpacesIgnoreAroundVariableDeclaration", GettextCatalog.GetString ("Ignore spaces in declaration statements"), @"void Example()
{
	int x=5;
}");

			category = AddOption (spacingOptions, null, GettextCatalog.GetString ("Set spacing for brackets"), null);
			AddOption (spacingOptions, category, "SpaceBeforeOpenSquareBracket", GettextCatalog.GetString ("Insert space before open square bracket"), @"void Example()
{
	i[5] = 3;
}");
			AddOption (spacingOptions, category, "SpaceBetweenEmptySquareBrackets", GettextCatalog.GetString ("Insert space within empty square brackets"), @"void Example()
{
	new int[] {1, 2};
}");
			AddOption (spacingOptions, category, "SpaceWithinSquareBrackets", GettextCatalog.GetString ("Insert space within square brackets"), @"void Example()
{
	i[5] = 3;
}");

			category = AddOption (spacingOptions, null, GettextCatalog.GetString ("Set spacing for brackets"), null);
			AddOption (spacingOptions, category, "SpaceAfterColonInBaseTypeDeclaration", GettextCatalog.GetString ("Insert space after colon for base or interface in type declaration"), @"class Foo : Bar
{
}");
			AddOption (spacingOptions, category, "SpaceAfterComma", GettextCatalog.GetString ("Insert space after comma"), @"void Example()
{
	for (int i =0; i < 10, i >5;i++)
	{
	}
}");
			AddOption (spacingOptions, category, "SpaceAfterDot", GettextCatalog.GetString ("Insert space after dot"), @"void Example()
{
	Foo.Bar.Test();
}");
			AddOption (spacingOptions, category, "SpaceAfterSemicolonsInForStatement", GettextCatalog.GetString ("Insert space after semicolon in \"for\" statement"), @"void Example()
{
	for (int i = 0; i< 10; i++)
	{
	}
}");
			AddOption (spacingOptions, category, "SpaceBeforeColonInBaseTypeDeclaration", GettextCatalog.GetString ("Insert space before colon for base or interface in type declaration"), @"class Foo : Bar
{
}");
			AddOption (spacingOptions, category, "SpaceBeforeComma", GettextCatalog.GetString ("Insert space before comma"), @"void Example()
{
	for (int i =0; i < 10, i >5;i++)
	{
	}
}");
			AddOption (spacingOptions, category, "SpaceBeforeDot", GettextCatalog.GetString ("Insert space before dot"), @"void Example()
{
	Foo.Bar.Test();
}");
			AddOption (spacingOptions, category, "SpaceBeforeSemicolonsInForStatement", GettextCatalog.GetString ("Insert space before semicolon in \"for\" statement"), @"void Example()
{
	for (int i = 0; i< 10; i++)
	{
	}
}");

			AddOption (spacingOptions, category, "SpacingAroundBinaryOperator", GettextCatalog.GetString ("Set spacing for operators"), @"void Example()
{
	i = (5 + 3) * 2;
}");

			treeviewSpacing.ExpandAll ();
			#endregion

			#region Style options
			styleOptions = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);

			// text column
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);


			treeviewStyle.Model = styleOptions;
			treeviewStyle.HeadersVisible = false;
			treeviewStyle.Selection.Changed += TreeSelectionChanged;
			treeviewStyle.AppendColumn (column);

			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = ComboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, styleOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);

			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewSpacing, styleOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);

			treeviewStyle.AppendColumn (column);

			AddOption (styleOptions, category, null, GettextCatalog.GetString ("Qualify member access with 'this'"), null);
			AddOption (styleOptions, category, null, GettextCatalog.GetString ("Use 'var' when generating locals"), null);

			treeviewStyle.ExpandAll ();
			#endregion

			#region Wrapping options
			wrappingOptions = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);

			// text column
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);

			treeviewWrapping.Model = wrappingOptions;
			treeviewWrapping.HeadersVisible = false;
			treeviewWrapping.Selection.Changed += TreeSelectionChanged;
			treeviewWrapping.AppendColumn (column);

			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = ComboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, wrappingOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);

			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewSpacing, wrappingOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);

			treeviewWrapping.AppendColumn (column);

			AddOption (wrappingOptions, "WrappingPreserveSingleLine", GettextCatalog.GetString ("Leave block on single line"), "");
			AddOption (wrappingOptions, "WrappingKeepStatementsOnSingleLine", GettextCatalog.GetString ("Leave statements and member declarations on the same line"), "");

			treeviewWrapping.ExpandAll ();
			#endregion
		}
		public CustomPropertiesWidget (PListScheme scheme)
		{
			Scheme = scheme ?? PListScheme.Empty;
			CurrentTree = new Dictionary<PObject, PListScheme.SchemaItem> ();
			treeview = new PopupTreeView  (this) { DoubleBuffered = true };
			treeview.HeadersClickable = true;
			
			RefreshKeyStore ();
			PackStart (treeview, true, true, 0);
			FindOrAddNewEntry (TreeIter.Zero);
			ShowAll ();

			var keyRenderer = new CellRendererCombo ();
			keyRenderer.Editable = true;
			keyRenderer.Model = keyStore;
			keyRenderer.Mode = CellRendererMode.Editable;
			keyRenderer.TextColumn = 0;
			keyRenderer.EditingStarted += KeyRendererEditingStarted;
			keyRenderer.Edited += KeyRendererEditingFinished;
			var col = new TreeViewColumn ();
			col.Resizable = true;
			col.Title = GettextCatalog.GetString ("Property");
			col.PackStart (keyRenderer, true);
			col.SetCellDataFunc (keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				string id = (string)tree_model.GetValue (iter, 0) ?? "";
				var obj = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Text = id;
					renderer.Editable = false;
					renderer.Sensitive = false;
					return;
				}
				
				var key = (PListScheme.SchemaItem) tree_model.GetValue (iter, 2);
				var parentPArray = obj.Parent is PArray;
				renderer.Editable = !parentPArray;
				renderer.Sensitive = !parentPArray;
				if (parentPArray)
					renderer.Text = "";
				else
					renderer.Text = key != null && ShowDescriptions ? key.Description : id;
			});
			treeview.AppendColumn (col);
			
			col = new TreeViewColumn { MinWidth = 25, Resizable = false, Sizing = Gtk.TreeViewColumnSizing.Fixed };
				
			var removeRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-remove", IconSize.Menu));
			removeRenderer.Clicked += RemoveElement;
			col.PackEnd (removeRenderer, false);
			col.SetCellDataFunc (removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				removeRenderer.Visible = treeview.Selection.IterIsSelected (iter) && !AddKeyNode.Equals (treeStore.GetValue (iter, 0));
			});
			
			var addRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-add", IconSize.Menu));
			addRenderer.Clicked += AddElement;
			col.PackEnd (addRenderer, false);
			col.SetCellDataFunc (addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				addRenderer.Visible = treeview.Selection.IterIsSelected (iter) && AddKeyNode.Equals (treeStore.GetValue (iter, 0));
			});
			treeview.AppendColumn (col);
			
			treeview.RowActivated += delegate(object o, RowActivatedArgs args) {
				TreeIter iter;
				if (treeStore.GetIter (out iter, args.Path) && AddKeyNode.Equals (treeStore.GetValue (iter, 0)))
					AddElement (o, EventArgs.Empty);
			};

			var comboRenderer = new CellRendererCombo ();
			
			var typeModel = new ListStore (typeof (string));
			typeModel.AppendValues (PArray.Type);
			typeModel.AppendValues (PDictionary.Type);
			typeModel.AppendValues (PBoolean.Type);
			typeModel.AppendValues (PData.Type);
			typeModel.AppendValues (PData.Type);
			typeModel.AppendValues (PNumber.Type);
			typeModel.AppendValues (PString.Type);
			comboRenderer.Model = typeModel;
			comboRenderer.Mode = CellRendererMode.Editable;
			comboRenderer.HasEntry = false;
			comboRenderer.TextColumn = 0;
			comboRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter selIter;
				if (!treeStore.GetIterFromString (out selIter, args.Path)) 
					return;
				
				PObject oldObj = (PObject)treeStore.GetValue (selIter, 1);
				if (oldObj != null && oldObj.TypeString != args.NewText)
					oldObj.Replace (PObject.Create (args.NewText));
			};
			
			treeview.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				var value = (string) tree_model.GetValue (iter, 0);
				var obj   = (PObject)tree_model.GetValue (iter, 1);
				var key   = (PListScheme.SchemaItem)tree_model.GetValue (iter, 2);
				renderer.Editable = key == null && !AddKeyNode.Equals (value);
				renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive);
				renderer.Text = obj == null ? "" : obj.TypeString;
			});
			
			var propRenderer = new CellRendererCombo ();
			
			propRenderer.Model = valueStore;
			propRenderer.Mode = CellRendererMode.Editable;
			propRenderer.TextColumn = 0;
			propRenderer.EditingStarted += PropRendererEditingStarted;
			propRenderer.Edited += PropRendererEditingFinished;

			treeview.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				var obj      = (PObject)tree_model.GetValue (iter, 1);

				renderer.Sensitive = obj != null && !(obj is PDictionary || obj is PArray || obj is PData);
				renderer.Editable = renderer.Sensitive;
				if (!renderer.Sensitive) {
					renderer.Text = "";
					return;
				}
				
				if (ShowDescriptions) {
					var identifier = (string) tree_model.GetValue (iter, 0);
					var values = PListScheme.AvailableValues (obj, CurrentTree);
					var item = values == null ? null : values.FirstOrDefault (v => v.Identifier == identifier);
					if (item != null && obj is IPValueObject) {
						// Ensure that we only display the Description if the items value matches the description/identifier.
						// For example when setting the Document Type Name we wish to display whatever identifer the user types
						// in and not the literal string 'Document Type Name'. However for somegthing like UISupportedDeviceOrientations
						// we can safely display the description 'iPhone' or 'iPad' and not hide important information.
						var actualValue = ((IPValueObject) obj).Value;
						if (actualValue  != null && (actualValue.ToString () == item.Description || actualValue.ToString () == item.Identifier)) {
							renderer.Text = item.Description ?? item.Identifier;
							return;
						}
					}
				}

				switch (obj.TypeString) {
				case PDictionary.Type:
					renderer.Text = string.Format (GettextCatalog.GetPluralString ("({0} item)", "({0} items)", ((PDictionary)obj).Count), ((PDictionary)obj).Count);
					break;
				case PArray.Type:
					renderer.Text = string.Format (GettextCatalog.GetPluralString ("({0} item)", "({0} items)", ((PArray)obj).Count, ((PArray)obj).Count));
					break;
				case PBoolean.Type:
					renderer.Text = ((PBoolean)obj).Value ? GettextCatalog.GetString ("Yes") : GettextCatalog.GetString ("No");
					break;
				case PData.Type:
					renderer.Text = string.Format ("byte[{0}]", ((PData)obj).Value.Length);
					break;
				default:
					if (obj is IPValueObject) {
						renderer.Text = (((IPValueObject)obj).Value ?? "").ToString ();
					} else {
						renderer.Sensitive = false;
						renderer.Text = GettextCatalog.GetString ("Could not render {0}.", obj.GetType ().Name);
					}
					break;
				}
			});
			treeview.EnableGridLines = TreeViewGridLines.Horizontal;
			treeview.Model = treeStore;
		}
Beispiel #20
0
        /// <summary>
        /// Populate the grid from the DataSource.
        /// </summary>
        private void PopulateGrid()
        {
            WaitCursor = true;
            ClearGridColumns();
            fixedcolview.Visible = false;
            colLookup.Clear();
            // Begin by creating a new ListStore with the appropriate number of
            // columns. Use the string column type for everything.
            int nCols = DataSource != null ? this.DataSource.Columns.Count : 0;
            Type[] colTypes = new Type[nCols];
            for (int i = 0; i < nCols; i++)
                colTypes[i] = typeof(string);
            gridmodel = new ListStore(colTypes);
            gridview.ModifyBase(StateType.Active, fixedcolview.Style.Base(StateType.Selected));
            gridview.ModifyText(StateType.Active, fixedcolview.Style.Text(StateType.Selected));
            fixedcolview.ModifyBase(StateType.Active, gridview.Style.Base(StateType.Selected));
            fixedcolview.ModifyText(StateType.Active, gridview.Style.Text(StateType.Selected));

            image1.Visible = false;
            // Now set up the grid columns
            for (int i = 0; i < nCols; i++)
            {
                /// Design plan: include renderers for text, toggles and combos, but hide all but one of them
                CellRendererText textRender = new Gtk.CellRendererText();
                CellRendererToggle toggleRender = new Gtk.CellRendererToggle();
                toggleRender.Visible = false;
                toggleRender.Toggled += ToggleRender_Toggled;
                CellRendererCombo comboRender = new Gtk.CellRendererCombo();
                comboRender.Edited += ComboRender_Edited;
                comboRender.Xalign = 1.0f;
                comboRender.Visible = false;

                colLookup.Add(textRender, i);

                textRender.FixedHeightFromFont = 1; // 1 line high
                textRender.Editable = !isReadOnly;
                textRender.EditingStarted += OnCellBeginEdit;
                textRender.Edited += OnCellValueChanged;
                textRender.Xalign = i == 0 ? 0.0f : 1.0f; // For right alignment of text cell contents; left align the first column

                TreeViewColumn column = new TreeViewColumn();
                column.Title = this.DataSource.Columns[i].ColumnName;
                column.PackStart(textRender, true);     // 0
                column.PackStart(toggleRender, true);   // 1
                column.PackStart(comboRender, true);    // 2
                column.Sizing = TreeViewColumnSizing.Autosize;
                //column.FixedWidth = 100;
                column.Resizable = true;
                column.SetCellDataFunc(textRender, OnSetCellData);
                column.Alignment = 0.5f; // For centered alignment of the column header
                gridview.AppendColumn(column);

                // Gtk Treeview doesn't support "frozen" columns, so we fake it by creating a second, identical, TreeView to display
                // the columns we want frozen
                // For now, these frozen columns will be treated as read-only text
                TreeViewColumn fixedColumn = new TreeViewColumn(this.DataSource.Columns[i].ColumnName, textRender, "text", i);
                fixedColumn.Sizing = TreeViewColumnSizing.Autosize;
                fixedColumn.Resizable = true;
                fixedColumn.SetCellDataFunc(textRender, OnSetCellData);
                fixedColumn.Alignment = 0.5f; // For centered alignment of the column header
                fixedColumn.Visible = false;
                fixedcolview.AppendColumn(fixedColumn);
            }
            // Add an empty column at the end; auto-sizing will give this any "leftover" space
            TreeViewColumn fillColumn = new TreeViewColumn();
            gridview.AppendColumn(fillColumn);
            fillColumn.Sizing = TreeViewColumnSizing.Autosize;

            // Now let's apply center-justification to all the column headers, just for the heck of it
            for (int i = 0; i < nCols; i++)
            {
                Label label = GetColumnHeaderLabel(i);
                label.Justify = Justification.Center;
                label.Style.FontDescription.Weight = Pango.Weight.Bold;

                label = GetColumnHeaderLabel(i, fixedcolview);
                label.Justify = Justification.Center;
                label.Style.FontDescription.Weight = Pango.Weight.Bold;
            }

            int nRows = DataSource != null ? this.DataSource.Rows.Count : 0;

            gridview.Model = null;
            fixedcolview.Model = null;
            for (int row = 0; row < nRows; row++)
            {
                // We could store data into the grid model, but we don't.
                // Instead, we retrieve the data from our datastore when the OnSetCellData function is called
                gridmodel.Append();
            }
            gridview.Model = gridmodel;

            gridview.Show();
            while (Gtk.Application.EventsPending())
                Gtk.Application.RunIteration();
            WaitCursor = false;
        }
    private void populate_log_file_columns()
    {
        /**
         * COLUMNS
         * =======
         * device_sensor_code
         * device_sensor_description
         * device_sensor_value_type <- combobox
         * device_sensor_value <- Surely NOT?
         * nvDeviceFileDesctiption
         */

        mnu_device.Popdown ();

        TreeStore ls_nvDeviceFileDescription = new TreeStore (typeof(string), typeof(string), typeof(string));
        ListStore ls_dev_sensor_codes = new ListStore (typeof(string));
        ListStore ls_dev_sensor_value_types = new ListStore (typeof(string));

        if (ar_file_description == null)
            ar_file_description = new ArrayList ();

            if (nvDeviceFileDescr.Columns.Length < 1) {
                Gtk.TreeViewColumn col_sensor_code = new Gtk.TreeViewColumn ();
                col_sensor_code.Title = "Sensor Code";
                col_sensor_code.Sizing = TreeViewColumnSizing.Autosize;

                Gtk.TreeViewColumn col_sensor_descr = new Gtk.TreeViewColumn ();
                col_sensor_descr.Title = "Sensor Descr";
                col_sensor_descr.Sizing = TreeViewColumnSizing.Autosize;

                Gtk.TreeViewColumn col_sensor_value_type = new Gtk.TreeViewColumn ();
                col_sensor_value_type.Title = "Value Type";
                col_sensor_value_type.Sizing = TreeViewColumnSizing.Autosize;

                CellRendererCombo dev_sensor_codes = new CellRendererCombo ();
                dev_sensor_codes.Editable = true;
                dev_sensor_codes.Edited += delegate(object o, EditedArgs args) {
                    int i = int.Parse (args.Path);
                    c_file_description_entry = (CDeviceFileDescription)ar_file_description [i];
                    c_file_description_entry.DeviceCode = args.NewText;

                    TreeIter iter;
                    TreeStore store = (TreeStore)nvDeviceFileDescr.Model;
                    store.GetIterFromString (out iter, args.Path);
                    store.SetValue (iter, 0, c_file_description_entry.DeviceCode);

                };

                CellRendererCombo dev_sensor_value_types = new CellRendererCombo ();
                dev_sensor_value_types.Editable = true;
                dev_sensor_value_types.Edited += delegate(object o, EditedArgs args) {
                    int i = int.Parse (args.Path);
                    c_file_description_entry = (CDeviceFileDescription)ar_file_description [i];
                    c_file_description_entry.DeviceCodeType = args.NewText;

                    TreeIter iter;
                    TreeStore store = (TreeStore)nvDeviceFileDescr.Model;
                    store.GetIterFromString (out iter, args.Path);
                    store.SetValue (iter, 2, c_file_description_entry.DeviceCodeType);
                };

                CellRendererText dev_sensor_descr = new CellRendererText ();
                dev_sensor_descr.Editable = true;
                dev_sensor_descr.Edited += delegate(object o, EditedArgs args) {
                    int i = int.Parse (args.Path);
                    c_file_description_entry = (CDeviceFileDescription)ar_file_description [i];
                    c_file_description_entry.DeviceCodeDescription = args.NewText;

                    TreeIter iter;
                    TreeStore store = (TreeStore)nvDeviceFileDescr.Model;
                    store.GetIterFromString (out iter, args.Path);
                    store.SetValue (iter, 1, c_file_description_entry.DeviceCodeDescription);
                };

                dev_sensor_codes.Model = ls_dev_sensor_codes;
                dev_sensor_codes.TextColumn = 0;

                dev_sensor_value_types.Model = ls_dev_sensor_value_types;
                dev_sensor_value_types.TextColumn = 0;

                col_sensor_code.PackStart (dev_sensor_codes, true);
                col_sensor_code.AddAttribute (dev_sensor_codes, "text", 0);

                col_sensor_descr.PackStart (dev_sensor_descr, true);
                col_sensor_descr.AddAttribute (dev_sensor_descr, "text", 1);

                col_sensor_value_type.PackStart (dev_sensor_value_types, true);
                col_sensor_value_type.AddAttribute (dev_sensor_value_types, "text", 2);

                nvDeviceFileDescr.AppendColumn (col_sensor_code);
                nvDeviceFileDescr.AppendColumn (col_sensor_descr);
            //nvDeviceFileDescr.AppendColumn (col_sensor_value_type);
            }

        nvDeviceFileDescr.DoubleBuffered = true;

        string[] _codes = csql.CSQL_GetDeviceSensorCodes ();
        string[] _types = csql.CSQL_GetDeviceSensorValueTypes ();

        // Do codes.
        if (_codes != null) {
            for (int i = 0; i < _codes.Length; i++) {
                ls_dev_sensor_codes.AppendValues (_codes [i]);
            }
        }

        //Do Types
        if (_types != null) {
            for (int i = 0; i < _types.Length; i++) {
                ls_dev_sensor_value_types.AppendValues (_types [i]);
            }
        }

        //Do any description entries, if available.
        if (ar_file_description.Count > 0) {

            for (int i = 0; i < ar_file_description.Count; i++) {

                CDeviceFileDescription file_descr =
                    (CDeviceFileDescription)ar_file_description [i];

                ls_nvDeviceFileDescription.AppendValues (file_descr.DeviceCode,
                    file_descr.DeviceCodeDescription, file_descr.DeviceCodeType);

            }

        }

        nvDeviceFileDescr.Model = ls_nvDeviceFileDescription;
    }
Beispiel #22
0
        public TaskTreeView(Gtk.TreeModel model)
            : base()
        {
                        #if GTK_2_12
            // set up the timing for the tooltips
            this.Settings.SetLongProperty("gtk-tooltip-browse-mode-timeout", 0, "Tasque:TaskTreeView");
            this.Settings.SetLongProperty("gtk-tooltip-browse-timeout", 750, "Tasque:TaskTreeView");
            this.Settings.SetLongProperty("gtk-tooltip-timeout", 750, "Tasque:TaskTreeView");

            ConnectEvents();
                        #endif

            // TODO: Modify the behavior of the TreeView so that it doesn't show
            // the highlighted row.  Then, also tie in with the mouse hovering
            // so that as you hover the mouse around, it will automatically
            // select the row that the mouse is hovered over.  By doing this,
            // we should be able to not require the user to click on a task
            // to select it and THEN have to click on the column item they want
            // to modify.

            filterCategory = null;

            modelFilter             = new Gtk.TreeModelFilter(model, null);
            modelFilter.VisibleFunc = FilterFunc;

            modelFilter.RowInserted += OnRowInsertedHandler;
            modelFilter.RowDeleted  += OnRowDeletedHandler;

            //Model = modelFilter

            Selection.Mode = Gtk.SelectionMode.Single;
            RulesHint      = false;
            HeadersVisible = false;
            HoverSelection = true;

            // TODO: Figure out how to turn off selection highlight

            Gtk.CellRenderer renderer;

            //
            // Checkbox Column
            //
            Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
            // Title for Completed/Checkbox Column
            column.Title     = Catalog.GetString("Completed");
            column.Sizing    = Gtk.TreeViewColumnSizing.Autosize;
            column.Resizable = false;
            column.Clickable = true;

            renderer = new Gtk.CellRendererToggle();
            (renderer as Gtk.CellRendererToggle).Toggled += OnTaskToggled;
            column.PackStart(renderer, false);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(TaskToggleCellDataFunc));
            AppendColumn(column);

            //
            // Priority Column
            //
            column = new Gtk.TreeViewColumn();
            // Title for Priority Column
            column.Title = Catalog.GetString("Priority");
            //column.Sizing = Gtk.TreeViewColumnSizing.Autosize;
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.Alignment  = 0.5f;
            column.FixedWidth = 30;
            column.Resizable  = false;
            column.Clickable  = true;

            renderer = new Gtk.CellRendererCombo();
            (renderer as Gtk.CellRendererCombo).Editable = true;
            (renderer as Gtk.CellRendererCombo).HasEntry = false;
            SetCellRendererCallbacks((CellRendererCombo)renderer, OnTaskPriorityEdited);
            Gtk.ListStore priorityStore = new Gtk.ListStore(typeof(string));
            priorityStore.AppendValues(Catalog.GetString("1"));               // High
            priorityStore.AppendValues(Catalog.GetString("2"));               // Medium
            priorityStore.AppendValues(Catalog.GetString("3"));               // Low
            priorityStore.AppendValues(Catalog.GetString("-"));               // None
            (renderer as Gtk.CellRendererCombo).Model      = priorityStore;
            (renderer as Gtk.CellRendererCombo).TextColumn = 0;
            renderer.Xalign = 0.5f;
            column.PackStart(renderer, true);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(TaskPriorityCellDataFunc));
            AppendColumn(column);

            //
            // Task Name Column
            //
            column = new Gtk.TreeViewColumn();
            // Title for Task Name Column
            column.Title = Catalog.GetString("Task Name");
//			column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.Sizing    = Gtk.TreeViewColumnSizing.Autosize;
            column.Expand    = true;
            column.Resizable = true;

            // TODO: Add in code to determine how wide we should make the name
            // column.
            // TODO: Add in code to readjust the size of the name column if the
            // user resizes the Task Window.
            //column.FixedWidth = 250;

            renderer = new Gtk.CellRendererText();
            column.PackStart(renderer, true);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(TaskNameTextCellDataFunc));
            ((Gtk.CellRendererText)renderer).Editable = true;
            SetCellRendererCallbacks((CellRendererText)renderer, OnTaskNameEdited);

            AppendColumn(column);


            //
            // Due Date Column
            //

            //  2/11 - Today
            //  2/12 - Tomorrow
            //  2/13 - Wed
            //  2/14 - Thu
            //  2/15 - Fri
            //  2/16 - Sat
            //  2/17 - Sun
            // --------------
            //  2/18 - In 1 Week
            // --------------
            //  No Date
            // ---------------
            //  Choose Date...

            column = new Gtk.TreeViewColumn();
            // Title for Due Date Column
            column.Title      = Catalog.GetString("Due Date");
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.Alignment  = 0f;
            column.FixedWidth = 90;
            column.Resizable  = false;
            column.Clickable  = true;

            renderer = new Gtk.CellRendererCombo();
            (renderer as Gtk.CellRendererCombo).Editable = true;
            (renderer as Gtk.CellRendererCombo).HasEntry = false;
            SetCellRendererCallbacks((CellRendererCombo)renderer, OnDateEdited);
            Gtk.ListStore dueDateStore = new Gtk.ListStore(typeof(string));
            DateTime      today        = DateTime.Now;
            dueDateStore.AppendValues(
                today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today"));
            dueDateStore.AppendValues(
                today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow"));
            dueDateStore.AppendValues(
                today.AddDays(2).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(3).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(4).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(5).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(6).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week"));
            dueDateStore.AppendValues(Catalog.GetString("No Date"));
            dueDateStore.AppendValues(Catalog.GetString("Choose Date..."));
            (renderer as Gtk.CellRendererCombo).Model      = dueDateStore;
            (renderer as Gtk.CellRendererCombo).TextColumn = 0;
            renderer.Xalign = 0.0f;
            column.PackStart(renderer, true);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(DueDateCellDataFunc));
            AppendColumn(column);



            //
            // Notes Column
            //
            column = new Gtk.TreeViewColumn();
            // Title for Notes Column
            column.Title      = Catalog.GetString("Notes");
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = 20;
            column.Resizable  = false;

            renderer = new Gtk.CellRendererPixbuf();
            column.PackStart(renderer, false);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(TaskNotesCellDataFunc));

            AppendColumn(column);

            //
            // Timer Column
            //
            column = new Gtk.TreeViewColumn();
            // Title for Timer Column
            column.Title      = Catalog.GetString("Timer");
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = 20;
            column.Resizable  = false;

            renderer        = new Gtk.CellRendererPixbuf();
            renderer.Xalign = 0.5f;
            column.PackStart(renderer, false);
            column.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(TaskTimerCellDataFunc));

            AppendColumn(column);
        }
Beispiel #23
0
        void LoadColumns()
        {
            bool pref_val;

            Gtk.CellRenderer renderer;

            ///
            /// Completion Status
            ///
            Gtk.TreeViewColumn status = new Gtk.TreeViewColumn();
            status.Title         = string.Empty;
            status.Sizing        = Gtk.TreeViewColumnSizing.Autosize;
            status.Resizable     = false;
            status.Clickable     = true;
            status.Clicked      += OnCompletionColumnClicked;
            status.Reorderable   = true;
            status.SortIndicator = true;

            renderer = new Gtk.CellRendererToggle();
            (renderer as Gtk.CellRendererToggle).Toggled += OnTaskToggled;
            status.PackStart(renderer, false);
            status.SetCellDataFunc(renderer,
                                   new Gtk.TreeCellDataFunc(ToggleCellDataFunc));
            tree.AppendColumn(status);

            ///
            /// Summary
            ///
            summary_column               = new Gtk.TreeViewColumn();
            summary_column.Title         = Catalog.GetString("Summary");
            summary_column.MinWidth      = 200;
            summary_column.FixedWidth    = 200;
            summary_column.Sizing        = Gtk.TreeViewColumnSizing.Autosize;
            summary_column.Resizable     = true;
            summary_column.Clickable     = true;
            summary_column.Clicked      += OnSummaryColumnClicked;
            summary_column.Reorderable   = true;
            summary_column.SortIndicator = true;

            renderer = new Gtk.CellRendererText();
            (renderer as CellRendererText).Editable  = true;
            (renderer as CellRendererText).Ellipsize = Pango.EllipsizeMode.End;
            (renderer as CellRendererText).Edited   += OnTaskSummaryEdited;
            renderer.Xalign = 0.0f;
            summary_column.PackStart(renderer, true);
            summary_column.SetCellDataFunc(renderer,
                                           new Gtk.TreeCellDataFunc(SummaryCellDataFunc));
            tree.AppendColumn(summary_column);

            // Due Date Column
            pref_val = GetPref(TaskListWindow.ShowDueDateColumnPreference);
            if (pref_val == true)
            {
                // Show the Due Date Column
                due_date_column               = new Gtk.TreeViewColumn();
                due_date_column.Title         = Catalog.GetString("Due Date");
                due_date_column.Sizing        = Gtk.TreeViewColumnSizing.Autosize;
                due_date_column.Resizable     = false;
                due_date_column.Clickable     = true;
                due_date_column.Clicked      += OnDueDateColumnClicked;
                due_date_column.Reorderable   = true;
                due_date_column.SortIndicator = true;

                renderer = new Gtk.Extras.CellRendererDate();
                (renderer as Gtk.Extras.CellRendererDate).Editable = true;
                (renderer as Gtk.Extras.CellRendererDate).Edited  += OnDueDateEdited;
                (renderer as Gtk.Extras.CellRendererDate).ShowTime = false;
                renderer.Xalign = 0.0f;
                due_date_column.PackStart(renderer, true);
                due_date_column.SetCellDataFunc(renderer,
                                                new Gtk.TreeCellDataFunc(DueDateCellDataFunc));
                tree.AppendColumn(due_date_column);
            }

            // Priority Column
            pref_val = GetPref(TaskListWindow.ShowPriorityColumnPreference);
            if (pref_val == true)
            {
                // Show the Priority Column
                priority_column               = new Gtk.TreeViewColumn();
                priority_column.Title         = Catalog.GetString("Priority");
                priority_column.Sizing        = Gtk.TreeViewColumnSizing.Autosize;
                priority_column.Resizable     = false;
                priority_column.Clickable     = true;
                priority_column.Clicked      += OnPriorityColumnClicked;
                priority_column.Reorderable   = true;
                priority_column.SortIndicator = true;

                renderer = new Gtk.CellRendererCombo();
                (renderer as Gtk.CellRendererCombo).Editable = true;
                (renderer as Gtk.CellRendererCombo).HasEntry = false;
                (renderer as Gtk.CellRendererCombo).Edited  += OnTaskPriorityEdited;
                Gtk.ListStore priority_store = new Gtk.ListStore(typeof(string));
                priority_store.AppendValues(Catalog.GetString("None"));
                priority_store.AppendValues(Catalog.GetString("Low"));
                priority_store.AppendValues(Catalog.GetString("Normal"));
                priority_store.AppendValues(Catalog.GetString("High"));
                (renderer as Gtk.CellRendererCombo).Model      = priority_store;
                (renderer as Gtk.CellRendererCombo).TextColumn = 0;
                renderer.Xalign = 0.0f;
                priority_column.PackStart(renderer, true);
                priority_column.SetCellDataFunc(renderer,
                                                new Gtk.TreeCellDataFunc(PriorityCellDataFunc));
                tree.AppendColumn(priority_column);
            }
        }
Beispiel #24
0
		private void InitColumns ()
		{
			var toggle = new CellRendererToggle ();
			toggle.Toggled += HandleRepoToggled;

			tv.AppendColumn ("", toggle, "active", COLINDEX_TOGGLE);

			var nameColumn = new TreeViewColumn { Title = "Name" };
			var nameCell = new CellRendererText ();
			nameColumn.PackStart (nameCell, true);
			nameColumn.SetCellDataFunc (nameCell, new TreeCellDataFunc (RenderEntryName));

			var localColumn = new TreeViewColumn { Title = "Local" };
			var localCell = new CellRendererText ();
			localColumn.PackStart (localCell, true);
			localColumn.SetCellDataFunc (localCell, new TreeCellDataFunc (RenderEntryLocal));

			var remoteColumn = new TreeViewColumn { Title = "Remote" };
			var remoteCell = new CellRendererText ();
			remoteColumn.PackStart (remoteCell, true);
			remoteColumn.SetCellDataFunc (remoteCell, new TreeCellDataFunc (RenderEntryRemote));

			var actionColumn = new TreeViewColumn { Title = "Action" };
			var actionCell = new CellRendererCombo ();
			actionColumn.PackStart (actionCell, true);
			actionColumn.AddAttribute (actionCell, "text", COLINDEX_ENTRY);
			actionColumn.SetCellDataFunc (actionCell, new TreeCellDataFunc (RenderEntryAction));

			tv.AppendColumn (nameColumn);
			tv.AppendColumn (localColumn);
			tv.AppendColumn (remoteColumn);
			tv.AppendColumn (actionColumn);
		}
Beispiel #25
0
        public Contract()
        {
            this.Build ();

            ComboWorks.ComboFillReference(comboOrg, "organizations", ComboWorks.ListMode.WithNo);
            ComboWorks.ComboFillReference(comboPlaceT,"place_types", ComboWorks.ListMode.WithNo);

            ComboBox ServiceCombo = new ComboBox();
            ComboWorks.ComboFillReference(ServiceCombo,"services", ComboWorks.ListMode.OnlyItems);
            ServiceNameList = ServiceCombo.Model;
            ServiceCombo.Destroy ();

            ComboBox CashCombo = new ComboBox();
            string sqlSelect = "SELECT name, id, color FROM cash";
            ComboWorks.ComboFillUniversal(CashCombo, sqlSelect, "{0}", null, 1, ComboWorks.ListMode.OnlyItems, true);
            CashNameList = CashCombo.Model;
            CashCombo.Destroy ();

            MainClass.FillServiceListStore(out ServiceRefListStore);

            //Создаем таблицу "Услуги"
            ServiceListStore = new Gtk.ListStore (typeof(int), 	// 0 - idServiceColumn
                                                  typeof(string),	// 1 - Наименование
                                                  typeof(int),		// 2 - idКасса
                                                  typeof(string),	// 3 - Касса
                                                  typeof(string), 	// 5 - Ед. изм.
                                                  typeof(decimal), 	// 6 - Количество
                                                  typeof(decimal),	// 7 - Цена
                                                  typeof(decimal),	// 8 - Сумма
                                                  typeof(int), 	// 9 - id
                                                  typeof(bool),	// 10 - Есть ли расчет по метражу
                                                  typeof(decimal),	// 11 - Минимальный платеж.
                                                  typeof(string) 	// 12 - Цвет строки
            );

            Gtk.TreeViewColumn ServiceColumn = new Gtk.TreeViewColumn ();
            ServiceColumn.Title = "Наименование";
            ServiceColumn.MinWidth = 180;
            Gtk.CellRendererCombo CellService = new CellRendererCombo();
            CellService.TextColumn = 0;
            CellService.Editable = true;
            CellService.Model = ServiceNameList;
            CellService.HasEntry = false;
            CellService.Edited += OnServiceComboEdited;
            ServiceColumn.PackStart (CellService, true);

            Gtk.TreeViewColumn CashColumn = new Gtk.TreeViewColumn ();
            CashColumn.Title = "Касса";
            CashColumn.MinWidth = 130;
            Gtk.CellRendererCombo CellCash = new CellRendererCombo();
            CellCash.TextColumn = 0;
            CellCash.Editable = true;
            CellCash.Model = CashNameList;
            CellCash.HasEntry = false;
            CellCash.Edited += OnCashComboEdited;
            CashColumn.PackStart (CellCash, true);

            Gtk.TreeViewColumn CountColumn = new Gtk.TreeViewColumn ();
            CountColumn.Title = "Количество";
            Gtk.CellRendererText CellCount = new CellRendererText();
            CellCount.Editable = true;
            CellCount.Edited += OnServiceCountEdited;
            CountColumn.PackStart (CellCount, true);
            Gtk.CellRendererText CellUnits = new CellRendererText ();
            CountColumn.PackStart (CellUnits, false);

            Gtk.CellRendererText CellPrice = new CellRendererText();
            CellPrice.Editable = true;
            CellPrice.Edited += OnServicePriceEdited;

            Gtk.CellRendererText CellMinSum = new CellRendererText();
            CellMinSum.Editable = true;
            CellMinSum.Edited += OnServiceMinSumEdited;

            treeviewServices.AppendColumn (ServiceColumn);
            ServiceColumn.AddAttribute (CellService, "text", (int)ServiceCol.service);
            treeviewServices.AppendColumn (CashColumn);
            CashColumn.AddAttribute (CellCash,"text", (int)ServiceCol.cash);
            treeviewServices.AppendColumn (CountColumn);
            CountColumn.AddAttribute (CellUnits,"text", (int)ServiceCol.units);
            CountColumn.SetCellDataFunc (CellCount, RenderCountColumn);
            treeviewServices.AppendColumn ("Цена", CellPrice, RenderPriceColumn);
            treeviewServices.AppendColumn ("Сумма", new Gtk.CellRendererText (), RenderSumColumn);
            treeviewServices.AppendColumn ("Мин. платеж", CellMinSum, RenderMinSumColumn);

            foreach(TreeViewColumn column in treeviewServices.Columns)
            {
                foreach(CellRenderer render in column.CellRenderers)
                {
                    column.AddAttribute (render, "background", (int)ServiceCol.row_color);
                }
            }

            treeviewServices.Columns[3].MinWidth = 90;

            treeviewServices.Model = ServiceListStore;
            treeviewServices.ShowAll();

            OnTreeviewServicesCursorChanged(null, null);
        }
        void InitCellRenderers()
        {
            cellRendererText = new CellRendererText ();

            cellRendererTextEditable = new CellRendererText ();
            cellRendererTextEditable.Editable = true;
            cellRendererTextEditable.Edited += HandleCellRendererTextEditableEdited;

            cellRendererToggle = new CellRendererToggle ();
            cellRendererToggle.Toggled += CellRendererToggled;

            cellRendererPixbuf = new CellRendererPixbuf ();

            cellRendererCombo = new CellRendererCombo ();
            cellRendererCombo.HasEntry = false;
            cellRendererCombo.Editable = true;
            cellRendererCombo.Model = tableTypesModel;
            cellRendererCombo.TextColumn = 0;
            cellRendererCombo.Edited += HandleCellRendererComboEdited;
        }
		public CSharpFormattingProfileDialog (CSharpFormattingPolicy profile)
		{
			this.Build ();
			this.profile = profile;
			this.Title = profile.IsBuiltIn ? GettextCatalog.GetString ("Show built-in profile") : GettextCatalog.GetString ("Edit Profile");
			
			notebookCategories.SwitchPage += delegate {
				TreeView treeView;
				switch (notebookCategories.Page) {
				case 0:
					treeView = treeviewIndentOptions;
					break;
				case 1:
					treeView = treeviewBracePositions;
					break;
				case 2: // Blank lines
					UpdateExample (blankLineExample);
					return;
				case 3: // white spaces
					treeView = treeviewInsertWhiteSpaceCategory;
					return;
				case 4:
					treeView = treeviewNewLines;
					break;
				default:
					return;
				}
				
				var model = treeView.Model;
				Gtk.TreeIter iter;
				if (treeView.Selection.GetSelected (out model, out iter))
					UpdateExample (model, iter);
			};
			notebookCategories.ShowTabs = false;
			comboboxCategories.AppendText (GettextCatalog.GetString ("Indentation"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Braces"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Blank lines"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("White Space"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("New Lines"));
			comboboxCategories.Changed += delegate(object sender, EventArgs e) {
				texteditor.Text = "";
				notebookCategories.Page = comboboxCategories.Active;
			};
			comboboxCategories.Active = 0;
			
			var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance;
			texteditor.Options.FontName = options.FontName;
			texteditor.Options.ColorScheme = options.ColorScheme;
			texteditor.Options.ShowFoldMargin = false;
			texteditor.Options.ShowIconMargin = false;
			texteditor.Options.ShowLineNumberMargin = false;
			texteditor.Options.ShowInvalidLines = false;
			texteditor.Document.ReadOnly = true;
			texteditor.Document.MimeType = CSharpFormatter.MimeType;
			scrolledwindow.Child = texteditor;
			ShowAll ();
			
			#region Indent options
			indentOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
			
			TreeViewColumn column = new TreeViewColumn ();
			// pixbuf column
			var pixbufCellRenderer = new CellRendererPixbuf ();
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			CellRendererText cellRendererText = new CellRendererText ();
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			 
			treeviewIndentOptions.Model = indentOptions;
			treeviewIndentOptions.HeadersVisible = false;
			treeviewIndentOptions.Selection.Changed += TreeSelectionChanged;
			treeviewIndentOptions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			CellRendererCombo cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = comboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;

			cellRendererCombo.Edited +=  new ComboboxEditedHandler (this, indentOptions).ComboboxEdited;
			
			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			CellRendererToggle cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewIndentOptions, indentOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewIndentOptions.AppendColumn (column);
			var category = AddOption (indentOptions, null, GettextCatalog.GetString ("Declarations"), null);
			AddOption (indentOptions, category, "IndentNamespaceBody", GettextCatalog.GetString ("within namespaces"), "namespace Test { class AClass {} }");
			
			AddOption (indentOptions, category, "IndentClassBody", GettextCatalog.GetString ("within classes"), "class AClass { int aField; void AMethod () {}}");
			AddOption (indentOptions, category, "IndentInterfaceBody", GettextCatalog.GetString ("within interfaces"), "interface IAInterfaces { int AProperty {get;set;} void AMethod ();}");
			AddOption (indentOptions, category, "IndentStructBody", GettextCatalog.GetString ("within structs"), "struct AStruct { int aField; void AMethod () {}}");
			AddOption (indentOptions, category, "IndentEnumBody", GettextCatalog.GetString ("within enums"), "enum AEnum { A, B, C }");
			
			AddOption (indentOptions, category, "IndentMethodBody", GettextCatalog.GetString ("within methods"), methodSpaceExample);
			AddOption (indentOptions, category, "IndentPropertyBody", GettextCatalog.GetString ("within properties"), propertyExample);
			AddOption (indentOptions, category, "IndentEventBody", GettextCatalog.GetString ("within events"), eventExample);
			
			category = AddOption (indentOptions, null, GettextCatalog.GetString ("Statements"), null);
			AddOption (indentOptions, category, "IndentBlocks", GettextCatalog.GetString ("within blocks"), spaceExample);
			AddOption (indentOptions, category, "IndentSwitchBody", GettextCatalog.GetString ("Indent 'switch' body"), spaceExample);
			AddOption (indentOptions, category, "IndentCaseBody", GettextCatalog.GetString ("Indent 'case' body"), spaceExample);
			AddOption (indentOptions, category, "IndentBreakStatements", GettextCatalog.GetString ("Indent 'break' statements"), spaceExample);
			
			AddOption (indentOptions, category, "AlignEmbeddedIfStatements", GettextCatalog.GetString ("Align embedded 'if' statements"), "class AClass { void AMethod () { if (a) if (b) { int c; } } } ");
			AddOption (indentOptions, category, "AlignEmbeddedUsingStatements", GettextCatalog.GetString ("Align embedded 'using' statements"), "class AClass { void AMethod () {using (IDisposable a = null) using (IDisposable b = null) { int c; } } }");
			treeviewIndentOptions.ExpandAll ();
			#endregion
			
			#region Brace options
			bacePositionOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
			
			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			cellRendererText = new CellRendererText ();
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			
			treeviewBracePositions.Model = bacePositionOptions;
			treeviewBracePositions.HeadersVisible = false;
			treeviewBracePositions.Selection.Changed += TreeSelectionChanged;
			treeviewBracePositions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = comboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, bacePositionOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewBracePositions, bacePositionOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewBracePositions.AppendColumn (column);
			
			AddOption (bacePositionOptions, "NamespaceBraceStyle", GettextCatalog.GetString ("Namespace declaration"), "namespace TestNameSpace {}");
			
			AddOption (bacePositionOptions, "ClassBraceStyle", GettextCatalog.GetString ("Class declaration"), "class ClassDeclaration {}");
			AddOption (bacePositionOptions, "InterfaceBraceStyle", GettextCatalog.GetString ("Interface declaration"), "interface InterfaceDeclaraction {}");
			AddOption (bacePositionOptions, "StructBraceStyle", GettextCatalog.GetString ("Struct declaration"), "struct StructDeclaration {}");
			AddOption (bacePositionOptions, "EnumBraceStyle", GettextCatalog.GetString ("Enum declaration"), "enum EnumDeclaration { A, B, C}");
			
			AddOption (bacePositionOptions, "MethodBraceStyle", GettextCatalog.GetString ("Method declaration"), "class ClassDeclaration { void MyMethod () {} }");
			AddOption (bacePositionOptions, "AnonymousMethodBraceStyle", GettextCatalog.GetString ("Anonymous methods"), "class ClassDeclaration { void MyMethod () { MyEvent += delegate (object sender, EventArgs e) { if (true) Console.WriteLine (\"Hello World\"); }; } }");
			AddOption (bacePositionOptions, "ConstructorBraceStyle", GettextCatalog.GetString ("Constructor declaration"), "class ClassDeclaration { public ClassDeclaration () {} }");
			AddOption (bacePositionOptions, "DestructorBraceStyle", GettextCatalog.GetString ("Destructor declaration"), "class ClassDeclaration { ~ClassDeclaration () {} }");
			
			AddOption (bacePositionOptions, "StatementBraceStyle", GettextCatalog.GetString ("Statements"), spaceExample);
			
			category = AddOption (bacePositionOptions, "PropertyBraceStyle", GettextCatalog.GetString ("Property declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "PropertyGetBraceStyle", GettextCatalog.GetString ("Get declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "AllowPropertyGetBlockInline", GettextCatalog.GetString ("Allow one line get"), propertyExample);
			AddOption (bacePositionOptions, category, "PropertySetBraceStyle", GettextCatalog.GetString ("Set declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "AllowPropertySetBlockInline", GettextCatalog.GetString ("Allow one line set"), propertyExample);
			
			
			category = AddOption (bacePositionOptions, "EventBraceStyle", GettextCatalog.GetString ("Event declaration"), eventExample);
			AddOption (bacePositionOptions, category, "EventAddBraceStyle", GettextCatalog.GetString ("Add declaration"), eventExample);
			AddOption (bacePositionOptions, category, "AllowEventAddBlockInline", GettextCatalog.GetString ("Allow one line add"), eventExample);
			AddOption (bacePositionOptions, category, "EventRemoveBraceStyle", GettextCatalog.GetString ("Remove declaration"), eventExample);
			AddOption (bacePositionOptions, category, "AllowEventRemoveBlockInline", GettextCatalog.GetString ("Allow one line remove"), eventExample);
			
			category = AddOption (bacePositionOptions, null, GettextCatalog.GetString ("Brace forcement"), null);
			AddOption (bacePositionOptions, category, "IfElseBraceForcement", GettextCatalog.GetString ("'if...else' statement"), @"class ClassDeclaration { 
	public void Test ()
		{
			if (true) {
				Console.WriteLine (""Hello World!"");
			}
			if (true)
				Console.WriteLine (""Hello World!"");
		}
	}");
			AddOption (bacePositionOptions, category, "ForBraceForcement", GettextCatalog.GetString ("'for' statement"), @"class ClassDeclaration { 
		public void Test ()
		{
			for (int i = 0; i < 10; i++) {
				Console.WriteLine (""Hello World "" + i);
			}
			for (int i = 0; i < 10; i++)
				Console.WriteLine (""Hello World "" + i);
		}
	}");
			AddOption (bacePositionOptions, category, "WhileBraceForcement", GettextCatalog.GetString ("'while' statement"), @"class ClassDeclaration { 
		public void Test ()
		{
			int i = 0;
			while (i++ < 10) {
				Console.WriteLine (""Hello World "" + i);
			}
			while (i++ < 20)
				Console.WriteLine (""Hello World "" + i);
		}
	}");
			AddOption (bacePositionOptions, category, "UsingBraceForcement", GettextCatalog.GetString ("'using' statement"), simpleUsingStatement);
			AddOption (bacePositionOptions, category, "FixedBraceForcement", GettextCatalog.GetString ("'fixed' statement"), simpleFixedStatement);
			treeviewBracePositions.ExpandAll ();
			#endregion
			
			#region New line options
			newLineOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
			
			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			
			treeviewNewLines.Model = newLineOptions;
			treeviewNewLines.HeadersVisible = false;
			treeviewNewLines.Selection.Changed += TreeSelectionChanged;
			treeviewNewLines.AppendColumn (column);
			
			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = comboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, newLineOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewNewLines, newLineOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewNewLines.AppendColumn (column);
			
			AddOption (newLineOptions, "PlaceElseOnNewLine", GettextCatalog.GetString ("Place 'else' on new line"), simpleIf);
			AddOption (newLineOptions, "PlaceElseIfOnNewLine", GettextCatalog.GetString ("Place 'else if' on new line"), simpleIf);
			AddOption (newLineOptions, "PlaceCatchOnNewLine", GettextCatalog.GetString ("Place 'catch' on new line"), simpleCatch);
			AddOption (newLineOptions, "PlaceFinallyOnNewLine", GettextCatalog.GetString ("Place 'finally' on new line"), simpleCatch);
			AddOption (newLineOptions, "PlaceWhileOnNewLine", GettextCatalog.GetString ("Place 'while' on new line"), simpleDoWhile);
			AddOption (newLineOptions, "PlaceArrayInitializersOnNewLine", GettextCatalog.GetString ("Place array initializers on new line"), simpleArrayInitializer);
			treeviewNewLines.ExpandAll ();
			#endregion
			
			#region White space options
			whiteSpaceOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
			
			
			column = new TreeViewColumn ();
			// pixbuf column
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			
			treeviewInsertWhiteSpaceCategory.Model = whiteSpaceOptions;
			treeviewInsertWhiteSpaceCategory.HeadersVisible = false;
			treeviewInsertWhiteSpaceCategory.Selection.Changed += TreeSelectionChanged;
			treeviewInsertWhiteSpaceCategory.AppendColumn (column);
			
			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = comboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;
			cellRendererCombo.Edited += new ComboboxEditedHandler (this, whiteSpaceOptions).ComboboxEdited;

			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewInsertWhiteSpaceCategory, whiteSpaceOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewInsertWhiteSpaceCategory.AppendColumn (column);
			
			string example = @"class Example {
		void Test ()
		{
		}
		
		void Test (int a, int b, int c)
		{
		}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Declarations"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinMethodDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterMethodDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			example = @"class Example {
		int a, b, c;
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Fields"), example);
			AddOption (whiteSpaceOptions, category, "BeforeFieldDeclarationComma", GettextCatalog.GetString ("before comma in multiple field declarations"), example);
			AddOption (whiteSpaceOptions, category, "AfterFieldDeclarationComma", GettextCatalog.GetString ("after comma in multiple field declarations"), example);
			
			example = @"class Example {
	Example () 
	{
	}

	Example (int a, int b, int c) 
	{
	}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Constructors"), example);
			AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinConstructorDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyConstructorDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterConstructorDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			example = @"class Example {
	public int this[int a, int b] {
		get {
			return a + b;
		}
	}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Indexer"), example);
			AddOption (whiteSpaceOptions, category, "BeforeIndexerDeclarationBracket", GettextCatalog.GetString ("before opening bracket"), example);
			AddOption (whiteSpaceOptions, category, "WithinIndexerDeclarationBracket", GettextCatalog.GetString ("within brackets"), example);
			AddOption (whiteSpaceOptions, category, "BeforeIndexerDeclarationParameterComma", GettextCatalog.GetString ("before comma in brackets"), example);
			AddOption (whiteSpaceOptions, category, "AfterIndexerDeclarationParameterComma", GettextCatalog.GetString ("after comma in brackets"), example);
			
			example = @"delegate void FooBar (int a, int b, int c);
delegate void BarFoo ();
";
			
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Delegates"), example);
			AddOption (whiteSpaceOptions, category, "BeforeDelegateDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinDelegateDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyDelegateDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeDelegateDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterDelegateDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			var upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Statements"), null);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'if'"), simpleIf);
			AddOption (whiteSpaceOptions, category, "IfParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleIf);
			AddOption (whiteSpaceOptions, category, "WithinIfParentheses", GettextCatalog.GetString ("within parenthesis"), simpleIf);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'while'"), simpleWhile);
			AddOption (whiteSpaceOptions, category, "WhileParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleWhile);
			AddOption (whiteSpaceOptions, category, "WithinWhileParentheses", GettextCatalog.GetString ("within parenthesis"), simpleWhile);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'for'"), simpleFor);
			AddOption (whiteSpaceOptions, category, "ForParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleFor);
			AddOption (whiteSpaceOptions, category, "WithinForParentheses", GettextCatalog.GetString ("within parenthesis"), simpleFor);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeForSemicolon", GettextCatalog.GetString ("before semicolon"), simpleFor);
			AddOption (whiteSpaceOptions, category, "SpacesAfterForSemicolon", GettextCatalog.GetString ("after semicolon"), simpleFor);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'foreach'"), simpleForeach);
			AddOption (whiteSpaceOptions, category, "ForeachParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleForeach);
			AddOption (whiteSpaceOptions, category, "WithinForEachParentheses", GettextCatalog.GetString ("within parenthesis"), simpleForeach);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'catch'"), simpleCatch);
			AddOption (whiteSpaceOptions, category, "CatchParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleCatch);
			AddOption (whiteSpaceOptions, category, "WithinCatchParentheses", GettextCatalog.GetString ("within parenthesis"), simpleCatch);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'switch'"), switchExample);
			AddOption (whiteSpaceOptions, category, "SwitchParentheses", GettextCatalog.GetString ("before opening parenthesis"), switchExample);
			AddOption (whiteSpaceOptions, category, "WithinSwitchParentheses", GettextCatalog.GetString ("within parenthesis"), switchExample);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'lock'"), simpleLock);
			AddOption (whiteSpaceOptions, category, "LockParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleLock);
			AddOption (whiteSpaceOptions, category, "WithinLockParentheses", GettextCatalog.GetString ("within parenthesis"), simpleLock);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'using'"), simpleUsingStatement);
			AddOption (whiteSpaceOptions, category, "UsingParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleUsingStatement);
			AddOption (whiteSpaceOptions, category, "WithinUsingParentheses", GettextCatalog.GetString ("within parenthesis"), simpleUsingStatement);
			
			
			upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Expressions"), null);
			
			example = @"class Example {
		void Test ()
		{
			Console.WriteLine();
			Console.WriteLine(""{0} {1}!"", ""Hello"", ""World"");
		}
}";
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Method invocations"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodCallParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinMethodCallParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodCallParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodCallParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterMethodCallParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Object creation"), example);
			example = @"partial class Example {
		void Test ()
		{
			var anExample = new Example (1, 2, 3);
			var emptyExample = new Example ();
		}
}";
			AddOption (whiteSpaceOptions, category, "NewParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinNewParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyNewParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeNewParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterNewParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			
			example = @"class Example {
		void Test ()
		{
			a[1,2] = b[3];
		}
}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Element access"), example);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeBrackets", GettextCatalog.GetString ("before opening bracket"), example);
			AddOption (whiteSpaceOptions, category, "SpacesWithinBrackets", GettextCatalog.GetString ("within brackets"), example);
			AddOption (whiteSpaceOptions, category, "BeforeBracketComma", GettextCatalog.GetString ("before comma in brackets"), example);
			AddOption (whiteSpaceOptions, category, "AfterBracketComma", GettextCatalog.GetString ("after comma in brackets"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Parentheses"), operatorExample);
			AddOption (whiteSpaceOptions, category, "WithinParentheses", GettextCatalog.GetString ("within parenthesis"), operatorExample);
			
			example = @"class ClassDeclaration { 
		public void Test (object o)
		{
			int i = (int)o;
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Type cast"), example);
			AddOption (whiteSpaceOptions, category, "WithinCastParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "SpacesAfterTypecast", GettextCatalog.GetString ("after type cast"), example);
			
			example = @"class ClassDeclaration { 
		public void Test ()
		{
			int i = sizeof (ClassDeclaration);
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'sizeof'"), example);
			AddOption (whiteSpaceOptions, category, "BeforeSizeOfParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinSizeOfParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			
			example = @"class ClassDeclaration { 
		public void Test ()
		{
			Type t = typeof (ClassDeclaration);
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'typeof'"), example);
			AddOption (whiteSpaceOptions, category, "BeforeTypeOfParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinTypeOfParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Around Operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundAssignmentParentheses", GettextCatalog.GetString ("Assignment (=, +=, -=, ...)"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundLogicalOperatorParentheses", GettextCatalog.GetString ("Logical (&&, ||) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundEqualityOperatorParentheses", GettextCatalog.GetString ("Equality (==, !=) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundRelationalOperatorParentheses", GettextCatalog.GetString ("Relational (<, >, <=, >=) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundBitwiseOperatorParentheses", GettextCatalog.GetString ("Bitwise &, |, ^, ~() operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundAdditiveOperatorParentheses", GettextCatalog.GetString ("Additive (+, -) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundMultiplicativeOperatorParentheses", GettextCatalog.GetString ("Multiplicative (*, /, %) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundShiftOperatorParentheses", GettextCatalog.GetString ("Shift (<<, >>) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundNullCoalescingOperator", GettextCatalog.GetString ("Null coalescing (??) operator"), operatorExample);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Conditional Operator (?:)"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeConditionSpace", GettextCatalog.GetString ("before '?'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterConditionSpace", GettextCatalog.GetString ("after '?'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeSeparatorSpace", GettextCatalog.GetString ("before ':'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterSeparatorSpace", GettextCatalog.GetString ("after ':'"), condOpExample);
			
			example = @"class ClassDeclaration { 
		string[][] field;
		int[] test;
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Array Declarations"), example);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeArrayDeclarationBrackets", GettextCatalog.GetString ("before opening bracket"), example);
			/*
			whiteSpaceOptions= new ListStore (typeof (Option), typeof (bool), typeof (bool)); 
			column = new TreeViewColumn ();
			// text column
			column.PackStart (cellRendererText, true);
			column.SetCellDataFunc (cellRendererText, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererText)cell).Text = ((Option)model.GetValue (iter, 0)).DisplayName;
			});
			treeviewInsertWhiteSpaceOptions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			cellRendererCombo = new CellRendererCombo ();
			cellRendererCombo.Ypad = 1;
			cellRendererCombo.Mode = CellRendererMode.Editable;
			cellRendererCombo.TextColumn = 1;
			cellRendererCombo.Model = comboBoxStore;
			cellRendererCombo.HasEntry = false;
			cellRendererCombo.Editable = !profile.IsBuiltIn;

			cellRendererCombo.Edited += delegate(object o, EditedArgs args) {
				TreeIter iter;
				var model = whiteSpaceOptions;
				if (model.GetIterFromString (out iter, args.Path)) {
					var option = (Option)model.GetValue (iter, 0);
					PropertyInfo info = GetPropertyByName (option.PropertyName);
					if (info == null)
						return;
					var value = Enum.Parse (info.PropertyType, args.NewText);
					info.SetValue (profile, value, null);
					UpdateExample (texteditor.Document.Text);
				}
			};
			
			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", 2);
			column.SetCellDataFunc (cellRendererCombo,  delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererCombo)cell).Text = GetValue (((Option)model.GetValue (iter, 0)).PropertyName).ToString ();
			});
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += delegate(object o, ToggledArgs args) {
				TreeIter iter;
				var model = whiteSpaceOptions;
				if (model.GetIterFromString (out iter, args.Path)) {
					var option = (Option)model.GetValue (iter, 0);
					PropertyInfo info = GetPropertyByName (option.PropertyName);
					if (info == null || info.PropertyType != typeof(bool))
						return;
					bool value = (bool)info.GetValue (this.profile, null);
					info.SetValue (profile, !value, null);
					UpdateExample (texteditor.Document.Text);
				}
			};
			
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", 1);
			column.SetCellDataFunc (cellRendererToggle,  delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererToggle)cell).Active = (bool)GetValue (((Option)model.GetValue (iter, 0)).PropertyName);
			});
			
			treeviewInsertWhiteSpaceOptions.AppendColumn (column);
			
			treeviewInsertWhiteSpaceOptions.Model = whiteSpaceOptions;*/
			treeviewInsertWhiteSpaceCategory.ExpandAll ();
			#endregion
			
			#region Blank line options
			entryBeforUsings.Text = profile.BlankLinesBeforeUsings.ToString ();
			entryAfterUsings.Text = profile.BlankLinesAfterUsings.ToString ();
			
			entryBeforeFirstDeclaration.Text = profile.BlankLinesBeforeFirstDeclaration.ToString ();
			entryBetweenTypes.Text = profile.BlankLinesBetweenTypes.ToString ();
			
			entryBetweenFields.Text = profile.BlankLinesBetweenFields.ToString ();
			entryBetweenEvents.Text = profile.BlankLinesBetweenEventFields.ToString ();
			entryBetweenMembers.Text = profile.BlankLinesBetweenMembers.ToString ();
			
			entryBeforUsings.Changed += HandleEntryBeforUsingsChanged;
			entryAfterUsings.Changed += HandleEntryBeforUsingsChanged;
			entryBeforeFirstDeclaration.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenTypes.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenFields.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenEvents.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenMembers.Changed += HandleEntryBeforUsingsChanged;
			#endregion
		}
Beispiel #28
0
        /// <summary>
        /// Experimental function 
        /// </summary>
        /// <returns>
        /// The combo column.
        /// </returns>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        public Gtk.TreeViewColumn AppendComboColumn(string name,  EditedHandler EditedHandler, bool editable, string[] comboValues)
        {
            var listStore = new Gtk.ListStore (typeof(string));

            foreach (var value in comboValues) listStore.AppendValues(value);

            var cellRenderer = new Gtk.CellRendererCombo();
            cellRenderer.Editable = editable;
            cellRenderer.TextColumn = 0;
            cellRenderer.HasEntry = false;
            cellRenderer.Model = listStore;
            cellRenderer.Data["colPosition"] = Columns.Count;
            if (EditedHandler != null) cellRenderer.Edited += EditedHandler;

            var newColumn = new Gtk.TreeViewColumn ();
            newColumn.Title = name;

            newColumn.PackStart (cellRenderer, true);
            Columns.Add(newColumn);

            newColumn.Data["cellRenderer"] = cellRenderer;
            newColumn.Data["cellType"] = "text";
            newColumn.Data["cellTypeOf"] = typeof(string);

            return newColumn;
        }
Beispiel #29
0
        //,string dp)
        //string dp;
        //TODO Автоматическое принятие изменений в столбце Priority при нажатии кнопки "ok"
        //TODO Статистика торрента
        public TorrentSettings(TorrentManager t)
        {
            this.t = t;
            this.Build ();
            //this.dp = t.SavePath;
            torrent = t.Torrent;
            Title = torrent.Name;
            CellRendererText crte = new CellRendererText();
            entry1.Text = t.SavePath;

            CellRendererToggle crt = new CellRendererToggle();
            crt.Activatable =true;
            crt.Toggled += HandleCrtToggled;

            string[] cbe = new string[5];
            cbe[0] = "Highest";
            cbe[1] = "High";
            cbe[2] = "Normal";
            cbe[3] = "Low";
            cbe[4] = "Lowest";

            ListStore m = new ListStore(typeof(string));
            m.AppendValues(cbe[0]);
            m.AppendValues (cbe[1]);
            m.AppendValues (cbe[2]);
            m.AppendValues (cbe[3]);
            m.AppendValues (cbe[4]);
            CellRendererCombo crc = new CellRendererCombo();
            crc.Model = m;
            crc.TextColumn = 0;
            crc.Editable = true;

            crc.Edited += HandleCrcEdited;

            treeview1.AppendColumn ("Path", new CellRendererText(), "text", 0);
            treeview1.Columns[0].Sizing = TreeViewColumnSizing.Fixed;
            treeview1.Columns[0].MinWidth = 50;
            treeview1.Columns[0].MaxWidth = 500;
            treeview1.Columns[0].FixedWidth = 200;
            treeview1.Columns[0].Resizable = true;

            treeview1.AppendColumn ("IsDownload", crt, "active", 1);
            treeview1.AppendColumn ("Progress", new CellRendererProgressBar (), "value", 2);
            treeview1.AppendColumn ("Size(MB)", new CellRendererText (), "text", 3);
            treeview1.AppendColumn("Priority", crc, "text", 4);

            Gtk.TreeStore tfileListStore = new Gtk.TreeStore (typeof(string), typeof(bool), typeof(int), typeof(string),  typeof(string));

            foreach (TorrentFile file in torrent.Files)
            {
                if (file.Priority != Priority.DoNotDownload)
                {
                    tfileListStore.AppendValues (file.Path, true, (int)(((float)file.BytesDownloaded / (float) file.Length) * 100), ((float)file.Length / 1024 / 1024).ToString ("0.00"),  file.Priority.ToString());
                }
                else
                {
                    tfileListStore.AppendValues (file.Path, false, (int)(((float)file.BytesDownloaded / (float)file.Length) * 100), ((float)file.Length / 1024 / 1024).ToString ("0.00"),  "Normal");
                }

            }

            //Gtk.TreeIter iter = musicListStore.AppendValues (t.Files);
            //musicListStore.AppendValues (iter, "Fannypack", "Nu Nu (Yeah Yeah) (double j and haze radio edit)");

            treeview1.Model = tfileListStore;
            treeview1.ShowAll();

            TorrentInfo();
        }
		public CodeIssuePanelWidget (string mimeType)
		{
			this.mimeType = mimeType;
			// ReSharper disable once DoNotCallOverridableMethodsInConstructor
			Build ();

			// ensure selected row remains visible
			treeviewInspections.SizeAllocated += (o, args) => {
				TreeIter iter;
				if (treeviewInspections.Selection.GetSelected (out iter)) {
					var path = treeviewInspections.Model.GetPath (iter);
					treeviewInspections.ScrollToCell (path, treeviewInspections.Columns[0], false, 0f, 0f);
				}
			};
			treeviewInspections.TooltipColumn = 2;
			treeviewInspections.HasTooltip = true;

			var toggleRenderer = new CellRendererToggle ();
			toggleRenderer.Toggled += delegate(object o, ToggledArgs args) {
				TreeIter iter;
				if (treeStore.GetIterFromString (out iter, args.Path)) {
					var provider = (BaseCodeIssueProvider)treeStore.GetValue (iter, 1);
					enableState[provider] = !enableState[provider];
				}
			};

			var titleCol = new TreeViewColumn ();
			treeviewInspections.AppendColumn (titleCol);
			titleCol.PackStart (toggleRenderer, false);
			titleCol.Sizing = TreeViewColumnSizing.Autosize;
			titleCol.SetCellDataFunc (toggleRenderer, delegate (TreeViewColumn treeColumn, CellRenderer cell, TreeModel model, TreeIter iter) {
				var provider = (BaseCodeIssueProvider)model.GetValue (iter, 1);
				if (provider == null) {
					toggleRenderer.Visible = false;
					return;
				}
				toggleRenderer.Visible = true;
				toggleRenderer.Active = enableState[provider];
			});


			var cellRendererText = new CellRendererText {
				Ellipsize = Pango.EllipsizeMode.End
			};
			titleCol.PackStart (cellRendererText, true);
			titleCol.AddAttribute (cellRendererText, "markup", 0);
			titleCol.Expand = true;

			searchentryFilter.ForceFilterButtonVisible = true;
			searchentryFilter.RoundedShape = true;
			searchentryFilter.HasFrame = true;
			searchentryFilter.Ready = true;
			searchentryFilter.Visible = true;
			searchentryFilter.Entry.Changed += ApplyFilter;


			var comboRenderer = new CellRendererCombo {
				Alignment = Pango.Alignment.Center
			};
			var col = treeviewInspections.AppendColumn ("Severity", comboRenderer);
			col.Sizing = TreeViewColumnSizing.GrowOnly;
			col.MinWidth = 100;
			col.Expand = false;

			var comboBoxStore = new ListStore (typeof(string), typeof(Severity));
//			comboBoxStore.AppendValues (GetDescription (Severity.None), Severity.None);
			comboBoxStore.AppendValues (GetDescription (Severity.Error), Severity.Error);
			comboBoxStore.AppendValues (GetDescription (Severity.Warning), Severity.Warning);
			comboBoxStore.AppendValues (GetDescription (Severity.Hint), Severity.Hint);
			comboBoxStore.AppendValues (GetDescription (Severity.Suggestion), Severity.Suggestion);
			comboRenderer.Model = comboBoxStore;
			comboRenderer.Mode = CellRendererMode.Activatable;
			comboRenderer.TextColumn = 0;

			comboRenderer.Editable = true;
			comboRenderer.HasEntry = false;
			
			comboRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path))
					return;

				TreeIter storeIter;
				if (!comboBoxStore.GetIterFirst (out storeIter))
					return;
				do {
					if ((string)comboBoxStore.GetValue (storeIter, 0) == args.NewText) {
						var provider = (BaseCodeIssueProvider)treeStore.GetValue (iter, 1);
						var severity = (Severity)comboBoxStore.GetValue (storeIter, 1);
						severities[provider] = severity;
						return;
					}
				} while (comboBoxStore.IterNext (ref storeIter));
			};
			
			col.SetCellDataFunc (comboRenderer, delegate (TreeViewColumn treeColumn, CellRenderer cell, TreeModel model, TreeIter iter) {
				var provider = (BaseCodeIssueProvider)model.GetValue (iter, 1);
				if (provider == null) {
					comboRenderer.Visible = false;
					return;
				}
				var severity = severities[provider];
				comboRenderer.Visible = true;
				comboRenderer.Text = GetDescription (severity);
				comboRenderer.BackgroundGdk = GetColor (severity);
			});
			treeviewInspections.HeadersVisible = false;
			treeviewInspections.Model = treeStore;
			GetAllSeverities ();
			FillInspectors (null);
		}
Beispiel #31
0
        public TaskTreeView(CollectionView<Task> model)
            : base()
        {
            #if GTK_2_12
            // set up the timing for the tooltips
            this.Settings.SetLongProperty("gtk-tooltip-browse-mode-timeout", 0, "Tasque:TaskTreeView");
            this.Settings.SetLongProperty("gtk-tooltip-browse-timeout", 750, "Tasque:TaskTreeView");
            this.Settings.SetLongProperty("gtk-tooltip-timeout", 750, "Tasque:TaskTreeView");

            ConnectEvents();
            #endif

            // TODO: Modify the behavior of the TreeView so that it doesn't show
            // the highlighted row.  Then, also tie in with the mouse hovering
            // so that as you hover the mouse around, it will automatically
            // select the row that the mouse is hovered over.  By doing this,
            // we should be able to not require the user to click on a task
            // to select it and THEN have to click on the column item they want
            // to modify.

            filterCategory = null;

            modelFilter = new ListCollectionView<Task> (model);
            modelFilter.Filter = FilterFunc;
            modelFilter.CollectionChanged += HandleModelFilterChanged;
            Model = new TreeModelListAdapter<Task> (modelFilter);
            modelFilter.IsObserving = true;

            Selection.Mode = Gtk.SelectionMode.Single;
            RulesHint = false;
            HeadersVisible = false;
            HoverSelection = true;

            // TODO: Figure out how to turn off selection highlight

            Gtk.CellRenderer renderer;

            //
            // Checkbox Column
            //
            Gtk.TreeViewColumn column = new Gtk.TreeViewColumn ();
            // Title for Completed/Checkbox Column
            column.Title = Catalog.GetString ("Completed");
            column.Sizing = Gtk.TreeViewColumnSizing.Autosize;
            column.Resizable = false;
            column.Clickable = true;

            renderer = new Gtk.CellRendererToggle ();
            (renderer as Gtk.CellRendererToggle).Toggled += OnTaskToggled;
            column.PackStart (renderer, false);
            column.SetCellDataFunc (renderer, new Gtk.TreeCellDataFunc (TaskToggleCellDataFunc));
            AppendColumn (column);

            //
            // Priority Column
            //
            column = new Gtk.TreeViewColumn ();
            // Title for Priority Column
            column.Title = Catalog.GetString ("Priority");
            //column.Sizing = Gtk.TreeViewColumnSizing.Autosize;
            column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.Alignment = 0.5f;
            column.FixedWidth = 30;
            column.Resizable = false;
            column.Clickable = true;

            renderer = new Gtk.CellRendererCombo ();
            (renderer as Gtk.CellRendererCombo).Editable = true;
            (renderer as Gtk.CellRendererCombo).HasEntry = false;
            SetCellRendererCallbacks ((CellRendererCombo) renderer, OnTaskPriorityEdited);
            Gtk.ListStore priorityStore = new Gtk.ListStore (typeof (string));
            priorityStore.AppendValues (Catalog.GetString ("1")); // High
            priorityStore.AppendValues (Catalog.GetString ("2")); // Medium
            priorityStore.AppendValues (Catalog.GetString ("3")); // Low
            priorityStore.AppendValues (Catalog.GetString ("-")); // None
            (renderer as Gtk.CellRendererCombo).Model = priorityStore;
            (renderer as Gtk.CellRendererCombo).TextColumn = 0;
            renderer.Xalign = 0.5f;
            column.PackStart (renderer, true);
            column.SetCellDataFunc (renderer,
                    new Gtk.TreeCellDataFunc (TaskPriorityCellDataFunc));
            AppendColumn (column);

            //
            // Task Name Column
            //
            column = new Gtk.TreeViewColumn ();
            // Title for Task Name Column
            column.Title = Catalog.GetString ("Task Name");
            //			column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.Sizing = Gtk.TreeViewColumnSizing.Autosize;
            column.Expand = true;
            column.Resizable = true;

            // TODO: Add in code to determine how wide we should make the name
            // column.
            // TODO: Add in code to readjust the size of the name column if the
            // user resizes the Task Window.
            //column.FixedWidth = 250;

            renderer = new Gtk.CellRendererText ();
            column.PackStart (renderer, true);
            column.SetCellDataFunc (renderer,
                new Gtk.TreeCellDataFunc (TaskNameTextCellDataFunc));
            ((Gtk.CellRendererText)renderer).Editable = true;
            SetCellRendererCallbacks ((CellRendererText) renderer, OnTaskNameEdited);

            AppendColumn (column);

            //
            // Due Date Column
            //

            //  2/11 - Today
            //  2/12 - Tomorrow
            //  2/13 - Wed
            //  2/14 - Thu
            //  2/15 - Fri
            //  2/16 - Sat
            //  2/17 - Sun
            // --------------
            //  2/18 - In 1 Week
            // --------------
            //  No Date
            // ---------------
            //  Choose Date...

            column = new Gtk.TreeViewColumn ();
            // Title for Due Date Column
            column.Title = Catalog.GetString ("Due Date");
            column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.Alignment = 0f;
            column.FixedWidth = 90;
            column.Resizable = false;
            column.Clickable = true;

            renderer = new Gtk.CellRendererCombo ();
            (renderer as Gtk.CellRendererCombo).Editable = true;
            (renderer as Gtk.CellRendererCombo).HasEntry = false;
            SetCellRendererCallbacks ((CellRendererCombo) renderer, OnDateEdited);
            Gtk.ListStore dueDateStore = new Gtk.ListStore (typeof (string));
            DateTime today = DateTime.Now;
            dueDateStore.AppendValues (
                today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today"));
            dueDateStore.AppendValues (
                today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow"));
            dueDateStore.AppendValues (
                today.AddDays(2).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays(3).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays(4).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays(5).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays(6).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week"));
            dueDateStore.AppendValues (Catalog.GetString ("No Date"));
            dueDateStore.AppendValues (Catalog.GetString ("Choose Date..."));
            (renderer as Gtk.CellRendererCombo).Model = dueDateStore;
            (renderer as Gtk.CellRendererCombo).TextColumn = 0;
            renderer.Xalign = 0.0f;
            column.PackStart (renderer, true);
            column.SetCellDataFunc (renderer,
                    new Gtk.TreeCellDataFunc (DueDateCellDataFunc));
            AppendColumn (column);

            //
            // Notes Column
            //
            column = new Gtk.TreeViewColumn ();
            // Title for Notes Column
            column.Title = Catalog.GetString ("Notes");
            column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = 20;
            column.Resizable = false;

            renderer = new Gtk.CellRendererPixbuf ();
            column.PackStart (renderer, false);
            column.SetCellDataFunc (renderer,
                new Gtk.TreeCellDataFunc (TaskNotesCellDataFunc));

            AppendColumn (column);

            //
            // Timer Column
            //
            column = new Gtk.TreeViewColumn ();
            // Title for Timer Column
            column.Title = Catalog.GetString ("Timer");
            column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = 20;
            column.Resizable = false;

            renderer = new Gtk.CellRendererPixbuf ();
            renderer.Xalign = 0.5f;
            column.PackStart (renderer, false);
            column.SetCellDataFunc (renderer,
                new Gtk.TreeCellDataFunc (TaskTimerCellDataFunc));

            AppendColumn (column);
        }
		public CodeIssuePanelWidget (string mimeType)
		{
			this.mimeType = mimeType;
			Build ();

			var col1 = treeviewInspections.AppendColumn ("Title", new CellRendererText (), "markup", 0);
			col1.Expand = true;

			searchentryFilter.Ready = true;
			searchentryFilter.Visible = true;
			searchentryFilter.Entry.Changed += ApplyFilter;

			var comboRenderer = new CellRendererCombo ();
			comboRenderer.Alignment = Pango.Alignment.Center;
			var col = treeviewInspections.AppendColumn ("Severity", comboRenderer);
			col.Sizing = TreeViewColumnSizing.GrowOnly;
			col.MinWidth = 100;
			col.Expand = false;

			var comboBoxStore = new ListStore (typeof(string), typeof(Severity));
			comboBoxStore.AppendValues (GetDescription (Severity.None), Severity.None);
			comboBoxStore.AppendValues (GetDescription (Severity.Error), Severity.Error);
			comboBoxStore.AppendValues (GetDescription (Severity.Warning), Severity.Warning);
			comboBoxStore.AppendValues (GetDescription (Severity.Hint), Severity.Hint);
			comboBoxStore.AppendValues (GetDescription (Severity.Suggestion), Severity.Suggestion);
			comboRenderer.Model = comboBoxStore;
			comboRenderer.Mode = CellRendererMode.Activatable;
			comboRenderer.TextColumn = 0;

			comboRenderer.Editable = true;
			comboRenderer.HasEntry = false;
			
			comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) {
				Gtk.TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path))
					return;

				Gtk.TreeIter storeIter;
				if (!comboBoxStore.GetIterFirst (out storeIter))
					return;
				do {
					if ((string)comboBoxStore.GetValue (storeIter, 0) == args.NewText) {
						var provider = (BaseCodeIssueProvider)treeStore.GetValue (iter, 1);
						var severity = (Severity)comboBoxStore.GetValue (storeIter, 1);
						severities[provider] = severity;
						return;
					}
				} while (comboBoxStore.IterNext (ref storeIter));
			};
			
			col.SetCellDataFunc (comboRenderer, delegate (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
				var provider = (BaseCodeIssueProvider)model.GetValue (iter, 1);
				if (provider == null) {
					comboRenderer.Visible = false;
					return;
				}
				var severity = severities[provider];
				comboRenderer.Visible = true;
				comboRenderer.Text = GetDescription (severity);
				comboRenderer.BackgroundGdk = GetColor (severity);
			});
			treeviewInspections.HeadersVisible = false;
			treeviewInspections.Model = treeStore;
			treeviewInspections.Selection.Changed += HandleSelectionChanged;
			GetAllSeverities ();
			FillInspectors (null);
		}
        public Order()
            : base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            notebook1.CurrentPage = 0;
            ComboWorks.ComboFillReference(comboExhibition, "exhibition", ComboWorks.ListMode.WithNo, true, "ordinal");
            dateArrval.Date = DateTime.Today;

            //Создаем таблицу номенклатуры
            ComboBox TempCombo = new ComboBox();
            ComboWorks.ComboFillReference(TempCombo, "materials", ComboWorks.ListMode.WithNo, true, "ordinal");
            MaterialNameList = TempCombo.Model;
            TempCombo.Destroy ();

            TempCombo = new ComboBox();
            ComboWorks.ComboFillReference(TempCombo, "facing", ComboWorks.ListMode.WithNo, true, "ordinal");
            FacingNameList = TempCombo.Model;
            TempCombo.Destroy ();

            ComponentsStore = new TreeStore(
                typeof(long), //row_id
                typeof(Nomenclature.NomType), //nomenclature_type
                typeof(int), //nomenclature_id
                typeof(string), //nomenclature
                typeof(string), //nomenclature_title
                typeof(string), //nomenclature_description
                typeof(int), //count
                typeof(int), //material_id
                typeof(string), //material
                typeof(int), //facing_id
                typeof(string), //facing
                typeof(string), //comment
                typeof(string), //price
                typeof(string), //price_total
                typeof(bool), //editable_count
                typeof(bool), //editable_price
                typeof(bool), //editable_material
                typeof(bool), //editable_facing
                typeof(bool), //editable_comment
                typeof(bool), //editable_discount
                typeof(int), //discount
                typeof(bool)); //editable_name

            BasisIter = ComponentsStore.AppendValues (
                (long)-1,
                Enum.Parse(typeof(Nomenclature.NomType), "construct"),
                1,
                null,
                "Каркас",
                null,
                1,
                -1,
                "",
                -1,
                "",
                "",
                "",
                "",
                false,
                false,
                false,
                false,
                false,
                false,
                null,
                false);

            ServiceIter = ComponentsStore.InsertNodeAfter (BasisIter);

            ComponentsStore.SetValues (
                ServiceIter,
                (long)-1,
                Enum.Parse (typeof(Nomenclature.NomType), "other"),
                1,
                null,
                "Услуги",
                "Кликните правой кнопкой мышы для добавления услуги",
                0,
                -1,
                "",
                -1,
                "",
                "",
                "",
                "",
                false,
                false,
                false,
                false,
                false,
                false,
                null,
                false);

            ColumnCount = new Gtk.TreeViewColumn ();
            ColumnCount.Title = "Кол-во";
            Gtk.CellRendererText CellCount = new CellRendererText ();
            CellCount.Editable = true;
            CellCount.Edited += OnCountEdited;
            ColumnCount.PackStart (CellCount, true);
            ColumnCount.AddAttribute(CellCount, "text", (int)ComponentCol.count);
            ColumnCount.AddAttribute(CellCount, "editable", (int)ComponentCol.editable_count);

            ColumnMaterial = new Gtk.TreeViewColumn ();
            ColumnMaterial.Title = "Отделка кубов";
            ColumnMaterial.MinWidth = 180;
            Gtk.CellRendererCombo CellMaterial = new CellRendererCombo();
            CellMaterial.TextColumn = 0;
            CellMaterial.Editable = true;
            CellMaterial.Model = MaterialNameList;
            CellMaterial.HasEntry = false;
            CellMaterial.Edited += OnMaterialComboEdited;
            ColumnMaterial.PackStart (CellMaterial, true);
            ColumnMaterial.AddAttribute(CellMaterial, "text", (int)ComponentCol.material);
            ColumnMaterial.AddAttribute(CellMaterial, "editable", (int)ComponentCol.editable_material);

            ColumnFacing = new Gtk.TreeViewColumn ();
            ColumnFacing.Title = "Отделка фасада";
            ColumnFacing.MinWidth = 180;
            Gtk.CellRendererCombo CellFacing = new CellRendererCombo();
            CellFacing.TextColumn = 0;
            CellFacing.Editable = true;
            CellFacing.Model = FacingNameList;
            CellFacing.HasEntry = false;
            CellFacing.Edited += OnFacingComboEdited;
            ColumnFacing.PackStart (CellFacing, true);
            ColumnFacing.AddAttribute(CellFacing, "text", (int)ComponentCol.facing);
            ColumnFacing.AddAttribute(CellFacing, "editable", (int)ComponentCol.editable_facing);

            ColumnPrice = new Gtk.TreeViewColumn ();
            ColumnPrice.Title = "Цена";
            ColumnPrice.Visible = false;
            Gtk.CellRendererText CellPrice = new CellRendererText ();
            CellPrice.Editable = true;
            CellPrice.Edited += OnPriceEdited;
            ColumnPrice.PackStart (CellPrice, true);
            ColumnPrice.AddAttribute(CellPrice, "text", (int)ComponentCol.price);
            ColumnPrice.AddAttribute(CellPrice, "editable", (int)ComponentCol.editable_price);

            ColumnPriceTotal = new Gtk.TreeViewColumn ();
            ColumnPriceTotal.Title = "Сумма";
            ColumnPriceTotal.Visible = false;
            Gtk.CellRendererText CellPriceTotal = new CellRendererText ();
            CellPriceTotal.Editable = false;
            ColumnPriceTotal.PackStart (CellPriceTotal, true);
            ColumnPriceTotal.AddAttribute(CellPriceTotal, "text", (int)ComponentCol.price_total);

            ColumnComment = new Gtk.TreeViewColumn ();
            ColumnComment.Title = "Комментарий";
            Gtk.CellRendererText CellComment = new Gtk.CellRendererText ();
            CellComment.WrapMode = Pango.WrapMode.WordChar;
            CellComment.WrapWidth = 500;
            CellComment.Editable = true;
            CellComment.Edited += OnCommentTextEdited;
            ColumnComment.MaxWidth = 500;
            ColumnComment.PackStart (CellComment, true);
            ColumnComment.AddAttribute(CellComment, "text", (int)ComponentCol.comment);
            ColumnComment.AddAttribute(CellComment, "editable", (int)ComponentCol.editable_comment);

            ColumnDiscount = new Gtk.TreeViewColumn ();
            ColumnDiscount.Title = "Наценка";
            Gtk.CellRendererSpin CellDiscount = new Gtk.CellRendererSpin ();
            CellDiscount.Visible = false;
            CellDiscount.Edited += OnDiscountEdited;
            CellDiscount.Adjustment = new Adjustment (0, -100, 100, 1, 10, 0);
            ColumnDiscount.PackStart (CellDiscount, true);
            ColumnDiscount.AddAttribute (CellDiscount, "text", (int)ComponentCol.discount);
            ColumnDiscount.AddAttribute (CellDiscount, "visible", (int)ComponentCol.editable_discount);
            ColumnDiscount.AddAttribute (CellDiscount, "editable", (int)ComponentCol.editable_discount);

            ColumnName = new Gtk.TreeViewColumn ();
            ColumnName.Title = "Название";
            Gtk.CellRendererText CellName = new CellRendererText ();
            CellName.Edited += OnCellNameEdited;
            ColumnName.PackStart (CellName, true);
            ColumnName.AddAttribute (CellName, "editable", (int)ComponentCol.editable_name);
            ColumnName.AddAttribute (CellName, "text", (int)ComponentCol.nomenclature_title);

            treeviewComponents.AppendColumn(ColumnName);
            treeviewComponents.AppendColumn(ColumnCount);
            treeviewComponents.AppendColumn(ColumnPrice);
            treeviewComponents.AppendColumn(ColumnDiscount);
            treeviewComponents.AppendColumn(ColumnPriceTotal);
            treeviewComponents.AppendColumn(ColumnMaterial);
            treeviewComponents.AppendColumn(ColumnFacing);
            treeviewComponents.AppendColumn(ColumnComment);
            treeviewComponents.Model = ComponentsStore;
            treeviewComponents.TooltipColumn = (int)ComponentCol.nomenclature_description;
            treeviewComponents.ShowAll();

            spinbutton1.Sensitive = false;
            spinbutton1.Value = PriceCorrection;
            checkbuttonShowPrice.Active = false;

            CurrentDrag = new DragInformation();
            //Загрузка списка кубов
            CubeList = new List<Cube>();
            CubeWidgetList = new List<CubeListItem>();
            vboxCubeList = new VBox(false, 6);
            hboxCubeList = new HBox(false, 20);
            string sql = "SELECT * FROM cubes ORDER BY ordinal";

            SqliteCommand cmd = new SqliteCommand(sql, (SqliteConnection)QSMain.ConnectionDB);
            using (SqliteDataReader rdr = cmd.ExecuteReader()) {
                while(rdr.Read()) {
                    if (rdr["image"] == DBNull.Value)
                        continue;
                    Cube TempCube = new Cube();
                    TempCube.NomenclatureId = rdr.GetInt32(rdr.GetOrdinal("id"));
                    TempCube.Name = DBWorks.GetString(rdr, "name", "");
                    TempCube.Description = DBWorks.GetString(rdr, "description", "");
                    TempCube.Height = DBWorks.GetInt(rdr, "height", 0) * 400;
                    TempCube.Widht = DBWorks.GetInt(rdr, "width", 0) * 400;
                    byte[] ImageFile = (byte[])rdr[rdr.GetOrdinal("image")];
                    TempCube.LoadSvg(ImageFile);
                    CubeList.Add(TempCube);
                    MaxCubeVSize = Math.Max(MaxCubeVSize, TempCube.CubesV);
                    MaxCubeHSize = Math.Max(MaxCubeHSize, TempCube.CubesH);

                    //Добавляем виджеты в лист
                    CubeListItem TempWidget = new CubeListItem();
                    TempCube.Widget = TempWidget;
                    TempWidget.CubeItem = TempCube;
                    TempWidget.CubePxSize = CubePxSize;
                    TempWidget.DragInfo = CurrentDrag;
                    CubeWidgetList.Add(TempWidget);
                }
                UpdateCubeList();
                scrolledCubeListV.AddWithViewport(vboxCubeList);
                scrolledCubeListH.AddWithViewport(hboxCubeList);
            }

            //Загрузка Списка типов шкафов
            TypeWidgetList = new List<CupboardListItem>();
            hboxTypeList = new HBox(false, 2);
            Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( "CupboardDesigner.icons.Yes_check.svg" );
            byte[] temparray;
            using(MemoryStream mstream = new MemoryStream()) {
                stream.CopyTo(mstream);
                temparray = mstream.ToArray();
            }
            Rsvg.Handle CheckImage = new Rsvg.Handle(temparray);
            sql = "SELECT * FROM basis ORDER BY ordinal ";
            cmd = new SqliteCommand(sql, (SqliteConnection)QSMain.ConnectionDB);
            using (SqliteDataReader rdr = cmd.ExecuteReader()) {
                Gtk.RadioButton FirstButton = null;
                while(rdr.Read()) {
                    if (rdr["image"] == DBNull.Value)
                        continue;

                    //Добавляем виджеты в лист
                    CupboardListItem TempWidget = new CupboardListItem(CheckImage);
                    TempWidget.id = rdr.GetInt32(rdr.GetOrdinal("id"));
                    TempWidget.DeltaH = rdr.GetInt32(rdr.GetOrdinal("delta_h"));
                    TempWidget.DeltaL = rdr.GetInt32(rdr.GetOrdinal("delta_l"));
                    TempWidget.ItemName = DBWorks.GetString(rdr, "name", "");
                    TempWidget.CubePxSize = CubePxSize;
                    if (FirstButton == null)
                        FirstButton = TempWidget.Button;
                    else
                        TempWidget.Button.Group = FirstButton.Group;
                    int size = DBWorks.GetInt(rdr, "image_size", 0);
                    byte[] ImageFile = new byte[size];
                    rdr.GetBytes(rdr.GetOrdinal("image"), 0, ImageFile, 0, size);
                    TempWidget.Image = new SVGHelper();
                    if (!TempWidget.Image.LoadImage(ImageFile))
                        continue;
                    TempWidget.Button.Clicked += OnBasisChanged;
                    TypeWidgetList.Add(TempWidget);
                    hboxTypeList.Add(TempWidget);
                }
                scrolledTypesH.AddWithViewport(hboxTypeList);
                hboxTypeList.ShowAll();
            }

            OrderCupboard = new Cupboard();
            OnBasisChanged(null, EventArgs.Empty);

            //Настраиваем DND
            Gtk.Drag.DestSet(drawCupboard, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.SourceSet(drawCupboard, ModifierType.Button1Mask, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.DestSet(vboxCubeList, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.DestSet(hboxCubeList, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            vboxCubeList.DragDrop += OnCubeListDragDrop;
            hboxCubeList.DragDrop += OnCubeListDragDrop;
        }
Beispiel #34
0
        private void Build()
        {
            SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
            ShadowType = ShadowType.EtchedIn;

            d_treeview = new TreeView <Node>();
            d_treeview.Show();

            d_treeview.EnableSearch = false;

            d_treeview.RulesHint      = true;
            d_treeview.Selection.Mode = SelectionMode.Multiple;
            d_treeview.ShowExpanders  = false;

            d_treeview.ButtonPressEvent += OnTreeViewButtonPressEvent;
            d_treeview.KeyPressEvent    += OnTreeViewKeyPressEvent;

            d_treeview.TooltipColumn = (int)Node.Columns.Tooltip;

            CellRendererText renderer;
            TreeViewColumn   column;

            // Setup renderer for the name of the property
            renderer          = new CellRendererText();
            renderer.Editable = true;

            column           = d_treeview.AppendColumn("Name", renderer, "text", Node.Columns.Name);
            column.Resizable = true;
            column.MinWidth  = 75;

            column.SetCellDataFunc(renderer, VisualizeProperties);

            CellRenderer rname = renderer;

            renderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
                d_editingEntry = args.Editable as Entry;
                d_editingPath  = args.Path;

                Node node = d_treeview.NodeStore.FindPath(new TreePath(args.Path));

                if (node.Variable == null && !(node is InterfaceNode))
                {
                    d_editingEntry.Text = "";
                }

                d_editingEntry.KeyPressEvent += delegate(object source, KeyPressEventArgs a)
                {
                    OnEntryKeyPressed(a, rname, NameEdited);
                };
            };

            renderer.EditingCanceled += delegate(object sender, EventArgs e) {
                if (d_editingEntry != null && Utils.GetCurrentEvent() is Gdk.EventButton)
                {
                    // Still do it actually
                    NameEdited(d_editingEntry.Text, d_editingPath);
                }
            };

            renderer.Edited += DoNameEdited;

            // Setup renderer for expression of the property
            renderer = new Gtk.CellRendererText();
            column   = d_treeview.AppendColumn("Expression", renderer,
                                               "text", Node.Columns.Expression,
                                               "editable", Node.Columns.Editable);

            column.Resizable = true;
            column.Expand    = true;

            column.SetCellDataFunc(renderer, VisualizeProperties);

            CellRenderer rexpr = renderer;

            renderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
                d_editingEntry = args.Editable as Entry;
                d_editingPath  = args.Path;

                d_editingEntry.KeyPressEvent += delegate(object source, KeyPressEventArgs a)
                {
                    OnEntryKeyPressed(a, rexpr, ExpressionEdited);
                };
            };

            renderer.EditingCanceled += delegate(object sender, EventArgs e) {
                if (d_editingEntry != null && Utils.GetCurrentEvent() is Gdk.EventButton)
                {
                    // Still do it actually
                    ExpressionEdited(d_editingEntry.Text, d_editingPath);
                }
            };

            renderer.Edited += DoExpressionEdited;

            // Setup renderer for integrated toggle
            CellRendererToggle toggle;

            toggle = new Gtk.CellRendererToggle();
            column = d_treeview.AppendColumn(" ∫", toggle,
                                             "active", Node.Columns.Integrated,
                                             "activatable", Node.Columns.Editable);
            column.Resizable = false;

            toggle.Toggled += DoIntegratedToggled;

            // Setup renderer for flags
            CellRendererCombo combo;

            combo = new Gtk.CellRendererCombo();

            column = d_treeview.AppendColumn("Flags", combo,
                                             "text", Node.Columns.Flags,
                                             "editable", Node.Columns.Editable);
            column.Resizable = true;
            column.Expand    = false;

            combo.EditingStarted += DoEditingStarted;
            combo.Edited         += DoFlagsEdited;

            combo.HasEntry = false;

            d_flagsStore     = new ListStore(typeof(string));
            combo.Model      = d_flagsStore;
            combo.TextColumn = 0;

            column.MinWidth = 50;

            if (d_wrapper != null && d_wrapper is Wrappers.Node)
            {
                renderer = new Gtk.CellRendererText();

                column = d_treeview.AppendColumn("Interface", renderer,
                                                 "text", Node.Columns.Target);

                renderer.Editable = true;

                column.SetCellDataFunc(renderer, VisualizeProperties);

                CellRenderer riface = renderer;

                renderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
                    d_editingEntry = args.Editable as Entry;
                    d_editingPath  = args.Path;

                    d_editingEntry.KeyPressEvent += delegate(object source, KeyPressEventArgs a)
                    {
                        OnEntryKeyPressed(a, riface, InterfaceEdited);
                    };
                };

                renderer.EditingCanceled += delegate(object sender, EventArgs e) {
                    if (d_editingEntry != null && Utils.GetCurrentEvent() is Gdk.EventButton)
                    {
                        // Still do it actually
                        InterfaceEdited(d_editingEntry.Text, d_editingPath);
                    }
                };

                renderer.Edited += DoInterfaceEdited;
            }

            Populate();
            InitializeFlagsList();

            Add(d_treeview);
        }
        public FieldsDialog()
        {
            this.Build ();

            CellRendererText nameCell = new Gtk.CellRendererText ();
            nameCell.Editable = true;

            nameCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Name = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Name = args.NewText;
            };
            this.nodeView.AppendColumn ("Имя", nameCell, "text", 0);

            ComboBox compteComboBox = new Gtk.ComboBox(Fields.Field.KeyboardList);
            Gtk.TreeViewColumn compteColumn = new TreeViewColumn();

            Gtk.CellRendererCombo compteCellCombo = new CellRendererCombo();
            compteColumn.PackStart(compteCellCombo, true);
            compteCellCombo.TextColumn = 0;
            compteCellCombo.Editable = true;
            compteCellCombo.Edited += delegate(object o, EditedArgs args) {
                    nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                    FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                    node.Keyboard = args.NewText;
                    FieldsController.GetInstance().GetFieldById(node.Id).Keyboard = args.NewText;
                };
            compteCellCombo.HasEntry = false;
            compteCellCombo.Model = compteComboBox.Model;
            compteCellCombo.Text = compteComboBox.ActiveText;

            this.nodeView.AppendColumn ("Клавиатура", compteCellCombo, "text", 1);

            CellRendererText maxLenCell = new Gtk.CellRendererText ();
            maxLenCell.Editable = true;
            maxLenCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                try{
                    int maxLen = int.Parse(args.NewText);
                    node.MaxLen = args.NewText;
                    FieldsController.GetInstance().GetFieldById(node.Id).MaxLen = maxLen;
                }catch(Exception) {	return;	}
            };
            this.nodeView.AppendColumn ("Максимальная длина", maxLenCell, "text", 2);

            CellRendererText messageCell = new Gtk.CellRendererText ();
            messageCell.Editable = true;
            messageCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Message = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Message = args.NewText;
            };
            this.nodeView.AppendColumn ("Сообщение", messageCell, "text", 3);

            CellRendererText exampleCell = new Gtk.CellRendererText ();
            exampleCell.Editable = true;
            exampleCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Example = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Example = args.NewText;
            };
            this.nodeView.AppendColumn ("Пример", exampleCell, "text", 4);

            CellRendererText titleCell = new Gtk.CellRendererText ();
            titleCell.Editable = true;
            titleCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Title = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Title = args.NewText;
            };
            this.nodeView.AppendColumn ("Заглавие", titleCell, "text", 5);

            CellRendererText regexCell = new Gtk.CellRendererText ();
            regexCell.Editable = true;
            regexCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Regex = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Regex = args.NewText;
            };
            this.nodeView.AppendColumn ("Рег. выражение", regexCell, "text", 6);

            CellRendererText splitCell = new Gtk.CellRendererText ();
            splitCell.Editable = true;
            splitCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Split = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Split = args.NewText;
            };
            this.nodeView.AppendColumn ("Разделитель", splitCell, "text", 7);

            CellRendererText helpCell = new Gtk.CellRendererText ();
            helpCell.Editable = true;
            helpCell.Edited += delegate(object o, EditedArgs args) {
                nodeView.NodeSelection.SelectPath(new TreePath(args.Path));
                FieldNode node = (FieldNode) nodeView.NodeSelection.SelectedNode;
                node.Help = args.NewText;
                FieldsController.GetInstance().GetFieldById(node.Id).Help = args.NewText;
            };
            this.nodeView.AppendColumn ("Помощь", helpCell, "text", 8);

            this.nodeView.NodeSelection.Changed += delegate(object sender, EventArgs e) {
                FieldNode node = nodeView.NodeSelection.SelectedNode as FieldNode;
                if(node != null)
                    FieldsController.GetInstance().SetSelectedField(node.Id);
            };
        }
		public CustomPropertiesWidget (PListScheme scheme)
		{
			this.scheme = scheme = scheme ?? PListScheme.Empty;
			this.Build ();
			treeview1 = new PopupTreeView  (this);
			this.vbox1.PackStart (treeview1, true, true, 0);
			ShowAll ();
			
			var keyRenderer = new CellRendererCombo ();
			keyRenderer.Editable = true;
			keyRenderer.Model = keyStore;
			keyRenderer.Mode = CellRendererMode.Editable;
			keyRenderer.TextColumn = 0;
			keyRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter selIter;
				if (!treeStore.GetIterFromString (out selIter, args.Path)) 
					return;
				if (args.NewText == (string)treeStore.GetValue (selIter, 0))
					return;
				
				var obj = (PObject)treeStore.GetValue (selIter, 1);
				
				var dict = obj.Parent as PDictionary;
				if (dict == null)
					return;
				
				var key = scheme.Keys.FirstOrDefault (k => k.Identifier == args.NewText || k.Description == args.NewText);
				var newKey = key != null ? key.Identifier : args.NewText;
				
				if (!dict.ChangeKey (obj, newKey))
					return;
				
				treeStore.SetValue (selIter, 0, newKey);
				
			};
			
			treeview1.AppendColumn (GettextCatalog.GetString ("Property"), keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				string id = (string)tree_model.GetValue (iter, 0) ?? "";
				var obj = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Text = id;
					renderer.Editable = false;
					renderer.Sensitive = false;
					return;
				}
				
				var key = scheme.GetKey (id);
				renderer.Editable = !(obj.Parent is PArray);
				renderer.Sensitive = true;
				renderer.Text = key != null && ShowDescriptions ? GettextCatalog.GetString (key.Description) : id;
			});
			treeview1.RowExpanded += delegate(object o, RowExpandedArgs args) {
				var obj = (PObject)treeStore.GetValue (args.Iter, 1);
				expandedObjects.Add (obj);
			};
			treeview1.RowCollapsed += delegate(object o, RowCollapsedArgs args) {
				var obj = (PObject)treeStore.GetValue (args.Iter, 1);
				expandedObjects.Remove (obj);
			};
			var comboRenderer = new CellRendererCombo ();
			
			var typeModel = new ListStore (typeof (string));
			typeModel.AppendValues ("Array");
			typeModel.AppendValues ("Dictionary");
			typeModel.AppendValues ("Boolean");
			typeModel.AppendValues ("Data");
			typeModel.AppendValues ("Date");
			typeModel.AppendValues ("Number");
			typeModel.AppendValues ("String");
			comboRenderer.Model = typeModel;
			comboRenderer.Mode = CellRendererMode.Editable;
			comboRenderer.HasEntry = false;
			comboRenderer.TextColumn = 0;
			comboRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter selIter;
				if (!treeStore.GetIterFromString (out selIter, args.Path)) 
					return;
				
				PObject oldObj = (PObject)treeStore.GetValue (selIter, 1);
				if (oldObj == null)
					return;
				var newObj = CreateNewObject (args.NewText);
				
				oldObj.Replace (newObj);
			};
			
			treeview1.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				string id = (string)tree_model.GetValue (iter, 0) ?? "";
				var key   = scheme.GetKey (id);
				var obj   = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Editable = false;
					renderer.Text = "";
					return; 
				}
				renderer.Editable = key == null;
				renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive);
				renderer.Text = obj.TypeString;
			});
			
			var propRenderer = new CellRendererCombo ();
			
			propRenderer.Model = valueStore;
			propRenderer.Mode = CellRendererMode.Editable;
			propRenderer.TextColumn = 0;
			propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
				valueStore.Clear ();
				if (Scheme == null)
					return;
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				var pObject = (PObject)treeStore.GetValue (iter, 1);
				if (pObject == null)
					return;
				var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null;
				if (key != null) {
					var descr = new List<string> (key.Values.Select (v => v.Description));
					descr.Sort ();
					foreach (var val in descr) {
						valueStore.AppendValues (val);
					}
				}
			};
			
			propRenderer.Edited += delegate(object o, EditedArgs args) {
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				var pObject = (PObject)treeStore.GetValue (iter, 1);
				if (pObject == null)
					return;
				string newText = args.NewText;
				var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null;
				if (key != null) {
					foreach (var val in key.Values) {
						if (newText == val.Description) {
							newText = val.Identifier;
							break;
						}
					}
				}
				pObject.SetValue (newText);
			};
			
	/*		propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
				TreeIter iter;
				if (!treeStore.GetIterFromString (out iter, args.Path)) 
					return;
				PObject obj = (PObject)treeStore.GetValue (iter, 1);
				if (obj is PBoolean) {
					((PBoolean)obj).Value = !((PBoolean)obj).Value;
					propRenderer.StopEditing (false);
				}
			};*/
			
			
			treeview1.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
				var renderer = (CellRendererCombo)cell;
				var obj      = (PObject)tree_model.GetValue (iter, 1);
				if (obj == null) {
					renderer.Editable = false;
					renderer.Text = "";
					return;
				}
				renderer.Editable = !(obj is PArray || obj is PDictionary || obj is PData);
				obj.RenderValue (this, renderer);
			});
			treeview1.EnableGridLines = TreeViewGridLines.Horizontal;
			treeview1.Model = treeStore;
		}
		//TODO: difference between columns and reference columns + combo events
		public ForeignKeyConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, ForeignKeyConstraintEditorSettings settings)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			if (settings == null)
				throw new ArgumentNullException ("settings");
			
			this.schemaProvider = schemaProvider;
			this.action = action;
			this.settings = settings;

			this.Build();

			store = new ListStore (typeof (string), typeof (string), typeof (bool), typeof (string), typeof (string), typeof (string), typeof (string), typeof (object));
			listFK.Model = store;
			
			storeActions = new ListStore (typeof (string), typeof (int));
			storeTables = new ListStore (typeof (string), typeof(TableSchema));
			
			if (settings.SupportsCascade)
				storeActions.AppendValues ("Cascade", (int)ForeignKeyAction.Cascade);
			if (settings.SupportsRestrict)
				storeActions.AppendValues ("Restrict", (int)ForeignKeyAction.Restrict);
			if (settings.SupportsNoAction)
				storeActions.AppendValues ("No Action", (int)ForeignKeyAction.NoAction);
			if (settings.SupportsSetNull)
				storeActions.AppendValues ("Set Null", (int)ForeignKeyAction.SetNull);
			if (settings.SupportsSetDefault)
				storeActions.AppendValues ("Set Default", (int)ForeignKeyAction.SetDefault);

			TreeViewColumn colName = new TreeViewColumn ();
			TreeViewColumn colRefTable = new TreeViewColumn ();
			TreeViewColumn colIsColumnConstraint = new TreeViewColumn ();
			TreeViewColumn colDeleteAction = new TreeViewColumn ();
			TreeViewColumn colUpdateAction = new TreeViewColumn ();
			
			colName.Title = AddinCatalog.GetString ("Name");
			colRefTable.Title = AddinCatalog.GetString ("Reference Table");
			colIsColumnConstraint.Title = AddinCatalog.GetString ("Column Constraint");
			colDeleteAction.Title = AddinCatalog.GetString ("Delete Action");
			colUpdateAction.Title = AddinCatalog.GetString ("Update Action");
			
			colRefTable.MinWidth = 120;
			
			CellRendererText nameRenderer = new CellRendererText ();
			CellRendererCombo refTableRenderer = new CellRendererCombo ();
			CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle ();
			CellRendererCombo deleteActionRenderer = new CellRendererCombo ();
			CellRendererCombo updateActionRenderer = new CellRendererCombo ();
			
			nameRenderer.Editable = true;
			nameRenderer.Edited += new EditedHandler (NameEdited);
			
			refTableRenderer.Model = storeTables;
			refTableRenderer.TextColumn = 0;
			refTableRenderer.Editable = true;
			refTableRenderer.Edited += new EditedHandler (RefTableEdited);
			
			deleteActionRenderer.Model = storeActions;
			deleteActionRenderer.TextColumn = 0;
			deleteActionRenderer.Editable = true;
			deleteActionRenderer.Edited += new EditedHandler (DeleteActionEdited);
			
			updateActionRenderer.Model = storeActions;
			updateActionRenderer.TextColumn = 0;
			updateActionRenderer.Editable = true;
			updateActionRenderer.Edited += new EditedHandler (UpdateActionEdited);

			colName.PackStart (nameRenderer, true);
			colRefTable.PackStart (refTableRenderer, true);
			colIsColumnConstraint.PackStart (isColumnConstraintRenderer, true);
			colDeleteAction.PackStart (deleteActionRenderer, true);
			colUpdateAction.PackStart (updateActionRenderer, true);

			colName.AddAttribute (nameRenderer, "text", colNameIndex);
			colRefTable.AddAttribute (refTableRenderer, "text", colReferenceTableIndex);
			colIsColumnConstraint.AddAttribute (isColumnConstraintRenderer, "active", colIsColumnConstraintIndex);
			colDeleteAction.AddAttribute (deleteActionRenderer, "text", colDeleteActionIndex);			
			colUpdateAction.AddAttribute (updateActionRenderer, "text", colUpdateActionIndex);
			
			colIsColumnConstraint.Visible = false;
			listFK.AppendColumn (colName);
			listFK.AppendColumn (colRefTable);
			listFK.AppendColumn (colIsColumnConstraint);
			listFK.AppendColumn (colDeleteAction);
			listFK.AppendColumn (colUpdateAction);
			
			columnSelecter.ColumnToggled += new EventHandler (ColumnToggled);
			referenceColumnSelecter.ColumnToggled += new EventHandler (ReferenceColumnToggled);
			listFK.Selection.Changed += new EventHandler (SelectionChanged);
			
			ShowAll ();
		}
        public PropertyGridTable ()
        {
            Build();

            items = new List<TreeItem> ();
            pitems = new List<TreeItem> ();
            eitems = new List<EventItem> ();
            nulliter = new TreeIter ();
            sortgroup = true;

            var column1 = new TreeViewColumn ();
            column1.Sizing = TreeViewColumnSizing.Fixed;
            column1.FixedWidth = 100;
            column1.Resizable = true;
            column1.Title = "Name";

            var textCell1 = new CellRendererText ();
            textCell1.Underline = Pango.Underline.Single;
            column1.PackStart (textCell1, false);

            var textCell2 = new CellRendererText ();
            column1.PackStart (textCell2, false);

            var idCell = new CellRendererText ();
            idCell.Visible = false;
            column1.PackStart (idCell, false);

            treeview1.AppendColumn (column1);

            var column2 = new TreeViewColumn ();
            column2.Sizing = TreeViewColumnSizing.Fixed;
            column2.Resizable = true;
            column2.Title = "Value";

            var editTextCell = new CellRendererText ();

            editTextCell.Edited += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for(int i = 0;i < eitems.Count;i++)
                    {
                        if(eitems[i].id == id)
                        {
                            if(eitems[i].eventHandler != null)
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 4, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart (editTextCell, false);

            var editTextCell2 = new CellRendererText ();
            editTextCell2.Editable = true;
            editTextCell2.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new CollectionEditorDialog(model.GetValue(iter, 14).ToString(), window);
                    dialog.TransientFor = window;
                    if(dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.text);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 14, dialog.text);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editTextCell2, false);

            var editTextCell4 = new CellRendererText ();
            editTextCell4.Editable = true;
            editTextCell4.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new ColorPickerDialog(model.GetValue(iter, 15).ToString());
                    dialog.TransientFor = window;
                    if(dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.data);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 15, dialog.data);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editTextCell4, false);

            var editTextCell3 = new CellRendererText ();
            editTextCell3.Visible = false;
            column2.PackStart (editTextCell3, false);

            var comboCell = new CellRendererCombo ();
            comboCell.TextColumn = 0;
            comboCell.IsExpanded = true;
            comboCell.Editable = true;
            comboCell.HasEntry = false;
            comboCell.Edited += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for(int i = 0;i < eitems.Count;i++)
                    {
                        if(eitems[i].id == id)
                        {
                            if(eitems[i].eventHandler != null && args.NewText != null && args.NewText != "")
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 8, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart (comboCell , false);

            var editFilePathCell = new CellRendererText();
            editFilePathCell.Editable = true;
            editFilePathCell.EditingStarted += delegate(object o, EditingStartedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new FileChooserDialog("Add Content Folder",
                        window,
                        FileChooserAction.SelectFolder,
                        "Cancel", ResponseType.Cancel,
                        "Open", ResponseType.Accept);
                    dialog.SetCurrentFolder (window._controller.GetFullPath(model.GetValue(iter, 17).ToString()));

                    int responseid = dialog.Run();
                    string fileName = dialog.Filename;
                    dialog.Destroy();

                    if(responseid == (int)ResponseType.Accept)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    string pl = ((PipelineController)window._controller).ProjectLocation;
                                    if (!pl.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                                        pl += System.IO.Path.DirectorySeparatorChar;

                                    Uri folderUri = new Uri(pl);
                                    Uri pathUri = new Uri(fileName);

                                    string newpath = Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', System.IO.Path.DirectorySeparatorChar));

                                    var fwidget = new FalseWidget(newpath);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 17, newpath);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editFilePathCell, false);

            treeview1.AppendColumn (column2);

            column1.AddAttribute (textCell1, "text", 0);
            column1.AddAttribute (textCell1, "visible", 1);
            column1.AddAttribute (textCell2, "text", 2);
            column1.AddAttribute (textCell2, "visible", 3);
            column2.AddAttribute (editTextCell, "text", 4);
            column2.AddAttribute (editTextCell, "visible", 5);
            column2.AddAttribute (editTextCell, "editable", 6);
            column2.AddAttribute (comboCell, "model", 7);
            column2.AddAttribute (comboCell, "text", 8);
            column2.AddAttribute (comboCell, "editable", 9);
            column2.AddAttribute (comboCell, "visible", 10);
            column1.AddAttribute (idCell, "text", 11);
            column2.AddAttribute (editTextCell2, "text", 12);
            column2.AddAttribute (editTextCell2, "visible", 13);
            column2.AddAttribute (editTextCell3, "text", 14);
            column2.AddAttribute (editTextCell4, "text", 15);
            column2.AddAttribute (editTextCell4, "visible", 16);
            column2.AddAttribute (editFilePathCell, "text", 17);
            column2.AddAttribute (editFilePathCell, "visible", 18);

            listStore = new TreeStore (typeof (string), typeof(bool), typeof (string), typeof(bool), typeof (string), typeof(bool), typeof(bool), typeof(TreeStore), typeof(string), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(bool));
            treeview1.Model = listStore;
        }
		public XmlSchemasPanelWidget ()
		{
			Build ();
			
			//set up tree view for default schemas
			var textRenderer = new CellRendererText ();
			registeredSchemasStore = new ListStore (typeof (XmlSchemaCompletionData));
			registeredSchemasView.Model = registeredSchemasStore;
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Namespace"), textRenderer,
				(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
					((CellRendererText)cell).Text = GetSchema (iter).NamespaceUri;
				}
			);
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Type"), textRenderer,
				(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
					((CellRendererText)cell).Text = GetSchema (iter).ReadOnly? 
						  GettextCatalog.GetString ("Built in") 
						: GettextCatalog.GetString ("User schema");
			});
			
			registeredSchemasStore.SetSortFunc (0, SortSchemas);
			
			registeredSchemasStore.SetSortColumnId (0, SortType.Ascending);
			
			//update state of "remove" button depending on whether schema is read-only and anything's slected
			registeredSchemasView.Selection.Changed += delegate {
				var data = GetSelectedSchema ();
				registeredSchemasRemoveButton.Sensitive = (data != null && !data.ReadOnly);
			};
			registeredSchemasRemoveButton.Sensitive = false;
			
			//set up cells for associations
			var extensionTextRenderer = new CellRendererText ();
			extensionTextRenderer.Editable = true;
			var prefixTextRenderer = new CellRendererText ();
			prefixTextRenderer.Editable = true;
			
			var comboEditor = new CellRendererCombo ();
			registeredSchemasComboModel = new ListStore (typeof (string));
			comboEditor.Model = registeredSchemasComboModel;
			comboEditor.Mode = CellRendererMode.Editable;
			comboEditor.TextColumn = 0;
			comboEditor.Editable = true;
			comboEditor.HasEntry = false;
			
			//rebuild combo's model from default schemas whenever editing starts
			comboEditor.EditingStarted += delegate (object sender, EditingStartedArgs args) {
				registeredSchemasComboModel.Clear ();
				registeredSchemasComboModel.AppendValues (string.Empty);
				foreach (TreeIter iter in WalkStore (registeredSchemasStore))
					registeredSchemasComboModel.AppendValues (
						GetSchema (iter).NamespaceUri
					);
				args.RetVal = true;
				registeredSchemasComboModel.SetSortColumnId (0, SortType.Ascending);
			};
			
			//set up tree view for associations
			defaultAssociationsStore = new ListStore (typeof (string), typeof (string), typeof (string), typeof (bool));
			defaultAssociationsView.Model = defaultAssociationsStore;
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("File Extension"), extensionTextRenderer, "text", COL_EXT);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Namespace"), comboEditor, "text", COL_NS);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Prefix"), prefixTextRenderer, "text", COL_PREFIX);
			defaultAssociationsStore.SetSortColumnId (COL_EXT, SortType.Ascending);
			
			//editing handlers
			extensionTextRenderer.Edited += handleExtensionSet;
			comboEditor.Edited += (sender, args) => setAssocValAndMarkChanged (args.Path, COL_NS, args.NewText ?? "");
			prefixTextRenderer.Edited += delegate (object sender, EditedArgs args) {
				foreach (char c in args.NewText)
					if (!char.IsLetterOrDigit (c))
						//FIXME: give an error message?
						return;
				setAssocValAndMarkChanged (args.Path, COL_PREFIX, args.NewText);
			};
			
			//update state of "remove" button depending on whether anything's slected
			defaultAssociationsView.Selection.Changed += delegate {
				TreeIter iter;
				defaultAssociationsRemoveButton.Sensitive =
					defaultAssociationsView.Selection.GetSelected (out iter);
			};
			defaultAssociationsRemoveButton.Sensitive = false;
		}