1 /*******************************************************************************
2 * Copyright (C) 2010, 2013 Dariusz Luksza <dariusz@luksza.org> and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
10 *******************************************************************************/
11 package org
.eclipse
.egit
.ui
.internal
.synchronize
.model
;
13 import java
.io
.IOException
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.eclipse
.egit
.core
.Activator
;
18 import org
.eclipse
.egit
.core
.synchronize
.dto
.GitSynchronizeData
;
19 import org
.eclipse
.egit
.core
.synchronize
.dto
.GitSynchronizeDataSet
;
22 * Root of all model objects.
24 public class GitModelRoot
{
26 private final GitSynchronizeDataSet gsds
;
28 private GitModelObject
[] children
;
33 public GitModelRoot(GitSynchronizeDataSet gsds
) {
38 * @return git synchronization data
40 public GitSynchronizeDataSet
getGsds() {
47 public GitModelObject
[] getChildren() {
48 return getChildrenImpl();
52 * Disposes all nested resources
54 public void dispose() {
58 private GitModelObject
[] getChildrenImpl() {
59 List
<GitModelObject
> result
= new ArrayList
<>();
61 if (gsds
.size() == 1) {
62 GitSynchronizeData gsd
= gsds
.iterator().next();
63 GitModelRepository repoModel
= new GitModelRepository(gsd
);
65 return repoModel
.getChildren();
67 for (GitSynchronizeData data
: gsds
) {
68 GitModelRepository repoModel
= new GitModelRepository(data
);
69 if (repoModel
.getChildren().length
> 0)
70 result
.add(repoModel
);
72 } catch (IOException e
) {
73 Activator
.logError(e
.getMessage(), e
);
76 children
= result
.toArray(new GitModelObject
[0]);
81 private void disposeOldChildren() {
84 for (GitModelObject child
: children
)