source: trunk/src/org/expeditee/agents/CopyTree.java@ 1415

Last change on this file since 1415 was 1415, checked in by bln4, 5 years ago

Renamed Frame.getItems() to Frame.getSortedItems() to better represent its functionality.

-> org.apollo.ApolloGestureActions
-> org.apollo.ApolloSystem
-> org.expeditee.actions.Actions
-> org.expeditee.actions.Debug
-> org.expeditee.actions.ExploratorySearchActions
-> org.expeditee.actions.JfxBrowserActions
-> org.expeditee.actions.Misc
-> org.expeditee.actions.Navigation
-> org.expeditee.actions.ScriptBase
-> org.expeditee.actions.Simple
-> org.expeditee.agents.ComputeTree
-> org.expeditee.agents.CopyTree
-> org.expeditee.agents.DisplayComet
-> org.expeditee.agents.DisplayTree
-> org.expeditee.agents.DisplayTreeLeaves
-> org.expeditee.agents.GraphFramesetLinks
-> org.expeditee.agents.TreeProcessor
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.DisplayController
-> org.expeditee.gui.FrameCreator
-> org.expeditee.gui.FrameIO
-> org.expeditee.io.DefaultTreeWriter
-> org.expeditee.io.JavaWriter
-> org.expeditee.io.PDF2Writer
-> org.expeditee.io.TXTWriter
-> org.expeditee.io.WebParser
-> org.expeditee.io.flowlayout.XGroupItem
-> org.expeditee.items.Dot
-> org.expeditee.items.Item
-> org.expeditee.items.ItemUtils
-> org.expeditee.network.FrameShare
-> org.expeditee.stats.TreeStats


Created ItemsList class to wrap ArrayList<Item>. Frames now use this new class to store its body list (used for display) as well as its primaryBody and surrogateBody.

-> org.expeditee.agents.Format
-> org.expeditee.agents.HFormat
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.Frame
-> org.expeditee.gui.FrameUtils


Refactorted Frame.setResort(bool) to Frame.invalidateSorted() to better function how it is intended to with a more accurate name.

-> org.expeditee.agents.Sort


When writing out .exp files and getting attributes to respond to LEFT + RIGHT click, boolean items are by default true. This has always been the case. An ammendment to this is that defaults can now be established.
Also added 'EnterClick' functionality. If cursored over a item with this property and you press enter, it acts as if you have clicked on it instead.

-> org.expeditee.assets.resources-public.framesets.authentication.1.exp to 6.exp
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gio.input.KBMInputEvent
-> org.expeditee.gio.javafx.JavaFXConversions
-> org.expeditee.gio.swing.SwingConversions
-> org.expeditee.gui.AttributeUtils
-> org.expeditee.io.Conversion
-> org.expeditee.io.DefaultFrameWriter
-> org.expeditee.items.Item


Fixed a bug caused by calling Math.abs on Integer.MIN_VALUE returning unexpected result. Due to zero being a thing, you cannot represent Math.abs(Integer.MIN_VALUE) in a Integer object. The solution is to use Integer.MIN_VALUE + 1 instead of Integer.MIN_VALUE.

-> org.expeditee.core.bounds.CombinationBounds
-> org.expeditee.io.flowlayout.DimensionExtent


Recoded the contains function in EllipticalBounds so that intersection tests containing circles work correctly.

-> org.expeditee.core.bounds.EllipticalBounds


Added toString() to PolygonBounds to allow for useful printing during debugging.

-> org.expeditee.core.bounds.PolygonBounds

Implemented Surrogate Mode!

-> org.expeditee.encryption.io.EncryptedExpReader
-> org.expeditee.encryption.io.EncryptedExpWriter
-> org.expeditee.encryption.items.surrogates.EncryptionDetail
-> org.expeditee.encryption.items.surrogates.Label
-> org.expeditee.gui.FrameUtils
-> org.expeditee.gui.ItemsList
-> org.expeditee.items.Item
-> org.expeditee.items.Text


???? Use Integer.MAX_VALUE cast to a float instead of Float.MAX_VALUE. This fixed some bug which I cannot remember.

-> org.expeditee.gio.TextLayoutManager
-> org.expeditee.gio.swing.SwingTextLayoutManager


Improved solution for dealing with the F10 key taking focus away from Expeditee due to it being a assessibility key.

-> org.expeditee.gio.swing.SwingInputManager


Renamed variable visibleItems in FrameGraphics.paintFrame to itemsToPaintCanditates to better represent functional intent.

-> org.expeditee.gui.FrameGraphics


Improved checking for if personal resources exist before recreating them

-> org.expeditee.gui.FrameIO


Repeated messages to message bay now have a visual feedback instead of just a beep. This visual feedback is in the form of a count of the amount of times it has repeated.

-> org.expeditee.gui.MessageBay


Updated comment on the Vector class to explain what vectors are.

-> org.expeditee.gui.Vector


Added constants to represent all of the property keys in DefaultFrameReader and DefaultFrameWriter.

-> org.expeditee.io.DefaultFrameReader
-> org.expeditee.io.DefaultFrameWriter


Updated the KeyList setting to be more heirarcial with how users will store their Secrets.

-> org.expeditee.settings.identity.secrets.KeyList

File size: 4.4 KB
Line 
1/**
2 * CopyTree.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.agents;
20
21import java.util.HashMap;
22import java.util.LinkedList;
23
24import org.expeditee.gui.Frame;
25import org.expeditee.gui.FrameIO;
26import org.expeditee.gui.FrameUtils;
27import org.expeditee.gui.MessageBay;
28import org.expeditee.items.Item;
29
30public class CopyTree extends TreeProcessor {
31
32 private String _nameTo;
33
34 private String _nameFrom;
35
36 private String _framePath;
37
38 private int _lastNumber = -1;
39
40 private int _firstNumber = 1;
41
42 private HashMap<String, String> _nameMap = new HashMap<String, String>();
43
44 private LinkedList<String> _toReparse = new LinkedList<String>();
45
46 public CopyTree(String framesetTo) {
47 _nameTo = framesetTo.trim();
48 }
49
50 @Override
51 public boolean initialise(Frame init, Item launcher) {
52 _nameFrom = init.getFramesetName().toLowerCase();
53
54 // create the new frameset
55 try {
56 // get the last used frame in the destination frameset
57 _lastNumber = FrameIO.getLastNumber(_nameTo);
58 Frame one = FrameIO.CreateFrameset(_nameTo, init.getPath());
59
60 _framePath = one.getPath();
61 _lastNumber = -1;
62 _firstNumber = 1;
63
64 // copy the original .0 frame
65 Frame zero = FrameIO
66 .LoadFrame(init.getFramesetName() + "0");
67 processFrame(zero);
68 } catch (ExistingFramesetException efe) {
69 MessageBay.errorMessage("A frameset called " + _nameTo
70 + " already exists.");
71 return false;
72 } catch (Exception e) {
73 return false;
74 }
75
76 return super.initialise(init, launcher);
77 }
78
79 @Override
80 protected void processFrame(Frame toProcess) {
81 // load a fresh copy of the frame that bypasses the cache
82 FrameIO.SuspendCache();
83
84 Frame fresh = FrameIO.LoadFrame(toProcess.getName());
85 if (_nameMap.containsKey(fresh.getName().toLowerCase())) {
86 fresh
87 .setName(_nameMap.get(fresh.getName()
88 .toLowerCase()));
89 } else {
90 fresh.setFrameset(_nameTo);
91 fresh.setFrameNumber(++_lastNumber);
92
93 _nameMap.put(toProcess.getName().toLowerCase(), fresh
94 .getName().toLowerCase());
95 }
96
97 boolean added = false;
98 for (Item i : fresh.getSortedItems())
99 if (i.getLink() != null && !i.isAnnotation() && i.isLinkValid()) {
100 String link = i.getLink().toLowerCase();
101 //convert to absolute link with the old framesetName
102 if (FrameIO.isPositiveInteger(link)){
103 link = _nameFrom + link;
104 }
105 //check if we already have this in our map
106 if (_nameMap.containsKey(link))
107 link = _nameMap.get(link);
108 //otherwise add it to our map
109 else if (link.startsWith(_nameFrom)) {
110 _nameMap.put(link, _nameTo + (++_lastNumber));
111 link = "" + _lastNumber;
112 }
113 i.setLink(link);
114 } else if (!added && i.getLink() != null && i.isAnnotation()
115 && i.isLinkValid()) {
116 // annotation links need to be parsed at the end
117 if (i.getAbsoluteLink().toLowerCase().startsWith(_nameFrom)) {
118 _toReparse.add(fresh.getName());
119 added = true;
120 }
121
122 }
123 _frameCount++;
124 fresh.setPath(_framePath);
125 FrameIO.ForceSaveFrame(fresh);
126 FrameIO.ResumeCache();
127 }
128
129 @Override
130 protected void finalise(Frame frame) {
131 // reparse all frames that have annotation links that may need updating
132 for (String name : _toReparse) {
133 Frame toParse = FrameIO.LoadFrame(name);
134 boolean changed = false;
135 for (Item i : toParse.getSortedItems()) {
136 if (i.getLink() != null && i.isAnnotation() && i.isLinkValid()) {
137 String link = i.getLink();
138 link = link.toLowerCase();
139 // link = link.replace(_nameFrom, _nameTo);
140 if (_nameMap.containsKey(link)) {
141 link = _nameMap.get(link);
142 i.setLink(link);
143 changed = true;
144 }
145 }
146 }
147 if (changed) {
148 FrameIO.SaveFrame(toParse);
149 }
150 }
151
152 message("Tree successfully copied to " + _nameTo);
153 FrameUtils.DisplayFrame(_nameTo + _firstNumber);
154
155 super.finalise(frame);
156 }
157
158}
Note: See TracBrowser for help on using the repository browser.