Exemplo n.º 1
0
        public void create_a_selected_workspace_item()
        {
            var item = new WorkspaceItem("something", true);
            item.Children[0].ShouldBeOfType<CheckBox>().IsChecked.ShouldEqual(true);

            item.Selected.ShouldBeTrue();
        }
		public virtual object GetService (WorkspaceItem item, Type type)
		{
			if (type.IsInstanceOfType (this))
				return this;
			else
				return GetNext (item).GetService (item, type);
		}
Exemplo n.º 3
0
        public ExportSolutionDialog(WorkspaceItem item, FileFormat selectedFormat)
        {
            this.Build();

            labelNewFormat.Text = item.FileFormat.Name;

            formats = Services.ProjectService.FileFormats.GetFileFormatsForObject (item);
            foreach (FileFormat format in formats)
                comboFormat.AppendText (format.Name);

            int sel = Array.IndexOf (formats, selectedFormat);
            if (sel == -1) sel = 0;
            comboFormat.Active = sel;

            if (formats.Length < 2) {
                table.Remove (newFormatLabel);
                newFormatLabel.Destroy ();
                newFormatLabel = null;
                table.Remove (comboFormat);
                comboFormat.Destroy ();
                comboFormat = null;
            }

            //auto height
            folderEntry.WidthRequest = 380;
            Resize (1, 1);

            folderEntry.Path = item.ItemDirectory;
            UpdateControls ();
        }
Exemplo n.º 4
0
		public override void Initialize (OptionsDialog dialog, object dataObject)
		{
			base.Initialize (dialog, dataObject);
			
			solutionItem = dataObject as SolutionEntityItem;
			if (solutionItem != null)
				workspaceItem = solutionItem.ParentSolution;
			else
				workspaceItem = dataObject as WorkspaceItem;
		}
 string ProcessWorkspaceItems(WorkspaceItem[] items, ProcessWorkspaceItemDelegate process)
 {
     string result = String.Empty;
     int i = 0;
     int count = items.Length;
     foreach (WorkspaceItem item in items)
     {
         UpdateResult(ref result, process(item, ++i, count));
     }
     return result;
 }
Exemplo n.º 6
0
        public void should_expose_the_selected_value()
        {
            var item = new WorkspaceItem("something", false);
            item.Selected.ShouldBeFalse();

            item.Children[0].ShouldBeOfType<CheckBox>().IsChecked = true;
            item.Selected.ShouldBeTrue();

            item.Children[0].ShouldBeOfType<CheckBox>().IsChecked = false;
            item.Selected.ShouldBeFalse();
        }
 string PrintWorkspaceItem(WorkspaceItem item, int counter, int count)
 {
     int indentLevelOrig = Debug.IndentLevel;
     int indentLevel = Debug.IndentLevel;
     Debug.IndentLevel = ++indentLevel;
     Debug.WriteLine(item.ToString());
     Debug.IndentLevel = ++indentLevel;
     if (item.Descriptions != null)
     {
         int i = 1;
         int length = item.Descriptions.Length;
         Debug.WriteLine(String.Format("Descriptions[{0}]", length)); Logger.InfoFormat("Descriptions[{0}]", length);
         Debug.IndentLevel = ++indentLevel;
         foreach (WorkspaceItemDescription description in item.Descriptions)
         {
             Debug.WriteLine(String.Format("Description {0} of {1} => {2}", i, length, description));
             Logger.InfoFormat("\tDescription {0} of {1} => {2}", i++, length, description);
         }
         Debug.IndentLevel = --indentLevel;
     }
     if (item.Children != null)
     {
         int i = 1;
         int length = item.Children.Length;
         Debug.WriteLine(String.Format("Children[{0}]", length)); Logger.InfoFormat("Children[{0}]", length);
         Debug.IndentLevel = ++indentLevel;
         foreach (WorkspaceItem child in item.Children)
         {
             Debug.WriteLine(String.Format("Child {0} of {1} => {2}", i, length, child));
             Logger.InfoFormat("\tChild {0} of {1} => {2}", i++, length, child);
         }
         Debug.IndentLevel = --indentLevel;
     }
     if (item.Properties != null)
     {
         int i = 1;
         int length = item.Properties.Length;
         Debug.WriteLine(String.Format("Properties[{0}]", length)); Logger.InfoFormat("Properties[{0}]", length);
         Debug.IndentLevel = ++indentLevel;
         foreach (WorkspaceItemProperty property in item.Properties)
         {
             Debug.WriteLine(String.Format("Property {0} of {1} => {2}", i, length, property));
             Logger.InfoFormat("\tProperty {0} of {1} => {2}", i++, length, property);
         }
         Debug.IndentLevel = --indentLevel;
     }
     Debug.IndentLevel = indentLevelOrig;
     return String.Empty;
 }
		public WorkspaceItemChangeEventArgs (WorkspaceItem item, bool reloading): base (item)
		{
			this.reloading = reloading;
		}
Exemplo n.º 9
0
        public WorkspaceItem CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            WorkspaceItem workspaceItem = null;

            if (string.IsNullOrEmpty(type))
            {
                workspaceItem = new Solution();
            }
            else
            {
                Type workspaceItemType = addin.GetType(type, false);
                if (workspaceItemType != null)
                {
                    workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem;
                }

                if (workspaceItem == null)
                {
                    MessageService.ShowError(GettextCatalog.GetString("Can't create solution with type: {0}", type));
                    return(null);
                }
            }

            workspaceItem.Name = StringParserService.Parse(name, new string[, ] {
                { "ProjectName", projectCreateInformation.SolutionName }
            });

            workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name);

            ProjectCreateInformation localProjectCI;

            if (!string.IsNullOrEmpty(directory) && directory != ".")
            {
                localProjectCI = new ProjectCreateInformation(projectCreateInformation);

                localProjectCI.SolutionPath    = Path.Combine(localProjectCI.SolutionPath, directory);
                localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory);

                if (!Directory.Exists(localProjectCI.SolutionPath))
                {
                    Directory.CreateDirectory(localProjectCI.SolutionPath);
                }

                if (!Directory.Exists(localProjectCI.ProjectBasePath))
                {
                    Directory.CreateDirectory(localProjectCI.ProjectBasePath);
                }
            }
            else
            {
                localProjectCI = projectCreateInformation;
            }

            Solution solution = workspaceItem as Solution;

            if (solution != null)
            {
                for (int i = 0; i < entryDescriptors.Count; i++)
                {
                    ISolutionItemDescriptor solutionItem = entryDescriptors[i];

                    SolutionEntityItem info = solutionItem.CreateItem(localProjectCI, defaultLanguage);
                    entryDescriptors[i].InitializeItem(solution.RootFolder, localProjectCI, defaultLanguage, info);

                    IConfigurationTarget configurationTarget = info as IConfigurationTarget;
                    if (configurationTarget != null)
                    {
                        foreach (ItemConfiguration configuration in configurationTarget.Configurations)
                        {
                            bool flag = false;
                            foreach (SolutionConfiguration solutionCollection in solution.Configurations)
                            {
                                if (solutionCollection.Id == configuration.Id)
                                {
                                    flag = true;
                                }
                            }
                            if (!flag)
                            {
                                solution.AddConfiguration(configuration.Id, true);
                            }
                        }
                    }

                    solution.RootFolder.Items.Add(info);
                    if (startupProject == info.Name)
                    {
                        solution.StartupItem = info;
                    }
                }
            }

            return(workspaceItem);
        }
Exemplo n.º 10
0
        void OpenEvent(object sender, EventArgs e)
        {
            if (!btn_new.Sensitive)
            {
                return;
            }

            if (notebook.Page == 0)
            {
                if (!CreateProject())
                {
                    return;
                }

                Solution parentSolution = null;

                if (parentFolder == null)
                {
                    WorkspaceItem item = (WorkspaceItem)newItem;
                    parentSolution = item as Solution;
                    if (parentSolution != null)
                    {
                        if (parentSolution.RootFolder.Items.Count > 0)
                        {
                            currentEntry = parentSolution.RootFolder.Items [0] as SolutionItem;
                        }
                        parentFolder = parentSolution.RootFolder;
                    }
                }
                else
                {
                    SolutionItem item = (SolutionItem)newItem;
                    parentSolution = parentFolder.ParentSolution;
                    currentEntry   = item;
                }

                if (btn_new.Label == Gtk.Stock.GoForward)
                {
                    // There are features to show. Go to the next page
                    if (currentEntry != null)
                    {
                        try {
                            featureList.Fill(parentFolder, currentEntry, SolutionItemFeatures.GetFeatures(parentFolder, currentEntry));
                        }
                        catch (Exception ex) {
                            LoggingService.LogError(ex.ToString());
                        }
                    }
                    notebook.Page++;
                    btn_new.Label = Gtk.Stock.Ok;
                    return;
                }
            }
            else
            {
                // Already in fetatures page
                if (!featureList.Validate())
                {
                    return;
                }
            }

            // New combines (not added to parent combines) already have the project as child.
            if (!newSolution)
            {
                // Make sure the new item is saved before adding. In this way the
                // version control add-in will be able to put it under version control.
                if (currentEntry is SolutionEntityItem)
                {
                    // Inherit the file format from the solution
                    SolutionEntityItem eitem = (SolutionEntityItem)currentEntry;
                    eitem.FileFormat = parentFolder.ParentSolution.FileFormat;
                    IdeApp.ProjectOperations.Save(eitem);
                }
                parentFolder.AddItem(currentEntry, true);
            }

            if (notebook.Page == 1)
            {
                featureList.ApplyFeatures();
            }

            if (parentFolder != null)
            {
                IdeApp.ProjectOperations.Save(parentFolder.ParentSolution);
            }
            else
            {
                IdeApp.ProjectOperations.Save(newItem);
            }

            if (openSolution)
            {
                selectedItem.OpenCreatedSolution();
            }
            Respond(ResponseType.Ok);
        }
Exemplo n.º 11
0
		public static void Unload (WorkspaceItem item)
		{
			if (DecLoadCount (item) != 0)
				return;
			
			if (item is Workspace) {
				Workspace ws = (Workspace) item;
				foreach (WorkspaceItem it in ws.Items)
					Unload (it);
				ws.ItemAdded -= OnWorkspaceItemAdded;
				ws.ItemRemoved -= OnWorkspaceItemRemoved;
			}
			else if (item is Solution) {
				Solution solution = (Solution) item;
				foreach (Project project in solution.GetAllProjects ())
					Unload (project);
				solution.SolutionItemAdded -= OnSolutionItemAdded;
				solution.SolutionItemRemoved -= OnSolutionItemRemoved;
			}
		}
 public WorkspaceItemViewModel(WorkspaceItem pItem)
 {
     WorkspaceItem = pItem;
 }
 private void agtOnRegisterDraggedDataCompleted(WorkspaceItem workspaceSource, WorkspaceItem workspaceTarget)//private void agtOnRegisterDraggedDataCompleted(object sender, WorkspaceItemsEventArgs e)
 {
 }
Exemplo n.º 14
0
		protected virtual BuildResult Build (IProgressMonitor monitor, WorkspaceItem item, ConfigurationSelector configuration)
		{
			if (item is Solution)
				return Build (monitor, (Solution) item, configuration);
			return GetNext (item).RunTarget (monitor, item, ProjectService.BuildTarget, configuration);
		}
Exemplo n.º 15
0
		protected virtual bool GetNeedsBuilding (WorkspaceItem item, ConfigurationSelector configuration)
		{
			if (item is Solution)
				return GetNeedsBuilding ((Solution) item, configuration);
			return GetNext (item).GetNeedsBuilding ((IBuildTarget) item, configuration);
		}
Exemplo n.º 16
0
        public void should_remember_the_workspace_name()
        {
            var item = new WorkspaceItem("something", true);

            item.WorkspaceName.ShouldEqual("something");
        }
Exemplo n.º 17
0
 public void should_remember_the_workspace_name()
 {
     var item = new WorkspaceItem("something", true);
     item.WorkspaceName.ShouldEqual("something");
 }
Exemplo n.º 18
0
        public void should_put_the_workspace_name_in_the_label()
        {
            var item = new WorkspaceItem("something", true);

            item.Children[1].ShouldBeOfType <Label>().Content.ShouldEqual("something");
        }
Exemplo n.º 19
0
 public WorkspaceItemChangeEventArgs(WorkspaceItem item, bool reloading)
     : base(item)
 {
     this.reloading = reloading;
 }
        public async Task <int> Run(string[] arguments)
        {
            Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Gettext Update Tool"));
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("gettext-update [options] [project-file]");
                Console.WriteLine("--f --file:FILE   Project or solution file to build.");
                Console.WriteLine("--p --project:PROJECT  Name of the project to build.");
                Console.WriteLine();
                return(0);
            }

            if (file == null)
            {
                string[] files = Directory.GetFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        file = f;
                        break;
                    }
                }
                if (file == null)
                {
                    Console.WriteLine("Solution file not found.");
                    return(1);
                }
            }
            else if (!Services.ProjectService.IsWorkspaceItemFile(file))
            {
                Console.WriteLine("File '{0}' is not a project or solution.", file);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;

            WorkspaceItem centry = await Services.ProjectService.ReadWorkspaceItem(monitor, file);

            monitor.IgnoreLogMessages = false;

            Solution solution = centry as Solution;

            if (solution == null)
            {
                Console.WriteLine("File is not a solution: " + file);
                return(1);
            }

            if (project != null)
            {
                SolutionItem item = solution.FindProjectByName(project);

                if (item == null)
                {
                    Console.WriteLine("The project '" + project + "' could not be found in " + file);
                    return(1);
                }
                TranslationProject tp = item as TranslationProject;
                if (tp == null)
                {
                    Console.WriteLine("The project '" + item.FileName + "' is not a translation project");
                    return(1);
                }
                tp.UpdateTranslations(monitor);
            }
            else
            {
                foreach (TranslationProject p in solution.GetAllItems <TranslationProject>())
                {
                    p.UpdateTranslations(monitor);
                }
            }

            return(0);
        }
 public void DeleteWorkspaceItem(WorkspaceItem workspaceItem)
 {
     throw new NotImplementedException();
 }
 public String RegisterWorkspace(WorkspaceItem workspaceItem)
 {
     return WorkspaceBrowserDomainGenerator
         .RegisterMockWorkspace(workspaceItem);
 }
Exemplo n.º 23
0
		protected virtual bool SupportsTarget (WorkspaceItem item, string target)
		{
			if (item is Solution)
				return SupportsTarget ((Solution) item, target);
			else
				return GetNext (item).SupportsTarget ((IBuildTarget) item, target);
		}
Exemplo n.º 24
0
        public WorkspaceItemCreatedInformation CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            WorkspaceItem workspaceItem = null;

            if (string.IsNullOrEmpty(type))
            {
                workspaceItem = new Solution();
            }
            else
            {
                Type workspaceItemType = addin.GetType(type, false);
                if (workspaceItemType != null)
                {
                    workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem;
                }

                if (workspaceItem == null)
                {
                    MessageService.ShowError(GettextCatalog.GetString("Can't create solution with type: {0}", type));
                    return(null);
                }
            }

            workspaceItem.Name = StringParserService.Parse(name, new string[, ] {
                { "ProjectName", projectCreateInformation.SolutionName }
            });

            workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name);

            ProjectCreateInformation localProjectCI;

            if (!string.IsNullOrEmpty(directory) && directory != ".")
            {
                localProjectCI = new ProjectCreateInformation(projectCreateInformation);

                localProjectCI.SolutionPath    = Path.Combine(localProjectCI.SolutionPath, directory);
                localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory);

                if (!Directory.Exists(localProjectCI.SolutionPath))
                {
                    Directory.CreateDirectory(localProjectCI.SolutionPath);
                }

                if (!Directory.Exists(localProjectCI.ProjectBasePath))
                {
                    Directory.CreateDirectory(localProjectCI.ProjectBasePath);
                }
            }
            else
            {
                localProjectCI = projectCreateInformation;
            }

            var workspaceItemCreatedInfo = new WorkspaceItemCreatedInformation(workspaceItem);

            Solution solution = workspaceItem as Solution;

            if (solution != null)
            {
                for (int i = 0; i < entryDescriptors.Count; i++)
                {
                    ProjectCreateInformation entryProjectCI;
                    var entry = entryDescriptors[i] as ICustomProjectCIEntry;
                    if (entry != null)
                    {
                        entryProjectCI = entry.CreateProjectCI(localProjectCI);
                    }
                    else
                    {
                        entryProjectCI = localProjectCI;
                    }

                    var solutionItemDesc = entryDescriptors[i];

                    SolutionEntityItem info = solutionItemDesc.CreateItem(entryProjectCI, defaultLanguage);
                    if (info == null)
                    {
                        continue;
                    }

                    solutionItemDesc.InitializeItem(solution.RootFolder, entryProjectCI, defaultLanguage, info);

                    IConfigurationTarget configurationTarget = info as IConfigurationTarget;
                    if (configurationTarget != null)
                    {
                        foreach (ItemConfiguration configuration in configurationTarget.Configurations)
                        {
                            bool flag = false;
                            foreach (SolutionConfiguration solutionCollection in solution.Configurations)
                            {
                                if (solutionCollection.Id == configuration.Id)
                                {
                                    flag = true;
                                }
                            }
                            if (!flag)
                            {
                                solution.AddConfiguration(configuration.Id, true);
                            }
                        }
                    }

                    if ((info is Project) && (solutionItemDesc is ProjectDescriptor))
                    {
                        workspaceItemCreatedInfo.AddPackageReferenceForCreatedProject((Project)info, (ProjectDescriptor)solutionItemDesc);
                    }
                    solution.RootFolder.Items.Add(info);
                    if (startupProject == info.Name)
                    {
                        solution.StartupItem = info;
                    }
                }
            }

            if (!workspaceItem.FileFormat.CanWrite(workspaceItem))
            {
                // The default format can't write solutions of this type. Find a compatible format.
                FileFormat f = IdeApp.Services.ProjectService.FileFormats.GetFileFormatsForObject(workspaceItem).First();
                workspaceItem.ConvertToFormat(f, true);
            }

            return(workspaceItemCreatedInfo);
        }
Exemplo n.º 25
0
		protected virtual bool CanExecute (WorkspaceItem item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (item is Solution)
				return CanExecute ((Solution) item, context, configuration);
			else
				return GetNext (item).CanExecute ((IBuildTarget) item, context, configuration);
		}
Exemplo n.º 26
0
        public async Task QueryTest()
        {
            var testNumber = 123456;

            // Create a test workspace
            _workspaceItemOne = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a test patient
            _patientOne = await TestHelper.CreatePatientAsync(_testClassName, testNumber, Path.Combine("Becker^Matthew", "RD.dcm"));

            await TestHelper.DeleteWorkspacesAsync(_workspaceItemOne.Name);

            var json = await _proKnow.Requestor.GetAsync($"/user");

            var userItem = JsonSerializer.Deserialize <UserItem>(json);

            FilterParameters filterParams = new FilterParameters();

            filterParams.PageSize    = 1;
            filterParams.Types       = new string[] { "patient_read", "workspace_deleted" };
            filterParams.WorkspaceId = _workspaceItemOne.Id;
            var auditPage = await _proKnow.Audit.Query(filterParams);

            Assert.AreEqual(auditPage.Total, (uint)2);

            var patientItem = auditPage.Items[0];

            Assert.AreEqual(patientItem.Classification, "HTTP");
            Assert.AreEqual(patientItem.Method, "DELETE");
            Assert.AreEqual(patientItem.PatientId, null);
            Assert.AreEqual(patientItem.PatientMrn, null);
            Assert.AreEqual(patientItem.PatientName, null);
            Assert.AreEqual(patientItem.ResourceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.ResourceName, _workspaceItemOne.Name);
            Assert.AreEqual(patientItem.StatusCode, "200");
            Assert.AreEqual(patientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.UserName, userItem.Name);
            Assert.AreEqual(patientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.WorkspaceName, null);

            var audit2Page = await auditPage.Next();

            Assert.AreEqual(audit2Page.Total, (uint)2);

            var nextPatientItem = audit2Page.Items[0];

            Assert.AreEqual(nextPatientItem.Classification, "HTTP");
            Assert.AreEqual(nextPatientItem.Method, "GET");
            Assert.AreEqual(nextPatientItem.PatientId, $"{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.PatientMrn, "123456-Mrn");
            Assert.AreEqual(nextPatientItem.PatientName, "123456-Name");
            Assert.AreEqual(nextPatientItem.ResourceId, $"{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.ResourceName, "123456-Name");
            Assert.AreEqual(nextPatientItem.StatusCode, "200");
            Assert.AreEqual(nextPatientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}/patients/{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.UserName, userItem.Name);
            Assert.AreEqual(nextPatientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(nextPatientItem.WorkspaceName, $"{_workspaceItemOne.Name}");

            //Call Next() on auditPage to verify it still retrieves Page 2 data
            var audit2PageAgain = await auditPage.Next();

            Assert.AreEqual(audit2PageAgain.Total, (uint)2);

            var lastPatientItem = audit2PageAgain.Items[0];

            Assert.AreEqual(lastPatientItem.Classification, "HTTP");
            Assert.AreEqual(lastPatientItem.Method, "GET");
            Assert.AreEqual(lastPatientItem.PatientId, $"{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.PatientMrn, "123456-Mrn");
            Assert.AreEqual(lastPatientItem.PatientName, "123456-Name");
            Assert.AreEqual(lastPatientItem.ResourceId, $"{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.ResourceName, "123456-Name");
            Assert.AreEqual(lastPatientItem.StatusCode, "200");
            Assert.AreEqual(lastPatientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}/patients/{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.UserName, userItem.Name);
            Assert.AreEqual(lastPatientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(lastPatientItem.WorkspaceName, $"{_workspaceItemOne.Name}");
        }
        /// <summary>
        /// Event Handler for Assigning the WorkspaceItem to ListItem Property
        /// </summary>
        /// <param name="items"></param>
        private void AgtOnGetWorkspaceCompleted(IEnumerable <WorkspaceItem> items)// private void AgtOnGetWorkspaceCompleted(object sender, WorkspaceItemsEventArgs e)
        {
            //if (AddWorkspace != null && (!AddWorkspace._blnaddworkspace || !AddItem.Blnadditem))
            //{

            //if (WorkspaceMainView != null)
            //{
            //    //WorkspaceMainView.wsNavigator.wsTreeView
            //    WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItemsChild =
            //        new ObservableCollection<WorkspaceItem>(e.Items);

            //}
            //}
            //else
            //{
            var list = items;
            var data = new ObservableCollection <WorkspaceItem>();

            foreach (var item in list)
            {
                var info = new WorkspaceItem
                {
                    AdditionalInfoUri = item.AdditionalInfoUri,
                    Children          = item.Children,
                    DateModified      = item.DateModified,
                    Descriptions      = item.Descriptions,
                    Id         = item.Id,
                    IsFolder   = item.IsFolder,
                    ItemId     = item.ItemId,
                    ItemImage  = item.ItemImage,
                    ItemTitle  = item.ItemTitle,
                    ParentId   = item.ParentId,
                    Properties = item.Properties,
                    SortOrder  = item.SortOrder,
                    TypeId     = item.TypeId,
                    TypeImage  = item.TypeImage,
                    TypeTitle  = item.TypeTitle
                };
                //if (item.ItemImage != null)
                //{
                info.ItemImage = item.IsFolder || item.ItemImage.Count() == 0
                                             ? GetEmbeddedFile("Pms.WorkspaceBrowser.Resources", "CloseFolder.png")
                                             : item.ItemImage;
                //}
                data.Add(info);
            }

            EventBroker.RaiseLoadDetailView(new LoadDetailViewEventArgs {
                ListItem = data
            });
            EventBroker.RaiseSetWorkspaceChildItem(new LoadWorkspaceItemEventArgs {
                WorkspaceItems = data
            });
            if (SelectedWorkspace)
            {
                // EventBroker.RaiseSetWorkspaceChildItem(new LoadWorkspaceItemEventArgs { WorkspaceItems = data });
                WorkspaceItems[0].Children = data.ToArray();
                // EventBroker.RaiseLoadWorkspaceItem(new LoadWorkspaceItemEventArgs { WorkspaceItems = WorkspaceItems });
                PreviousListItem = new List <WorkspaceItem>();
                // PreviousListItem.Add(WorkspaceItems[0]);
                // EventBroker.RaiseGetPreviousListItem(new LoadWorkspaceItemEventArgs() { PreviousListItem = PreviousListItem });
                // WorkspaceItems = WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItems;
                //  WorkspaceItemsChild =
                //   new ObservableCollection<WorkspaceItem>(e.Items);
                // if (PreviousListItem.Count == 0)
                // {
                //  WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItems[0].Children = ListItem.ToArray();
                // WorkspaceItems = WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItems;
                // WorkspaceMainView.wsNavigator.wsTreeView.Vm.PreviousListItem.Add(WorkspaceItems[0]);
                // }
                SelectedWorkspace = false;
            }
            // ListItem = data;
            //ChildrenListItem = e.Item;
            //  if (View == List || View == null)
            //  BindListViewData();
            // else
            // BindDetailViewData();
            //if (WorkspaceMainView != null)
            //{
            //if (WorkspaceMainView.wsNavigator.wsTreeView._selected)
            //{
            //    WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItemsChild =
            //        new ObservableCollection<WorkspaceItem>(e.Items);
            //    if (WorkspaceMainView.wsNavigator.wsTreeView.Vm.PreviousListItem.Count == 0)
            //    {
            //        WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItems[0].Children = ListItem.ToArray();
            //        WorkspaceItems = WorkspaceMainView.wsNavigator.wsTreeView.WorkspaceItems;
            //        WorkspaceMainView.wsNavigator.wsTreeView.Vm.PreviousListItem.Add(WorkspaceItems[0]);
            //    }
            //}
            //}
            // }
        }
Exemplo n.º 28
0
 /****************************************************************/
 public WorkspaceItemView(WorkspaceItem value)
 {
     InitializeComponent();
     Item = value;
     Update(value);
 }
Exemplo n.º 29
0
		public void Export (WorkspaceItem item)
		{
			Export (item, null);
		}
Exemplo n.º 30
0
 /****************************************************************/
 void Update(WorkspaceItem value)
 {
     toolStripLabel1.Text = value.FileName;
     textBoxPath.Text     = value.ItemFilePath;
     textBoxComment.Text  = value.Comment;
 }
Exemplo n.º 31
0
        void RealOpenFile(FileOpenInformation openFileInfo)
        {
            FilePath         fileName;
            IProgressMonitor monitor = openFileInfo.ProgressMonitor;

            using (monitor)
            {
                Counters.OpenDocumentTimer.Trace("Checking file");

                string origName = openFileInfo.FileName;

                if (origName == null)
                {
                    monitor.ReportError(GettextCatalog.GetString("Invalid file name"), null);
                    return;
                }

                if (origName.StartsWith("file://"))
                {
                    fileName = new Uri(origName).LocalPath;
                }
                else
                {
                    fileName = origName;
                }

                if (!origName.StartsWith("http://"))
                {
                    fileName = fileName.FullPath;
                }

                //Debug.Assert(FileService.IsValidPath(fileName));
                if (FileService.IsDirectory(fileName))
                {
                    monitor.ReportError(GettextCatalog.GetString("{0} is a directory", fileName), null);
                    return;
                }
                // test, if file fileName exists
                if (!origName.StartsWith("http://"))
                {
                    // test, if an untitled file should be opened
                    if (!System.IO.Path.IsPathRooted(origName))
                    {
                        foreach (Document doc in Documents)
                        {
                            if (doc.Window.ViewContent.IsUntitled && doc.Window.ViewContent.UntitledName == origName)
                            {
                                doc.Select();
                                openFileInfo.NewContent = doc.Window.ViewContent;
                                return;
                            }
                        }
                    }
                    if (!File.Exists(fileName))
                    {
                        monitor.ReportError(GettextCatalog.GetString("File not found: {0}", fileName), null);
                        return;
                    }
                }

                foreach (Document doc in Documents)
                {
                    if (doc.FileName == fileName)
                    {
                        if (openFileInfo.BringToFront)
                        {
                            doc.Select();
                            IEditableTextBuffer ipos = doc.GetContent <IEditableTextBuffer> ();
                            if (openFileInfo.Line != -1 && ipos != null)
                            {
                                ipos.SetCaretTo(openFileInfo.Line, openFileInfo.Column != -1 ? openFileInfo.Column : 0, openFileInfo.HighlightCaretLine);
                            }
                        }
                        openFileInfo.NewContent = doc.Window.ViewContent;
                        return;
                    }
                }

                Counters.OpenDocumentTimer.Trace("Looking for binding");

                IDisplayBinding binding;

                if (openFileInfo.DisplayBinding != null)
                {
                    binding = openFileInfo.DisplayBinding;
                }
                else
                {
                    binding = DisplayBindingService.GetDefaultBinding(fileName, DesktopService.GetMimeTypeForUri(fileName));
                }

                if (binding != null)
                {
                    // When looking for the project to which the file belongs, look first
                    // in the active project, then the active solution, and so on
                    Project project = null;
                    if (IdeApp.ProjectOperations.CurrentSelectedProject != null)
                    {
                        if (IdeApp.ProjectOperations.CurrentSelectedProject.Files.GetFile(fileName) != null)
                        {
                            project = IdeApp.ProjectOperations.CurrentSelectedProject;
                        }
                    }
                    if (project == null && IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem != null)
                    {
                        project = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.GetProjectContainingFile(fileName);
                        if (project == null)
                        {
                            WorkspaceItem it = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.ParentWorkspace;
                            while (it != null && project == null)
                            {
                                project = it.GetProjectContainingFile(fileName);
                                it      = it.ParentWorkspace;
                            }
                        }
                    }
                    if (project == null)
                    {
                        project = IdeApp.Workspace.GetProjectContainingFile(fileName);
                    }

                    LoadFileWrapper fw = new LoadFileWrapper(workbench, binding, project, openFileInfo);
                    fw.Invoke(fileName);

                    Counters.OpenDocumentTimer.Trace("Adding to recent files");
                    DesktopService.RecentFiles.AddFile(fileName, project);
                }
                else
                {
                    try {
                        Counters.OpenDocumentTimer.Trace("Showing in browser");
                        DesktopService.OpenFile(fileName);
                    } catch (Exception ex) {
                        LoggingService.LogError("Error opening file: " + fileName, ex);
                        MessageService.ShowError(GettextCatalog.GetString("File '{0}' could not be opened", fileName));
                    }
                }
            }
        }
Exemplo n.º 32
0
        public static FileInfo CreateConfig(WorkspaceItem pWorkspaceItem)
        {
            var strSourceFile     = Settings.NewDirectoryPath + "/" + pWorkspaceItem.New.Name;
            var strNewProjectFile = Path.Combine(Settings.ProjectPath, Path.ChangeExtension(pWorkspaceItem.New.Name, ".mlt"));

            if (!Directory.Exists(Settings.ProjectPath))
            {
                throw new Exception("Unable to access " + Settings.ProjectPath);
            }
            //if(!File.Exists(strSourceFile)) { throw new Exception("Unable to find source file"); }
            if (File.Exists(strNewProjectFile))
            {
                throw new Exception("Project file already exists");
            }

            var objSpan          = pWorkspaceItem.New.Duration;
            var strDurationStart = "00:00:00.000";
            var strDurationEnd   = string.Format("{0}:{1}:{2}.{3}",
                                                 objSpan.Hours.ToString().PadLeft(2, '0'),
                                                 objSpan.Minutes.ToString().PadLeft(2, '0'),
                                                 objSpan.Seconds.ToString().PadLeft(2, '0'),
                                                 objSpan.Milliseconds.ToString().PadLeft(3, '0')
                                                 );

            var doc = new XDocument(
                new XDeclaration("1.0", "utf-8", "no"),
                new XElement("mlt",
                             new XAttribute("LC_NUMERIC", "C"),
                             new XAttribute("producer", "main_bin"),
                             new XElement("profile",
                                          new XAttribute("description", "automatic"),
                                          new XAttribute("width", pWorkspaceItem.New.Width),
                                          new XAttribute("height", pWorkspaceItem.New.Height),
                                          new XAttribute("display_aspect_num", pWorkspaceItem.New.Width),
                                          new XAttribute("display_aspect_den", pWorkspaceItem.New.Height)
                                          //new XAttribute("colorspace", "709")
                                          ),
                             new XElement("playlist",
                                          new XAttribute("id", "main_bin"),
                                          new XAttribute("autoclose", "1"),
                                          new XElement("property", new XAttribute("name", "xml_retain"))
            {
                Value = "1"
            }
                                          ),
                             //new XAttribute("width", pWorkspaceItem.New.Width),
                             //new XAttribute("height", pWorkspaceItem.New.Height),
                             //new XAttribute("progressive", "1"),
                             //new XAttribute("sample_aspect_num", "1"),
                             //new XAttribute("display_aspect_num", "1"),
                             //new XAttribute("display_aspect_den", "automatic"),
                             //new XAttribute("frame_rate_num", "automatic"),
                             //new XAttribute("frame_rate_den", "automatic"),
                             //new XAttribute("colorspace", "automatic"),
                             //width = "1280" height = "720"
                             //progressive = "1" sample_aspect_num = "1" sample_aspect_den = "1"
                             //display_aspect_num = "1280" display_aspect_den = "720"
                             //frame_rate_num = "401160000" frame_rate_den = "16599583" colorspace = "709" />
                             new XElement("producer",
                                          new XAttribute("id", "black"),
                                          new XAttribute("in", strDurationStart),
                                          new XAttribute("out", strDurationEnd),
                                          new XElement("property", new XAttribute("name", "length"))
            {
                Value = strDurationEnd
            },
                                          new XElement("property", new XAttribute("name", "eof"))
            {
                Value = "pause"
            },
                                          new XElement("property", new XAttribute("name", "resource"))
            {
                Value = "0"
            },
                                          new XElement("property", new XAttribute("name", "aspect_ratio"))
            {
                Value = "1"
            },
                                          new XElement("property", new XAttribute("name", "mlt_service"))
            {
                Value = "color"
            },
                                          new XElement("property", new XAttribute("name", "set.test_audio"))
            {
                Value = "0"
            }
                                          //new XElement("property", new XAttribute("name", "set.mlt_image_format")) { Value = "rgb24a" }
                                          ),
                             new XElement("playlist",
                                          new XAttribute("id", "background"),
                                          new XElement("entry",
                                                       new XAttribute("producer", "black"),
                                                       new XAttribute("in", strDurationStart),
                                                       new XAttribute("out", strDurationEnd)
                                                       )
                                          ),
                             new XElement("producer",
                                          new XAttribute("id", "producer0"),
                                          new XAttribute("in", strDurationStart),
                                          new XAttribute("out", strDurationEnd),
                                          new XElement("property", new XAttribute("name", "length"))
            {
                Value = strDurationEnd
            },
                                          new XElement("property", new XAttribute("name", "eof"))
            {
                Value = "pause"
            },
                                          new XElement("property", new XAttribute("name", "resource"))
            {
                Value = strSourceFile
            },
                                          new XElement("property", new XAttribute("name", "audio_index"))
            {
                Value = "1"
            },
                                          new XElement("property", new XAttribute("name", "video_index"))
            {
                Value = "0"
            },
                                          new XElement("property", new XAttribute("name", "mute_on_pause"))
            {
                Value = "0"
            },
                                          new XElement("property", new XAttribute("name", "mlt_service"))
            {
                Value = "avformat-novalidate"
            },
                                          new XElement("property", new XAttribute("name", "seekable"))
            {
                Value = "1"
            },
                                          new XElement("property", new XAttribute("name", "aspect_ratio"))
            {
                Value = "1"
            },
                                          new XElement("property", new XAttribute("name", "ignore_points"))
            {
                Value = "0"
            },
                                          new XElement("property", new XAttribute("name", "global_feed"))
            {
                Value = "1"
            },
                                          new XElement("property", new XAttribute("name", "xml"))
            {
                Value = "was here"
            }
                                          ),
                             new XElement("playlist",
                                          new XAttribute("id", "playlist0"),
                                          new XElement("entry",
                                                       new XAttribute("producer", "producer0"),
                                                       new XAttribute("in", strDurationStart),
                                                       new XAttribute("out", strDurationEnd)
                                                       )
                                          ),
                             new XElement("tractor",
                                          new XAttribute("id", "tractor0"),
                                          new XAttribute("global_feed", "1"),
                                          new XAttribute("in", strDurationStart),
                                          new XAttribute("out", strDurationEnd),
                                          new XElement("property", new XAttribute("name", "shotcut"))
            {
                Value = "1"
            },
                                          new XElement("track", new XAttribute("producer", "background")),
                                          new XElement("track", new XAttribute("producer", "playlist0")),
                                          new XElement("transition",
                                                       new XAttribute("id", "transition0"),
                                                       new XElement("property", new XAttribute("name", "a_track"))
            {
                Value = "0"
            },
                                                       new XElement("property", new XAttribute("name", "b_track"))
            {
                Value = "1"
            },
                                                       new XElement("property", new XAttribute("name", "mlt_service"))
            {
                Value = "mix"
            },
                                                       new XElement("property", new XAttribute("name", "always_active"))
            {
                Value = "1"
            },
                                                       new XElement("property", new XAttribute("name", "sum"))
            {
                Value = "1"
            }
                                                       ),
                                          new XElement("transition",
                                                       new XAttribute("id", "transition1"),
                                                       new XElement("property", new XAttribute("name", "a_track"))
            {
                Value = "0"
            },
                                                       new XElement("property", new XAttribute("name", "b_track"))
            {
                Value = "1"
            },
                                                       new XElement("property", new XAttribute("name", "version"))
            {
                Value = "0.9"
            },
                                                       new XElement("property", new XAttribute("name", "mlt_service"))
            {
                Value = "frei0r.cairoblend"
            },
                                                       new XElement("property", new XAttribute("name", "disable"))
            {
                Value = "1"
            }
                                                       )
                                          )
                             )
                );

            var builder = new StringBuilder();

            using (TextWriter writer = new StringWriter(builder)) {
                doc.Save(writer);
            }
            File.WriteAllText(strNewProjectFile, builder.ToString().Replace("utf-16", "utf-8"));
            return(new FileInfo(strNewProjectFile));
        }
Exemplo n.º 33
0
        /// <summary>
        ///  Event Handler for Assigning the WorkspaceItem to ListItem Property
        /// </summary>
        /// <param name="action"></param>
        private void OnGetWorkspaceCompleted(WorkspaceItemResult <WorkspaceItem> action)
        {
            try
            {
                if (action.Items == null)
                {
                    return;
                }

                var list = action.Items;
                var data = new ObservableCollection <WorkspaceItem>();

                foreach (var item in list)
                {
                    var info = new WorkspaceItem
                    {
                        AdditionalInfoUri = item.AdditionalInfoUri,
                        Children          = item.Children,
                        DateModified      = item.DateModified,
                        Descriptions      = item.Descriptions,
                        Id         = item.Id,
                        IsFolder   = item.IsFolder,
                        ItemId     = item.ItemId,
                        ItemImage  = item.ItemImage,
                        ItemTitle  = item.ItemTitle,
                        ParentId   = item.ParentId,
                        Properties = item.Properties,
                        SortOrder  = item.SortOrder,
                        TypeId     = item.TypeId,
                        TypeImage  = item.TypeImage,
                        TypeTitle  = item.TypeTitle
                    };
                    #region "Binding Image"
                    //if (item.ItemImage != null)
                    //{
                    //    info.ItemImage = item.IsFolder || item.ItemImage.Count() == 0
                    //                         ? Constants.GetEmbeddedFile("Pms.ManageWorkspaces.Resources", "CloseFolder.png")
                    //                         : item.ItemImage;
                    //}
                    #endregion
                    data.Add(info);
                }

                EventBroker.RaiseLoadDetailView(new LoadDetailViewEventArgs {
                    ListItem = data
                });

                //EventBroker.RaiseSetWorkspaceChildItem(new LoadWorkspaceItemEventArgs { WorkspaceItems = data });
                //EventBroker.RaiseLoadDetailView(new LoadDetailViewEventArgs { ListItem = data });
                //EventBroker.RaiseSetWorkspaceChildItem(new LoadWorkspaceItemEventArgs { WorkspaceItems = data });
                if (SelectedWorkspace)
                {
                    WorkspaceItems[0].Children = data.ToArray();
                    PreviousListItem           = new List <WorkspaceItem>();
                    SelectedWorkspace          = false;
                    if (!Istreeviewselected)
                    {
                        WorkspaceBrowserMainViewViewModel.CurrentListItem = WorkspaceItems[0];
                        Istreeviewselected = true;
                    }
                }

                #region "Unused code- need to check"
                #endregion
                if (Child)
                {
                    EventBroker.RaiseLoadChild(new LoadDetailViewEventArgs {
                        ChildItems = data.ToList()
                    });
                    Child = false;
                }
                else
                {
                    //  EventBroker.RaiseLoadDetailView(new LoadDetailViewEventArgs { ListItem = data });// need to check
                    EventBroker.RaiseSetWorkspaceChildItem(new LoadWorkspaceItemEventArgs {
                        WorkspaceItems = data
                    });
                }
            }
            finally
            {
                FinishRefreshState();
                // if (WorkspaceItems != null)
                //EventBroker.RaiseLoadWorkspaceItemCount(new LoadDetailViewEventArgs() { WorkspaceItemCount = WorkspaceItems.Count });
                //Mouse.OverrideCursor = null; //need to ch
            }
        }
Exemplo n.º 34
0
        FilePath GetUserTasksFilename(WorkspaceItem item)
        {
            FilePath combinePath = item.FileName.ParentDirectory;

            return(combinePath.Combine(item.FileName.FileNameWithoutExtension + ".usertasks"));
        }
		public WorkspaceItemEventArgs (WorkspaceItem item)
		{
			this.item = item;
		}
Exemplo n.º 36
0
        /// <param name='newItem'>
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse <string> > UpsertWithHttpMessagesAsync(WorkspaceItem newItem = default(WorkspaceItem), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("newItem", newItem);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "Upsert", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "v2/items").ToString();
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PUT");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (newItem != null)
            {
                _requestContent      = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(newItem, Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 202 && (int)_statusCode != 400)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                if (_httpResponse.Content != null)
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                else
                {
                    _responseContent = string.Empty;
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse <string>();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            // Deserialize Response
            if ((int)_statusCode == 400)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject <string>(_responseContent, Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
Exemplo n.º 37
0
 public WorkspaceItemDescriptor(WorkspaceItem item)
 {
     this.item = item;
 }
 public WorkspaceItemUpdate(WorkspaceItem pWorkpaceItem, WorkspaceAction pAction)
 {
     WorkspaceItem = pWorkpaceItem;
     Action        = pAction;
 }
Exemplo n.º 39
0
 public void should_put_the_workspace_name_in_the_label()
 {
     var item = new WorkspaceItem("something", true);
     item.Children[1].ShouldBeOfType<Label>().Content.ShouldEqual("something");
 }
Exemplo n.º 40
0
        /// <summary>
        /// Show "Add Item" Screen
        /// </summary>
        /// <param name="descriptionListItem"></param>
        /// <param name="workspaceItemProperties"></param>
        /// <param name="currentItem"></param>
        /// <param name="processFrom"></param>
        public static void ShowAddItemScreen(IEnumerable <WorkspaceItemDescription> descriptionListItem, IEnumerable <WorkspaceItemProperty> workspaceItemProperties, WorkspaceItem currentItem, string processFrom)
        {
            AddItemViewModel addItemVm = GetAddItemViewModel();

            switch (processFrom)
            {
            case Constants.ViewNames.ModifyDesc:
                addItemVm.Reset();
                addItemVm.DescriptionListItem = descriptionListItem;
                addItemVm.CurrentItem         = currentItem;
                break;

            case Constants.ViewNames.ModifyProperty:
                addItemVm.Reset();
                addItemVm.WorkspaceItemProperties = workspaceItemProperties;
                addItemVm.CurrentItem             = currentItem;
                break;

            case Constants.ViewNames.ModifyItem:
                addItemVm.Reset();
                addItemVm.DescriptionListItem     = descriptionListItem;
                addItemVm.WorkspaceItemProperties = workspaceItemProperties;
                addItemVm.CurrentItem             = currentItem;
                break;

            case Constants.ViewNames.AddItem:
                addItemVm.Reset();
                break;
            }


            addItemVm.HandleIsEnableProperty(processFrom);
            var addItem = new AddItem();

            addItem.Initialize(addItemVm);
            addItem.ShowDialog();
        }
Exemplo n.º 41
0
		public override object GetService (WorkspaceItem item, Type type)
		{
			return item.OnGetService (type);
		}
Exemplo n.º 42
0
 ///<summary>
 /// Event Handler for the Back Button Click
 ///</summary>
 private void BtnBackClickEvent()
 {
     Mouse.OverrideCursor = Cursors.Wait;
     IsRefreshing         = true;
     if (PreviousListItem != null)
     {
         if (PreviousListItem.Count > 1)
         {
             for (int i = 0; i <= PreviousListItem.Count; i++)
             {
                 var child1 = PreviousListItem[PreviousListItem.Count - 2].Children;
                 var child2 = PreviousListItem[PreviousListItem.Count - 1].Children;
                 if ((child1 != null) && (child1.Count() > 0) && (child2 != null) && (child2.Count() > 0))
                 {
                     if (PreviousListItem[PreviousListItem.Count - 2].Children[0].Id ==
                         PreviousListItem[PreviousListItem.Count - 1].Children[0].Id)
                     {
                         if (PreviousListItem.Count > 2)
                         {
                             PreviousListItem.RemoveAt(PreviousListItem.Count - 1);
                         }
                     }
                 }
             }
             if (PreviousListItem.Count > 1)
             {
                 if (PreviousListItem[PreviousListItem.Count - 2].Children != null)
                 {
                     var data = new ObservableCollection <WorkspaceItem>();
                     foreach (var item in PreviousListItem[PreviousListItem.Count - 2].Children.ToList())
                     {
                         var info = new WorkspaceItem
                         {
                             AdditionalInfoUri = item.AdditionalInfoUri,
                             Children          = item.Children,
                             DateModified      = item.DateModified,
                             Descriptions      = item.Descriptions,
                             Id         = item.Id,
                             IsFolder   = item.IsFolder,
                             ItemId     = item.ItemId,
                             ItemImage  = item.ItemImage,
                             ItemTitle  = item.ItemTitle,
                             ParentId   = item.ParentId,
                             Properties = item.Properties,
                             SortOrder  = item.SortOrder,
                             TypeId     = item.TypeId,
                             TypeImage  = item.TypeImage,
                             TypeTitle  = item.TypeTitle
                         };
                         if (item.ItemImage != null)
                         {
                             info.ItemImage = item.IsFolder || item.ItemImage.Count() == 0 ? Constants.GetEmbeddedFile("Pms.ManageWorkspaces.Resources", "CloseFolder.png") : item.ItemImage;
                         }
                         data.Add(info);
                     }
                     Mouse.OverrideCursor = null;
                     ItemId = PreviousListItem[PreviousListItem.Count - 2].Children[0].ItemId;
                     EventBroker.RaiseGetId(new LoadWorkspaceItemEventArgs {
                         ItemId = ItemId
                     });
                     PreviousListItem.RemoveAt(PreviousListItem.Count - 1);
                     EventBroker.RaiseGetPreviousListItem(new LoadWorkspaceItemEventArgs {
                         PreviousListItem = PreviousListItem
                     });
                     EventBroker.RaiseLoadDetailView(new LoadDetailViewEventArgs {
                         ListItem = data
                     });
                 }
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
         }
     }
 }
Exemplo n.º 43
0
		protected virtual void Clean (IProgressMonitor monitor, WorkspaceItem item, ConfigurationSelector configuration)
		{
			if (item is Solution)
				Clean (monitor, (Solution) item, configuration);
			else
				GetNext (item).RunTarget (monitor, item, ProjectService.CleanTarget, configuration);
		}
        public void StartAnalysis(WorkspaceItem solution)
        {
            lock (_lock) {
                tokenSource    = new CancellationTokenSource();
                processedFiles = new ConcurrentDictionary <string, object> ();
                ThreadPool.QueueUserWorkItem(delegate {
                    State = AnalysisState.Running;

                    using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor("Analyzing solution", null, false)) {
                        AnalysisState oldState;
                        AnalysisState newState;
                        try {
                            int work = 0;
                            foreach (var project in solution.GetAllProjects())
                            {
                                work += project.Files.Count(f => f.BuildAction == BuildAction.Compile);
                            }
                            monitor.BeginTask("Analyzing solution", work);
                            foreach (var project in solution.GetAllProjects())
                            {
                                if (tokenSource.IsCancellationRequested)
                                {
                                    break;
                                }
                                var content = TypeSystemService.GetProjectContext(project);
                                Parallel.ForEach(project.Files, file => {
                                    try {
                                        AnalyzeFile(file, content);
                                        monitor.Step(1);
                                    } catch (Exception ex) {
                                        LoggingService.LogError("Error while running code issue on:" + file.Name, ex);
                                    }
                                });
                            }
                            // Cleanup
                            lock (_lock) {
                                oldState = state;
                                if (tokenSource.IsCancellationRequested)
                                {
                                    newState = AnalysisState.Cancelled;
                                }
                                else
                                {
                                    newState = AnalysisState.Completed;
                                }
                                state       = newState;
                                tokenSource = null;
                            }
                            OnAnalysisStateChanged(new AnalysisStateChangeEventArgs(oldState, newState));
                        } catch (Exception e) {
                            lock (_lock) {
                                oldState    = state;
                                state       = AnalysisState.Error;
                                newState    = state;
                                tokenSource = null;
                            }
                            OnAnalysisStateChanged(new AnalysisStateChangeEventArgs(oldState, newState));
                            // Do not rethrow in a thread pool
                            MessageService.ShowException(e);
                        }
                    }
                });
            }
        }
Exemplo n.º 45
0
		protected virtual void Execute (IProgressMonitor monitor, WorkspaceItem item, ExecutionContext context, ConfigurationSelector configuration)
		{
			if (item is Solution)
				Execute (monitor, (Solution) item, context, configuration);
			else
				GetNext (item).Execute (monitor, (IBuildTarget) item, context, configuration);
		}
Exemplo n.º 46
0
		static FilePath GetUserTasksFilename (WorkspaceItem item)
		{
			FilePath combinePath = item.FileName.ParentDirectory;
			return combinePath.Combine (item.FileName.FileNameWithoutExtension + ".usertasks");
		}
Exemplo n.º 47
0
		protected virtual IEnumerable<ExecutionTarget> GetExecutionTargets (WorkspaceItem item, ConfigurationSelector configuration)
		{
			if (item is Solution)
				return GetExecutionTargets ((Solution) item, configuration);
			else
				return GetNext (item).GetExecutionTargets ((IBuildTarget) item, configuration);
		}
Exemplo n.º 48
0
		public static void Load (WorkspaceItem item)
		{
			if (IncLoadCount (item) != 1)
				return;
			
			lock (databases) {
				if (item is Workspace) {
					Workspace ws = (Workspace) item;
					foreach (WorkspaceItem it in ws.Items)
						Load (it);
					ws.ItemAdded += OnWorkspaceItemAdded;
					ws.ItemRemoved += OnWorkspaceItemRemoved;
				}
				else if (item is Solution) {
					Solution solution = (Solution) item;
					foreach (Project project in solution.GetAllProjects ())
						Load (project);
					// Refresh the references of all projects. This is necessary because
					// some project may have been loaded before the projects their reference,
					// in which case those references are not properly registered.
					foreach (Project project in solution.GetAllProjects ()) {
						ProjectDom dom = GetProjectDom (project);
						// referenced by main project - prevents the removal if a project is referenced one time inside the solution
						// and the project that references it is reloaded.
						dom.ReferenceCount++; 
						if (dom != null)
							dom.UpdateReferences ();
					}
					solution.SolutionItemAdded += OnSolutionItemAdded;
					solution.SolutionItemRemoved += OnSolutionItemRemoved;
				}
			}
		}
Exemplo n.º 49
0
		protected virtual void SetNeedsBuilding (WorkspaceItem item, bool val, ConfigurationSelector configuration)
		{
			if (item is Solution)
				SetNeedsBuilding ((Solution) item, val, configuration);
			else
				GetNext (item).SetNeedsBuilding ((IBuildTarget) item, val, configuration);
		}
Exemplo n.º 50
0
		internal void InternalWriteWorkspaceItem (IProgressMonitor monitor, string file, WorkspaceItem item)
		{
			string newFile = WriteFile (monitor, file, item, item.FileFormat);
			if (newFile != null)
				item.FileName = newFile;
			else
				throw new InvalidOperationException ("FileFormat not provided for workspace item '" + item.Name + "'");
		}
Exemplo n.º 51
0
		public virtual void Save (IProgressMonitor monitor, WorkspaceItem item)
		{
			GetNext (item).Save (monitor, item);
		}
 internal void Update(WorkspaceItem pWorkspaceItem)
 {
     WorkspaceItem = pWorkspaceItem;
     OnPropertyChanged("");
 }
Exemplo n.º 53
0
		void LoadWorkspaceItemContents (WorkspaceItem wob)
		{
			foreach (var sln in wob.GetAllSolutions ())
				LoadSolutionContents (sln);
		}
Exemplo n.º 54
0
 public WorkspaceItemCreatedInformation(WorkspaceItem item)
 {
     WorkspaceItem = item;
 }
Exemplo n.º 55
0
		public static void Unload (WorkspaceItem item)
		{
			if (DecLoadCount (item) != 0)
				return;
			
			if (item is Workspace) {
				Workspace ws = (Workspace) item;
				foreach (WorkspaceItem it in ws.Items)
					Unload (it);
				ws.ItemAdded -= OnWorkspaceItemAdded;
				ws.ItemRemoved -= OnWorkspaceItemRemoved;
			}
			else if (item is Solution) {
				Solution solution = (Solution) item;
				foreach (Project project in solution.GetAllProjects ()) {
					ProjectDom dom = GetProjectDom (project);
					if (dom != null) {
						dom.ReferenceCount--;
						Unload (project);
					}
				}
				solution.SolutionItemAdded -= OnSolutionItemAdded;
				solution.SolutionItemRemoved -= OnSolutionItemRemoved;
			}
		}
Exemplo n.º 56
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='newItem'>
 /// </param>
 public static string Edit(this IWorkspaceItemsService operations, WorkspaceItem newItem = default(WorkspaceItem))
 {
     return(operations.EditAsync(newItem).GetAwaiter().GetResult());
 }
Exemplo n.º 57
0
		public override void Save (IProgressMonitor monitor, WorkspaceItem entry)
		{
			entry.OnSave (monitor);
		}
Exemplo n.º 58
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='newItem'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <string> EditAsync(this IWorkspaceItemsService operations, WorkspaceItem newItem = default(WorkspaceItem), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.EditWithHttpMessagesAsync(newItem, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 59
0
		public void Export (WorkspaceItem item, FileFormat format)
		{
			ExportSolutionDialog dlg = new ExportSolutionDialog (item, format);
			
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true)) {
						Services.ProjectService.Export (monitor, item.FileName, dlg.TargetFolder, dlg.Format);
					}
				}
			} finally {
				dlg.Destroy ();
			}
		}
Exemplo n.º 60
0
        public void StartAnalysis(WorkspaceItem solution)
        {
            lock (_lock) {
                tokenSource = new CancellationTokenSource();
                ThreadPool.QueueUserWorkItem(delegate {
                    State = AnalysisState.Running;

                    using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor("Analyzing solution", null, false)) {
                        int work = 0;
                        foreach (var project in solution.GetAllProjects())
                        {
                            work += project.Files.Count(f => f.BuildAction == BuildAction.Compile);
                        }
                        monitor.BeginTask("Analyzing solution", work);
                        var processedFiles = new ConcurrentDictionary <string, object> ();
                        foreach (var project in solution.GetAllProjects())
                        {
                            if (tokenSource.IsCancellationRequested)
                            {
                                break;
                            }
                            var content = TypeSystemService.GetProjectContext(project);
                            Parallel.ForEach(project.Files, file => {
                                var me    = new object();
                                var owner = processedFiles.AddOrUpdate(file.Name, me, (key, old) => old);
                                if (me != owner)
                                {
                                    return;
                                }
                                if (file.BuildAction != BuildAction.Compile || tokenSource.IsCancellationRequested)
                                {
                                    return;
                                }

                                var editor   = TextFileProvider.Instance.GetReadOnlyTextEditorData(file.FilePath);
                                var document = TypeSystemService.ParseFile(project, editor);
                                if (document == null)
                                {
                                    return;
                                }

                                var compilation = content.AddOrUpdateFiles(document.ParsedFile).CreateCompilation();
                                var resolver    = new CSharpAstResolver(compilation, document.GetAst <SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile);
                                var context     = document.CreateRefactoringContextWithEditor(editor, resolver, tokenSource.Token);

                                CodeIssueProvider[] codeIssueProvider = RefactoringService.GetInspectors(editor.MimeType).ToArray();
                                Parallel.ForEach(codeIssueProvider, (provider) => {
                                    var severity = provider.GetSeverity();
                                    if (severity == Severity.None || tokenSource.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    try {
                                        foreach (var issue in provider.GetIssues(context, tokenSource.Token))
                                        {
                                            AddIssue(file, provider, issue);
                                        }
                                    } catch (OperationCanceledException) {
                                        // The operation was cancelled, no-op as the user-visible parts are
                                        // handled elsewhere
                                    } catch (Exception ex) {
                                        LoggingService.LogError("Error while running code issue on:" + editor.FileName, ex);
                                    }
                                });
                                //lastMime = editor.MimeType;
                                monitor.Step(1);
                            });
                        }
                        // Cleanup
                        AnalysisState oldState;
                        AnalysisState newState;
                        lock (_lock) {
                            oldState = state;
                            if (tokenSource.IsCancellationRequested)
                            {
                                newState = AnalysisState.Cancelled;
                            }
                            else
                            {
                                newState = AnalysisState.Completed;
                            }
                            state       = newState;
                            tokenSource = null;
                        }
                        OnAnalysisStateChanged(new AnalysisStateChangeEventArgs(oldState, newState));
                        monitor.EndTask();
                    }
                });
            }
        }