Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
af3
AF3
Commits
cc02dcc4
Commit
cc02dcc4
authored
Jul 01, 2013
by
Johannes Eder
Browse files
added file import check+copy
refs 1007
parent
1d8fb1c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.project/trunk/src/org/fortiss/af3/project/utils/ExternalFileUtils.java
0 → 100644
View file @
cc02dcc4
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2013 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.project.utils
;
import
java.io.File
;
import
java.io.IOException
;
import
org.conqat.lib.commons.filesystem.FileSystemUtils
;
import
org.eclipse.emf.common.util.TreeIterator
;
import
org.eclipse.emf.common.util.URI
;
import
org.eclipse.emf.ecore.EObject
;
import
org.fortiss.af3.project.model.FileProject
;
import
org.fortiss.tooling.kernel.ToolingKernelActivator
;
import
org.fortiss.tooling.kernel.model.IExternalDocumentReference
;
import
org.fortiss.tooling.kernel.utils.LoggingUtils
;
/**
*
* @author eder
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public
class
ExternalFileUtils
{
/**
* Check given e-object and all its children for {@link IExternalDocumentReference}
*
*/
public
static
void
checkImportedFileReferences
(
FileProject
fileProject
,
URI
sourceFileURI
,
URI
targetFileURI
)
{
TreeIterator
<
EObject
>
currentContents
=
fileProject
.
eAllContents
();
while
(
currentContents
.
hasNext
())
{
EObject
current
=
currentContents
.
next
();
if
(
current
instanceof
IExternalDocumentReference
)
{
IExternalDocumentReference
ref
=
(
IExternalDocumentReference
)
current
;
File
sourcePath
=
new
File
(
sourceFileURI
.
path
()).
getParentFile
().
getAbsoluteFile
();
File
destinationPath
=
new
File
(
targetFileURI
.
path
()).
getParentFile
().
getAbsoluteFile
();
File
sourceFile
=
new
File
(
sourcePath
,
ref
.
getUri
());
if
(!
sourceFile
.
exists
())
{
LoggingUtils
.
warning
(
ToolingKernelActivator
.
getDefault
(),
"Could not load "
+
ref
.
getUri
());
continue
;
}
// check file type
try
{
FileSystemUtils
.
copyFile
(
sourceFile
,
new
File
(
destinationPath
,
ref
.
getUri
()));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment