Skip to content

Commit

Permalink
Add missing license headers and svg file as addressed while PR.
Browse files Browse the repository at this point in the history
Also small code cleanups
  • Loading branch information
Chris2011 committed Dec 19, 2024
1 parent 78a2273 commit fe9e4af
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 13 deletions.
20 changes: 20 additions & 0 deletions ide/svg/build.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<project basedir="." default="netbeans" name="ide/svg">
<description>Builds, tests, and runs the project org.netbeans.modules.svg</description>
<import file="../../nbbuild/templates/projectized.xml"/>
Expand Down
5 changes: 4 additions & 1 deletion ide/svg/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
-->
<licenseinfo>
<fileset>
<file>src/org/netbeans/modules/svg/resources/svgLogo.svg</file>
<file>src/org/netbeans/modules/svg/resources/svgLogo.png</file>
<license ref="Apache-2.0-ASF" />
<comment type="TEMPLATE_MINIMAL_IP"/>
<comment type="COMMENT_UNSUPPORTED">
Images for the SVG filetype
</comment>
</fileset>
</licenseinfo>
20 changes: 19 additions & 1 deletion ide/svg/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
javac.source=1.8
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

is.eager=true
javac.source=17
javac.compilerargs=-Xlint -Xlint:-serial
20 changes: 20 additions & 0 deletions ide/svg/nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
Expand Down
18 changes: 18 additions & 0 deletions ide/svg/src/org/netbeans/modules/svg/SVGPanel.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.netbeans.modules.svg;

import com.github.weisj.jsvg.SVGDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
public class SvgNavigatorPanel implements NavigatorPanel {

private static final Logger LOG = Logger.getLogger(SVGViewerElement.class.getName());
private final SVGLoader svgLoader = new SVGLoader();

/**
* holds UI of this panel
Expand Down Expand Up @@ -103,11 +102,13 @@ public void panelActivated(Lookup context) {
// get actual data and recompute content
Collection<? extends SVGDataObject> data = currentContext.allInstances();
currentDataObject = getDataObject(data);

if (currentDataObject == null) {
return;
}

if (fileChangeListener == null) {
fileChangeListener = new ImageFileChangeAdapter();
fileChangeListener = new SvgFileChangeAdapter();
}
currentDataObject.getPrimaryFile().addFileChangeListener(fileChangeListener);
setNewContent(currentDataObject);
Expand Down Expand Up @@ -137,14 +138,21 @@ private void setNewContent(final DataObject dataObject) {
WORKER.post(() -> {
FileObject fo = dataObject.getPrimaryFile();

if ((fo != null) && (panelUI != null)) {
try {
SVGDocument svgDocument = svgLoader.load(fo.toURL());
if (fo == null) {
return;
}

if (panelUI == null) {
return;
}

try {
SVGLoader svgLoader = new SVGLoader();
SVGDocument svgDocument = svgLoader.load(fo.toURL());

panelUI.setSvg(svgDocument);
} catch (Exception ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
SwingUtilities.invokeLater(() -> panelUI.setSvg(svgDocument));
} catch (Exception ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
});
}
Expand Down Expand Up @@ -179,7 +187,7 @@ public void resultChanged(LookupEvent ev) {
}
}

private class ImageFileChangeAdapter extends FileChangeAdapter {
private class SvgFileChangeAdapter extends FileChangeAdapter {

@Override
public void fileChanged(final FileEvent fe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* JPanel used for SVG preview in Navigator window
*
* @author jpeska
* @author christian lenz
*/
public class SvgPreviewPanel extends JPanel {

Expand Down
67 changes: 67 additions & 0 deletions ide/svg/src/org/netbeans/modules/svg/resources/svgLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions ide/svg/src/org/netbeans/modules/svg/toolbar/BackgroundIcon.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.netbeans.modules.svg.toolbar;

import org.netbeans.modules.svg.BackgroundMode;
Expand Down

0 comments on commit fe9e4af

Please sign in to comment.