Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request to create/update 'rebased/RES-711' branch #76

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@
def repoName = "rups"
def dependencyRegex = "itextcore"

automaticJavaBuild(repoName, dependencyRegex, 'jdk-17-openjdk')
automaticJavaBuild(repoName, dependencyRegex)

pipeline {
agent any

stages {
stage('test') {
steps {
sh 'Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99'
}
}
}
}
26 changes: 22 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
</scm>

<properties>
<assembly-plugin.version>3.2.0</assembly-plugin.version>
<dom4j.version>2.1.3</dom4j.version>
<itext.version>7.2.5</itext.version>
<junit-jupiter-api.version>5.9.2</junit-jupiter-api.version>
Expand All @@ -57,8 +56,11 @@
<sonar.projectName>RUPS</sonar.projectName>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version>
<maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version>
<maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
<jacoco-maven-plugin.version>0.8.9</jacoco-maven-plugin.version>
<japicmp-maven-plugin.version>0.17.2</japicmp-maven-plugin.version>
<maven-bundle-plugin.version>5.1.4</maven-bundle-plugin.version>
</properties>

Expand Down Expand Up @@ -93,6 +95,11 @@
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
</dependency>
<dependency>
<groupId>org.uispec4j</groupId>
<artifactId>uispec4j</artifactId>
<version>17.0-rc1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdftest</artifactId>
Expand Down Expand Up @@ -152,7 +159,14 @@
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<argLine>@{jacoco.agent.argLine}</argLine>
<argLine>
@{jacoco.agent.argLine}
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/java.awt.peer=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.windows.WToolkit=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -197,8 +211,9 @@
<version>${maven-bundle-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${assembly-plugin.version}</version>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>make-assembly</id>
Expand Down Expand Up @@ -229,7 +244,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifest>
Expand All @@ -250,6 +267,7 @@
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>${japicmp-maven-plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/itextpdf/rups/RupsLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ This file is part of the iText (R) project.
* of a PDF file.
*/
public class RupsLauncher {

/**
* Main method. Starts the RUPS application.
*
Expand Down
118 changes: 108 additions & 10 deletions src/main/java/com/itextpdf/rups/controller/PdfReaderController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ This file is part of the iText (R) project.
import com.itextpdf.rups.event.NodeAddDictChildEvent;
import com.itextpdf.rups.event.NodeDeleteArrayChildEvent;
import com.itextpdf.rups.event.NodeDeleteDictChildEvent;
import com.itextpdf.rups.event.NodeUpdateArrayChildEvent;
import com.itextpdf.rups.event.NodeUpdateDictChildEvent;
import com.itextpdf.rups.event.OpenPlainTextEvent;
import com.itextpdf.rups.event.OpenStructureEvent;
import com.itextpdf.rups.event.RupsEvent;
Expand Down Expand Up @@ -95,6 +97,7 @@ This file is part of the iText (R) project.
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;

/**
Expand Down Expand Up @@ -167,7 +170,9 @@ public class PdfReaderController extends Observable implements Observer {
*/
public PdfReaderController(TreeSelectionListener treeSelectionListener,
PageSelectionListener pageSelectionListener) {

pdfTree = new PdfTree();
pdfTree.setName("pdfTree");

pdfTree.addTreeSelectionListener(treeSelectionListener);
JPopupMenu menu = PdfTreeContextMenu.getPopupMenu(pdfTree);
Expand All @@ -189,6 +194,7 @@ public PdfReaderController(TreeSelectionListener treeSelectionListener,
addObserver(text);

navigationTabs = new JTabbedPane();
navigationTabs.setName("navigationTabs");
final String pagesString = Language.PAGES.getString();
navigationTabs.addTab(pagesString, null, new JScrollPane(pages), pagesString);
navigationTabs.addTab(Language.OUTLINES.getString(), null, new JScrollPane(outlines),
Expand Down Expand Up @@ -219,17 +225,19 @@ public void stateChanged(ChangeEvent e) {
}
});

objectPanel = new PdfObjectPanel();
objectPanel = new PdfObjectPanel(this);
addObserver(objectPanel);
objectPanel.addObserver(this);
streamPane = new SyntaxHighlightedStreamPane(this);
addObserver(streamPane);
JScrollPane debug = new JScrollPane(DebugView.getInstance().getTextArea());
editorTabs = new JTabbedPane();
editorTabs.setName("editorTabs");
editorTabs.addTab(Language.STREAM.getString(), null, streamPane, Language.STREAM.getString());
editorTabs.addTab(Language.FORM_XFA.getString(), null, form.getXfaTextArea(),
Language.FORM_XFA_LONG_FORM.getString());
editorTabs.addTab(Language.DEBUG_INFO.getString(), null, debug, Language.DEBUG_INFO_DESCRIPTION.getString());

}

/**
Expand Down Expand Up @@ -343,11 +351,24 @@ public void update(Observable observable, Object obj) {
case RupsEvent.NODE_ADD_DICT_CHILD_EVENT:
addTreeNodeDictChild(((NodeAddDictChildEvent.Content) event.getContent()).parent,
((NodeAddDictChildEvent.Content) event.getContent()).key,
((NodeAddDictChildEvent.Content) event.getContent()).index);
((NodeAddDictChildEvent.Content) event.getContent()).index,
((NodeAddDictChildEvent.Content) event.getContent()).value);
break;
case RupsEvent.NODE_ADD_ARRAY_CHILD_EVENT:
addTreeNodeArrayChild(((NodeAddArrayChildEvent.Content) event.getContent()).parent,
((NodeAddArrayChildEvent.Content) event.getContent()).index);
((NodeAddArrayChildEvent.Content) event.getContent()).index,
((NodeAddArrayChildEvent.Content) event.getContent()).value);
break;
case RupsEvent.NODE_UPDATE_DICT_CHILD_EVENT:
updateTreeNodeDictChild(((NodeUpdateDictChildEvent.Content) event.getContent()).parent,
((NodeUpdateDictChildEvent.Content) event.getContent()).key,
((NodeUpdateDictChildEvent.Content) event.getContent()).index,
((NodeUpdateDictChildEvent.Content) event.getContent()).value);
break;
case RupsEvent.NODE_UPDATE_ARRAY_CHILD_EVENT:
updateTreeNodeArrayChild(((NodeUpdateArrayChildEvent.Content) event.getContent()).parent,
((NodeUpdateArrayChildEvent.Content) event.getContent()).index,
((NodeUpdateArrayChildEvent.Content) event.getContent()).value);
break;
case RupsEvent.NODE_DELETE_ARRAY_CHILD_EVENT:
deleteTreeChild(((NodeDeleteArrayChildEvent.Content) event.getContent()).parent,
Expand Down Expand Up @@ -466,28 +487,105 @@ public int deleteTreeNodeDictChild(PdfObjectTreeNode parent, PdfName key) {
}

//Returns index of the added child
public int addTreeNodeDictChild(PdfObjectTreeNode parent, PdfName key, int index) {
PdfObjectTreeNode child = PdfObjectTreeNode.getInstance((PdfDictionary) parent.getPdfObject(), key);
public int addTreeNodeDictChild(PdfObjectTreeNode parent, PdfName key, int index, PdfObject childValue) {
PdfObjectTreeNode child = PdfObjectTreeNode.getInstance(childValue, key);
return addTreeNodeChild(parent, child, index);
}

//Returns index of the added child
public int addTreeNodeArrayChild(PdfObjectTreeNode parent, int index) {
PdfObjectTreeNode child = PdfObjectTreeNode.getInstance(((PdfArray) parent.getPdfObject()).get(index, false));
return addTreeNodeChild(parent, child, index);
public int addTreeNodeArrayChild(PdfObjectTreeNode parent, int index, PdfObject child) {
PdfArray parentArray = (PdfArray) parent.getPdfObject();
PdfObjectTreeNode childNode = PdfObjectTreeNode.getInstance(child);
return addTreeNodeChild(parent, childNode, index);
}

//Returns index of the updated child
public int updateTreeNodeDictChild(PdfObjectTreeNode parent, PdfName key, int index, PdfObject child) {
//PdfObjectTreeNode child = PdfObjectTreeNode.getInstance((PdfDictionary) parent.getPdfObject(), key);
return updateTreeChild(parent, PdfObjectTreeNode.getInstance(child), index);
}

//Returns index of the updated child
public int updateTreeNodeArrayChild(PdfObjectTreeNode parent, int index, PdfObject child) {
return updateTreeChild(parent, PdfObjectTreeNode.getInstance(child), index);
}

public int deleteTreeChild(PdfObjectTreeNode parent, int index) {
parent.remove(index);
((DefaultTreeModel) pdfTree.getModel()).reload(parent);
deleteObjectChild(parent.getPdfObject(), index);
updateObject(parent);
updateView(parent);
return index;
}

//Returns index of the updated child
public int updateTreeChild(PdfObjectTreeNode parent, PdfObjectTreeNode child, int index) {
PdfObjectTreeNode oldChild = (PdfObjectTreeNode) parent.getChildAt(index);
int childrenToTransfer = oldChild.getChildCount();
if (childrenToTransfer > 0){
for (int childIndex = 0; childIndex < childrenToTransfer; childIndex++){
PdfObjectTreeNode childToTransfer = (PdfObjectTreeNode) oldChild.getChildAt(childIndex);
addObjectChild(child.getPdfObject(),childToTransfer.getPdfObject(), child.getKey(), childIndex);
child.add((MutableTreeNode) childToTransfer);
}
}
parent.remove(oldChild);
parent.insert(child, index);
updateObjectChild(parent.getPdfObject(), child.getPdfObject(), index);
nodes.expandNode(child);
updateObject(parent);
updateView(parent);
return index;
}

//Returns index of the added child
public int addTreeNodeChild(PdfObjectTreeNode parent, PdfObjectTreeNode child, int index) {
parent.insert(child, index);
nodes.expandNode(child);
((DefaultTreeModel) pdfTree.getModel()).reload(parent);
addObjectChild(parent.getPdfObject(), child.getPdfObject(), child.getKey(), index);
updateObject(parent);
updateView(parent);
return index;
}

private void updateView(PdfObjectTreeNode parent) {
((DefaultTreeModel) pdfTree.getModel()).reload(parent);
objectPanel.render(parent,getParser());
}

private void updateObject (PdfObjectTreeNode parent){
if (parent.isDictionary()) {
PdfDictionary parentDict = (PdfDictionary) parent.getPdfObject();
parentDict.keySet();
}else if(parent.isArray()){
PdfArray parentArray = (PdfArray)parent.getPdfObject();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything?

}
}

protected void addObjectChild(PdfObject parent, PdfObject child, PdfName key, int index){
if (parent.isDictionary()) {
PdfDictionary parentDict = ((PdfDictionary) parent);
parentDict.put(key, child);
}else if(parent.isArray()){
PdfArray parentArray = (PdfArray) parent;
parentArray.add(index, child);
}
}
protected void updateObjectChild(PdfObject parent, PdfObject child, int index){
if (parent.isDictionary()) {
PdfDictionary parentDict = ((PdfDictionary) parent);
parentDict.put((PdfName) parentDict.keySet().toArray()[index], child);
}else if(parent.isArray()){
PdfArray parentArray = (PdfArray) parent;
parentArray.set(index, child);
}
}
protected void deleteObjectChild(PdfObject parent, int index){
if (parent.isDictionary()) {
PdfDictionary parentDict = ((PdfDictionary) parent);
parentDict.remove((PdfName) parentDict.keySet().toArray()[index]);
}else if(parent.isArray()){
((PdfArray)parent).remove(index);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ public RupsInstanceController(Dimension dimension, JPanel owner) {
masterComponent.setDividerSize(2);

final JSplitPane content = new JSplitPane();
content.setName("content");
masterComponent.add(content, JSplitPane.TOP);
final JSplitPane info = new JSplitPane();
info.setName("info");
masterComponent.add(info, JSplitPane.BOTTOM);

content.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
content.setDividerLocation((int) (dimension.getWidth() * .6));
content.setDividerSize(1);
JPanel treePanel = new JPanel(new BorderLayout());
treePanel.setName("treePanel");
treePanel.add(new JScrollPane(readerController.getPdfTree()), BorderLayout.CENTER);
content.add(treePanel, JSplitPane.LEFT);
content.add(readerController.getNavigationTabs(), JSplitPane.RIGHT);
Expand All @@ -157,7 +160,9 @@ public RupsInstanceController(Dimension dimension, JPanel owner) {
info.setDividerSize(1);
info.add(readerController.getObjectPanel(), JSplitPane.LEFT);
final JTabbedPane editorPane = readerController.getEditorTabs();
editorPane.setName("editorPane");
final JScrollPane cons = new JScrollPane(console.getTextArea());
cons.setName("console");
console.getTextArea().addMouseListener(
new ContextMenuMouseListener(ConsoleContextMenu.getPopupMenu(console.getTextArea()),
console.getTextArea()));
Expand Down
Loading