internal void Add(string id, BaseItem item) { // Add full lookup, with filename. if (_lookup.ContainsKey(id)) { _windowManager.Logger.LogStr("Warning : Lookup reports duplicate : " + id); } else { _lookup.Add(id, item); } string[] bits = id.Split(BaseItem.FileSeperator); string shortId = null; if (bits.Length > 1) { shortId = bits[1]; } // Add short lookup, no filename. if (shortId != null) { if (_lookupShort.ContainsKey(shortId)) { _windowManager.Logger.Debug("Lookup reports duplicate shortId : " + shortId); } else { _lookupShort.Add(shortId, item); } } }
public JSClassItem(string itemPath, string fullName, BaseItem parent) { ItemPath = itemPath; //? Parent = parent; _Name = itemPath; _FullName = fullName; }
internal virtual void Add(BaseItem item) { Node parent = null; if (_tree.SelectedNode != null) parent = _tree.SelectedNode.Tag as Node; AddWithParent(item, parent, -1); }
public override void SetActiveItem(BaseItem item) { _activeItem = item; // For this diagram, when set active items is called, we just add // the item to the side panel. this._sidePanel.AddItem(item); if (_options.AutoRefresh) { this.RunTranslate(item); } }
public FavouritesNode(string text, string id, bool isFolder, BaseItem item) : base(text) { Id = id; IsFolder = isFolder; _item = item; if (item != null) { _icon = item.Icon; } }
public void Add(BaseItem item) { if (_currentItem == item) return; Node node = new Node(item.Name); _items.Add(node, item); if (_currentNode != null) { if (_currentNode.NextNode == null) { Node parent = _currentNode.Parent; if (parent != null) { parent.Nodes.Add(node); node.Parent = parent; } else { _model.Nodes.Add(node); } } else { Node parent = _currentNode; parent.Nodes.Add(node); node.Parent = parent; } } else { _model.Nodes.Add(node); } _currentItem = item; _currentNode = node; try { _ignoreSelect = true; _treeView.SelectedNode = _treeView.FindNode(_model.GetPath(node)); } finally { _ignoreSelect = false; } SetCaption(); }
public void AddItem(BaseItem item) { if (_rows.ContainsKey(item)) return; _grid.Rows.Add(new object[] { item.Name }); _grid.CommitEdit(DataGridViewDataErrorContexts.CurrentCellChange); DataGridViewRow row = _grid.Rows[_grid.Rows.Count - 1]; _rows.Add(item, row); row.Tag = item; row.Selected = true; _lookup.Add(item.GetID(), item); }
internal void RemoveWatch(BaseItem fileItem) { try { string path = Path.GetDirectoryName(fileItem.ItemPath); if (_watches.ContainsKey(fileItem.ItemPath)) { lock (_watchLock) { _watches.Remove(fileItem.ItemPath); } } } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Unexpected RemoveWatch error")) throw; } }
public virtual void SetActiveItem(BaseItem item) { if (item == null) { lblCaption.Text = string.Empty; lblPleaseWait.Text = string.Empty; } if (GetKind() == WindowPluginKind.ProjectItem) { // Use SetRefresh to refresh, so ignore calls with same item. if (item == _activeItem) return; } RunTranslate(item); }
public FolderItem(string itemPath, BaseItem parent) { ItemPath = itemPath; Parent = parent; }
private void _clickTimer_Tick(object sender, EventArgs e) { _clickTimer.Stop(); WF.MouseEventArgs me = _clickTimer.Tag as WF.MouseEventArgs; if (_cancelClick) { _cancelClick = false; return; } if (_activeItem == null) { return; } GD.Node node = GetObjectAt(me.X, me.Y) as GD.Node; BaseItem item = GetItem(node); if (me.Button == System.Windows.Forms.MouseButtons.Right) { if (item != null) { ShowContextMenu(me.X, me.Y); } else { if (_viewer.ZoomF == _defaultZoom) { // If we're fully zoomed out, then wherever we are, show the context menu. ShowContextMenu(me.X, me.Y); } else { // Reset zoom. Would be nice to go "back" instead, but can't see how. _viewer.ZoomF = _defaultZoom; } } } else if (Math.Abs(_downX - me.X) > 2 || Math.Abs(_downY - me.Y) > 2) { // It was a zoom operation, don't select the item. } else { if (WF.Control.ModifierKeys == WF.Keys.Control) { // Use control to handle local ignores. List <BaseItem> list = GetItemList(node); _sidePanel.ToggleList(list); if (_sidePanel.AutoRefreshCheckBox.Checked) { ForceRefresh(); } } else { _windowManager.SetActiveItem(item, this); } } }
public void SetActiveItem(BaseItem item, object sender) { if (item == null) return; if (_currentItem == item) return; _currentItem = item; // Find the treenode for this item, if available, and select it. // todo, goes via tags. issue with this not working? in jsfile? _treeView.SelectedNode = _treeView.FindNode(_model.GetPath(item)); if (_treeView.SelectedNode == null) { _windowManager.Logger.LogStr("Item no longer present in project"); } else { _treeView.ScrollTo(_treeView.SelectedNode); } }
internal void BroadcastItemChange(object sender, BaseItem item) { foreach (KeyValuePair<string, DockContent> pair in _windows) { if (pair.Value is IActiveItemViewer) { if (pair.Value is IWindowPlugin) { List<Type> types = (pair.Value as IWindowPlugin).GetHandledTypes(); if (item == null) { CachedSet(pair.Value, item, true); } else if (types != null && types.Contains(item.GetType())) { BaseItem currentItem = (pair.Value as IActiveItemViewer).GetActiveItem(); if (item != currentItem) { CachedSet(pair.Value, item, false); } } } } } }
private void ForceRefresh() { BaseItem item = _activeItem; _activeItem = null; RunTranslate(item); }
public JSMethodItem(string name, BaseItem parent) { ItemPath = name; //? Parent = parent; _Name = name; }
public void UpdateContextMenu(ContextMenuStrip contextMenu, BaseItem item) { // The context menu needs to be updated depending on the type of the item. if (_contextMenuIndex.ContainsKey(contextMenu)) { // We've been here already, so clear the menu below this point. int defaultCount = _contextMenuIndex[contextMenu]; for (int i = contextMenu.Items.Count - 1; i >= defaultCount; i--) { contextMenu.Items.RemoveAt(i); } } else { _contextMenuIndex.Add(contextMenu, contextMenu.Items.Count); } if (item == null) return; // The rest of the menu is context sensitive on the underlying BaseItem. Type type = item.GetType(); if (_contextOptions.ContainsKey(type)) { List<ToolStripMenuItem> list = _contextOptions[type]; if (list.Count > 0) { if (contextMenu.Items.Count > 0) contextMenu.Items.Add(new ToolStripSeparator()); foreach (ToolStripMenuItem mi in list) { contextMenu.Items.Add(mi); // Hang onto the item as well for context clicks. ((MenuInfo)mi.Tag).Item = item; } } } // Add any items that will always be at the end. if (contextMenu.Items.Count > 0) contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add(_addToFavouritesMI); // Make sure the tags are up to date for any menu function to use. (_addToFavouritesMI.Tag as MenuInfo).Item = item; }
public MenuInfo(IWindowPlugin plugin, BaseItem item) { Plugin = plugin; Item = item; }
private void ReadItem(BaseItem item, bool unload) { string ext = Path.GetExtension(item.Name); if (_windowManager.PluginManager.ParserPluginsByExt.ContainsKey(ext)) { try { List<IParserPlugin> list = _windowManager.PluginManager.ParserPluginsByExt[ext]; foreach (IParserPlugin plugin in list) { bool ok = plugin.ReadItem(item, unload); // Try another until we get a result. if (!ok) break; } } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Unexpected plugin error")) throw; } } else _windowManager.Logger.LogStr(string.Format("Error : accepted file, but no parser found for {0}", ext)); }
private void ActivateItem(BaseItem item) { if (item == null) { _windowManager.Logger.LogStr("Warning : ActivateItem : item is null"); return; } _currentItem = item; _windowManager.BroadcastItemChange(this, _currentItem); _statusManager.SetLeftCaption(_currentItem.GetID()); _model.Prioritise(_treeView.SelectedNode.Tag as BaseItem); }
public void SetRefresh(BaseItem item) { BaseItem baseItem = GetActiveItem(); if (baseItem == null) return; // We need access to the builder here :/ if (baseItem != null && _builders.ContainsKey(baseItem)) { BaseGraphBuilder builder = _builders[baseItem]; if (item != null) { string id = item.GetID(); // TODO - short id - added nodes do not have full ids. string[] bits = id.Split('?'); if (bits.Length > 1) { id = bits[1]; } if (builder.AddedNodes.ContainsKey(id)) { // We know we added this node, so we do a refresh ForceRefresh(); } } } }
protected void RunTranslate(BaseItem item) { try { _activeItem = item; _failed = false; _viewer.Visible = false; _builders.Clear(); lblCaption.Text = string.Empty; btnRefresh.Visible = false; if (item == null) { lblPleaseWait.Text = string.Empty; } else { lblPleaseWait.Text = "Please wait..."; } if (item != null && !GetHandledTypes().Contains(item.GetType())) return; // We're on the main thread. We're using proper threads instead of // BackgroundWorkers so we can safely abort them. (The async mode // of GViewer does not abort quickly enough) if (_thread != null && _thread.ThreadState != ThreadState.Stopped) { _timer.Change(Timeout.Infinite, 100); _thread.Abort(); _thread = null; } if (item != null) { _thread = new Thread(new ParameterizedThreadStart(thread_doWork)); _thread.IsBackground = true; _thread.Priority = ThreadPriority.AboveNormal; _logView.Debug("New thread:" + _thread.ManagedThreadId); _thread.Start(item); _timer.Change(0, 100); } } catch (Exception exc) { if (_logView.LogCatchAll(exc, "Unexpected plugin error")) throw; } }
internal void UpdatePluginItem(IWindowPlugin plugin, BaseItem item) { CachedSet(plugin as DockContent, item, false); }
public void SetActiveItem(BaseItem item, object sender) { // todo? get rid of this, passthrough to project manager, and then back. // better to have pm control it all anyhow? _projectBrowser.SetActiveItem(item, sender); }
private void CachedSetRefresh(DockContent window, BaseItem item) { // Add or get from local storage. if (!_activeItemsRefresh.ContainsKey(window)) { _activeItemsRefresh.Add(window, item); } else { _activeItemsRefresh[window] = item; } // Set immediately if visible, otherwise set in VisibleChanged. if (window.Visible) { SetItemRefreshInternal(window, item); } }
internal void BroadcastRefresh(object sender, BaseItem item) { foreach (KeyValuePair<string, DockContent> pair in _windows) { if (pair.Value is IActiveItemViewer) { if (pair.Value is IWindowPlugin) { CachedSetRefresh(pair.Value, item); } } } }
private void SetItemRefreshInternal(DockContent window, BaseItem item) { try { IActiveItemViewer viewer = window as IActiveItemViewer; IWindowPlugin plugin = window as IWindowPlugin; viewer.SetRefresh(item); } catch (Exception exc) { if (_logView.LogCatchAll(exc, "Unexpected plugin error")) throw; } }
private void CachedSet(DockContent window, BaseItem item, bool force) { // Add or get from local storage. if (!_activeItems.ContainsKey(window)) { _activeItems.Add(window, item); } else { _activeItems[window] = item; } // Set immediately if visible or force, otherwise set in VisibleChanged. if (force || window.Visible) { SetItemInternal(window, item); } }
public JSFileItem(string itemPath, BaseItem parent) : base(itemPath, parent) { }
private void SetItemInternal(DockContent window, BaseItem item) { try { IActiveItemViewer viewer = window as IActiveItemViewer; IWindowPlugin plugin = window as IWindowPlugin; // Always set a main window plugin, but only set others if they've changed. if (plugin.GetKind() == WindowPluginKind.MainWindow || viewer.GetActiveItem() != item) { viewer.SetActiveItem(item); } } catch (Exception exc) { if (_logView.LogCatchAll(exc, "Unexpected plugin error")) throw; } }
internal virtual void Remove(BaseItem item) { string id = item.GetID(); if (!_items.ContainsKey(id)) { _windowManager.Logger.LogStr("Warning : Favourite not found to remove : " + id); return; } RemoveInternal(id); }
private void AddWithParent(BaseItem item, Node parent, int idx) { string id = item.GetID(); if (_items.ContainsKey(id)) return; Node node = null; if (parent != null) { if (parent is FavouritesNode && (parent as FavouritesNode).IsFolder) { // Standard. node = new FavouritesNode(item.Name, id, false, item); if (idx == -1) parent.Nodes.Add(node); else parent.Nodes.Insert(idx, node); } else { // May be the "root" Node. node = new FavouritesNode(item.Name, id, false, item); if (parent.Parent != null) { if (idx == -1) parent.Parent.Nodes.Add(node); else parent.Parent.Nodes.Insert(idx, node); } else { if (idx == -1) _treeModel.Nodes.Add(node); else _treeModel.Nodes.Insert(idx, node); } } } else { node = new FavouritesNode(item.Name, id, false, item); _treeModel.Nodes.Add(node); } AddInternal(id, (FavouritesNode)node); }
private void thread_doWork(object sender) { try { BaseItem item = sender as BaseItem; _progress = 0; // Do our side of the work, using the builder subclass. BaseGraphBuilder builder = CreateBuilder(); float ratio = _viewer.Width / (float)(_viewer.Height - _toolheight); builder.SetServiceProvider(_serviceProvider, new DThreadProgress(thread_doProgress), _sidePanel, item, GetID(), ratio, _options); // Hang onto this for ignores. if (_builders.ContainsKey(item)) { _builders[item] = builder; } else { _builders.Add(item, builder); } try { try { builder.BeforeTranslate(); builder.Translate(); } finally { builder.AfterTranslate(); } } catch (ArgumentException exc) { _logView.LogExcStr(exc, "Failed during translate"); _failed = true; } catch (InvalidOperationException) { // Collection modified, fail gracefully, don't restart // automatically, as it could be a slow operation. _logView.LogStr("Failed during translate of:" + item.Name); _failed = true; } _logView.Debug("Visible false on UI thread"); try { if (this.IsHandleCreated) { this.Invoke((DSetVisible)SetViewerVisible, new object[] { false }); } } catch { } try { _logView.Debug("Layout on this thread"); // This fails a lot inside the viewer component. //_viewer.SetCalculatedLayout(layout); // More stable, still sometimes fails. object layout = _viewer.CalculateLayout(builder.Graph); } catch (InvalidOperationException) { _logView.LogStr("GLEE Layout error, try again with different aspect ratio"); _failed = true; } // This can take time itself, seconds for large graphs, and has to run on the // UI thread. _logView.Debug("Invoking SetGraph()"); if (this.IsHandleCreated) { this.Invoke((DSetGraph)SetGraph, new object[] { builder.Graph }); } // Stop the progress timer. _timer.Change(Timeout.Infinite, 100); _logView.Debug("Thread finished"); } catch (System.Threading.ThreadAbortException) { _failed = true; } catch (Exception exc) { if (_logView.LogCatchAll(exc, "Unexpected plugin error")) { throw; } _failed = true; } }