Пример #1
0
        private void NewWeblink()
        {
            bool newWeblink = false;

            if (_favorite == null)
            {
                _favorite  = Core.ResourceStore.BeginNewResource("Weblink");
                newWeblink = true;
            }
            else
            {
                _favorite.BeginUpdate();
            }
            try
            {
                string url = _URLBox.Text;
                _favorite.SetProp(Core.Props.Name, _nameBox.Text);
                _favorite.SetProp(FavoritesPlugin._propURL, url);
                int updateFreq = 0;
                if (_updateCheckBox.Checked)
                {
                    updateFreq = (int)_hoursBox.Value * 60 * 60;
                    int unitIndex = _unitBox.SelectedIndex;
                    if (unitIndex > 0)  // days or weeks
                    {
                        updateFreq *= 24;
                        if (unitIndex > 1)  // weeks
                        {
                            updateFreq *= 7;
                        }
                    }
                }
                _favorite.SetProp(FavoritesPlugin._propUpdateFreq, updateFreq);
                if (_parent != null)
                {
                    _favorite.AddLink(FavoritesPlugin._propParent, _parent);
                }
                Core.WorkspaceManager.AddToActiveWorkspace(_favorite);
            }
            finally
            {
                _favorite.EndUpdate();
            }
            if (newWeblink)
            {
                IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(_favorite);
                string           error   = null;
                if (profile != null && profile.CanCreate(_favorite, out error))
                {
                    profile.Create(_favorite);
                }
                else
                {
                    Core.UserInterfaceAP.QueueJob(new LineDelegate(DisplayError), error);
                }
                BookmarkService.ImmediateQueueWeblink(_favorite, _URLBox.Text);
            }
        }
Пример #2
0
        private void NewFolder()
        {
            IBookmarkService bookmarkService =
                (IBookmarkService)Core.PluginLoader.GetPluginService(typeof(IBookmarkService));
            IResource        newFolder = bookmarkService.FindOrCreateFolder(_parentFolder, "New Folder");
            IBookmarkProfile profile   = bookmarkService.GetOwnerProfile(newFolder);
            string           error     = null;

            if (profile != null && profile.CanCreate(newFolder, out error))
            {
                profile.Create(newFolder);
            }
            Core.WorkspaceManager.AddToActiveWorkspaceRecursive(newFolder);
            Core.UIManager.QueueUIJob(new ResourceDelegate(FavoritesPlugin._favoritesTreePane.SelectResource), newFolder);
            Core.UIManager.QueueUIJob(new ResourceDelegate(FavoritesPlugin._favoritesTreePane.EditResourceLabel), newFolder);
        }
Пример #3
0
        private void WeblinkOrFolderChanged(object sender, ResourcePropIndexEventArgs e)
        {
            IResource webLink = e.Resource;

            IPropertyChangeSet set = e.ChangeSet;
            int propLastModified   = Core.ResourceStore.PropTypes["LastModified"].Id;

            if (BookmarkService.DownloadMethod != 2 && webLink == _lastDisplayedWeblink &&
                ((set.IsPropertyChanged(propLastModified) && webLink.HasProp("Source")) ||
                 (set.IsPropertyChanged(Core.Props.LastError) && webLink.HasProp(Core.Props.LastError))))
            {
                // if the displayed web link has changed, redisplay it
                IResourceBrowser browser = Core.ResourceBrowser;
                if ((webLink == _favoritesTreePane.SelectedNode && Core.TabManager.CurrentTabId == "Web") ||
                    (browser.SelectedResources.Count == 1 && webLink == browser.SelectedResources[0]))
                {
                    Core.UserInterfaceAP.QueueJobAt(DateTime.Now.AddSeconds(1), "RedisplaySelectedResource", browser.RedisplaySelectedResource);
                }
            }

            string URL = webLink.GetPropText(_propURL);

            if (URL.Length > 0)
            {
                if (set.IsPropertyChanged(_propLastUpdated) || set.IsPropertyChanged(_propUpdateFreq))
                {
                    BookmarkService.QueueWeblink(webLink, URL, BookmarkService.BookmarkSynchronizationTime(webLink));
                }
                if (set.IsPropertyChanged(_propURL))
                {
                    BookmarkService.ImmediateQueueWeblink(webLink, URL);
                }
            }
            if (set.IsPropertyChanged(Core.PropIds.Name) || set.IsPropertyChanged(_propURL))
            {
                IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(webLink);
                string           error;
                if (profile != null && profile.CanCreate(webLink, out error))
                {
                    profile.Create(webLink);
                }
            }
        }
Пример #4
0
        public void ResourcesDropped(IResource targetResource, IResourceList droppedResources)
        {
            IBookmarkProfile targetProfile = _bookmarkService.GetOwnerProfile(targetResource);

            foreach (IResource dropRes in droppedResources)
            {
                IResource        oldParent     = BookmarkService.GetParent(dropRes);
                IBookmarkProfile sourceProfile = _bookmarkService.GetOwnerProfile(dropRes);
                if (sourceProfile == targetProfile)
                {
                    if (targetProfile != null)
                    {
                        targetProfile.Move(dropRes, targetResource, oldParent);
                    }
                    new ResourceProxy(dropRes).SetProp(_propParent, targetResource);
                }
                else
                {
                    if (sourceProfile != null)
                    {
                        sourceProfile.Delete(dropRes);
                    }
                    new ResourceProxy(dropRes).SetProp(_propParent, targetResource);
                    if (targetProfile != null)
                    {
                        targetProfile.Create(dropRes);
                    }
                }
                // the resource may have been moved from a parent which belonged to a workspace
                // to the top level (#5066)
                if (dropRes.Type == "Weblink")
                {
                    Core.WorkspaceManager.AddToActiveWorkspace(dropRes);
                }
                else
                {
                    Core.WorkspaceManager.AddToActiveWorkspaceRecursive(dropRes);
                }
            }
        }
Пример #5
0
 private void SubmitChanges()
 {
     if (!_weblink.IsTransient)
     {
         _weblink.BeginUpdate();
     }
     try
     {
         string annotation = _edtAnnotation.Text;
         if (annotation.Length == 0)
         {
             _weblink.DeleteProp("Annotation");
         }
         else
         {
             _weblink.SetProp("Annotation", annotation);
         }
         string name = _nameBox.Text;
         if (name != _weblink.GetPropText(Core.Props.Name))
         {
             _weblink.SetProp(Core.Props.Name, name);
             IBookmarkService service =
                 (IBookmarkService)Core.PluginLoader.GetPluginService(typeof(IBookmarkService));
             IBookmarkProfile profile = service.GetOwnerProfile(_weblink);
             string           error;
             if (profile != null && profile.CanCreate(_weblink, out error))
             {
                 profile.Create(_weblink);
             }
         }
     }
     finally
     {
         _weblink.EndUpdate();
     }
 }