diff --git a/trunk/.classpath b/trunk/.classpath index 07ffbb30..1cf4af03 100644 --- a/trunk/.classpath +++ b/trunk/.classpath @@ -42,5 +42,7 @@ + + diff --git a/trunk/SIPRPSoft/lib/evospellchecker.jar b/trunk/SIPRPSoft/lib/evospellchecker.jar new file mode 100644 index 00000000..3c254eb4 Binary files /dev/null and b/trunk/SIPRPSoft/lib/evospellchecker.jar differ diff --git a/trunk/SIPRPSoft/lib/jazzy-core.jar b/trunk/SIPRPSoft/lib/jazzy-core.jar new file mode 100644 index 00000000..50d31354 Binary files /dev/null and b/trunk/SIPRPSoft/lib/jazzy-core.jar differ diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java index 6f2217e4..add4443a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java @@ -40,6 +40,7 @@ import leaf.ui.LeafTextAreaEditor; import leaf.ui.LeafTree; import leaf.ui.LeafUIConstants; import leaf.ui.TreeTools; +import siprp.SpellChecker; import siprp.database.cayenne.objects.HsNormalizacao; import siprp.logic.HigieneSegurancaLogic; @@ -256,6 +257,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C } ); textCodigo.addCaretListener( this ); textAreaDescricao.addCaretListener( this ); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( textAreaDescricao ); buttonPortuguesaCriar.addActionListener( new ActionListener() { @Override diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index e0254229..c4673c32 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -16,6 +16,7 @@ import javax.swing.event.CaretListener; import leaf.ui.LeafButton; import leaf.ui.LeafDialog; +import siprp.SpellChecker; import siprp.database.cayenne.objects.HsMedida; import com.evolute.utils.images.ImageException; @@ -67,10 +68,10 @@ public class GerirMedidaPanel extends JPanel { fieldTextMedida.setWrapStyleWord( true ); fieldTextMedida.setLineWrap( true ); - new CopyPasteHandler(fieldTextMedida); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( fieldTextMedida ); fieldTextRequisitosLegais.setWrapStyleWord( true ); fieldTextRequisitosLegais.setLineWrap( true ); - new CopyPasteHandler(fieldTextRequisitosLegais); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( fieldTextRequisitosLegais ); scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index 68d84716..771b2b61 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -19,6 +19,7 @@ import javax.swing.event.CaretListener; import leaf.ui.LeafButton; import leaf.ui.LeafDialog; +import siprp.SpellChecker; import siprp.database.cayenne.objects.HsRelatorioPostoMedida; import com.evolute.utils.images.ImageException; @@ -79,6 +80,8 @@ public class GerirMedidaRelatorioPanel extends JPanel fieldTextMedida.setLineWrap( true ); fieldTextRequisitosLegais.setWrapStyleWord( true ); fieldTextRequisitosLegais.setLineWrap( true ); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( fieldTextRequisitosLegais ); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( fieldTextMedida ); scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); diff --git a/trunk/common/src/com/evolute/adt/Pair.java b/trunk/common/src/com/evolute/adt/Pair.java new file mode 100644 index 00000000..ce01de8a --- /dev/null +++ b/trunk/common/src/com/evolute/adt/Pair.java @@ -0,0 +1,100 @@ +package com.evolute.adt; + +public class Pair implements Comparable> +{ + + private final CARCLASS left; + + private final CDRCLASS right; + + public Pair( CARCLASS leftValue, CDRCLASS rightValue ) + { + this.left = leftValue; + this.right = rightValue; + } + + public CARCLASS getLeft() + { + return left; + } + + public CDRCLASS getRight() + { + return right; + } + + @SuppressWarnings("unchecked") + @Override + public boolean equals(Object obj) + { + boolean result = obj != null; + if( result ) + { + if( obj instanceof Pair ) + { + result = ( left == null ? (((Pair) obj).left == null ) : (left.equals(((Pair) obj).left)) ); + result &= ( right == null ? (((Pair) obj).right == null ) : (right.equals(((Pair) obj).right)) ); + } + else + { + result = false; + } + } + return result; + } + + @Override + public int compareTo(Pair pair) + { + int result = compare( left, pair == null ? null : pair.left ); + if( result == 0 ) + { + result = compare( right, pair == null ? null : pair.right ); + } + return result; + } + + @SuppressWarnings("unchecked") + private int compare( Object a, Object b ) + { + int result = a == null ? (b == null ? 0 : -1 ) : ( b == null ? 1 : 0 ); + if( a != null && b != null ) + { + if( a.getClass().equals( b.getClass() ) && (a instanceof Comparable) ) + { + ((Comparable)a).compareTo(b); + } + else + { + result = compare(a.toString(),b.toString()); + } + } + return result; + } + + @Override + public int hashCode() + { + int result = super.hashCode(); + if( left != null ) + { + result = left.hashCode(); + if( right != null ) + { + result ^= right.hashCode(); + } + } + else if( right != null ) + { + result = right.hashCode(); + } + return result; + } + + @Override + public String toString() + { + return "<"+left+","+right+">"; + } + +} diff --git a/trunk/common/src/com/evolute/adt/Range.java b/trunk/common/src/com/evolute/adt/Range.java new file mode 100644 index 00000000..b093044a --- /dev/null +++ b/trunk/common/src/com/evolute/adt/Range.java @@ -0,0 +1,55 @@ +package com.evolute.adt; + +public class Range +{ + + private final int start; + + private final int end; + + private final int length; + + public Range( int start, int end ) + { + super(); + this.start = start; + this.end = end; + this.length = 1 + ( Math.max( Math.abs( start ), Math.abs( end ) ) - Math.min( Math.abs( start ), Math.abs( end ) ) ); + } + + public int getStart() + { + return start; + } + + public int getEnd() + { + return end; + } + + /** + * The lenght of the range + * Examples: + * start:end > length + * 0:3 > 4 + * -1:-1 > 1 + * @return + */ + public int getLength() + { + return length; + } + + @Override + public boolean equals( Object obj ) + { + return (obj instanceof Range) && ((Range)obj).start == start && ((Range)obj).end == end; + } + + @Override + public int hashCode() + { + return new Integer( start ).hashCode() ^ new Integer( end ).hashCode(); + } + +} diff --git a/trunk/common/src/leaf/ui/LeafTextAreaEditor.java b/trunk/common/src/leaf/ui/LeafTextAreaEditor.java index 64bd0240..471e6387 100644 --- a/trunk/common/src/leaf/ui/LeafTextAreaEditor.java +++ b/trunk/common/src/leaf/ui/LeafTextAreaEditor.java @@ -15,6 +15,8 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.JTextComponent; +import siprp.SpellChecker; + import com.evolute.utils.ui.text.CopyPasteHandler; import leaf.data.Validator; @@ -80,6 +82,7 @@ public class LeafTextAreaEditor extends JPanel scroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); buttonSave.setMargin( new Insets(0,0,0,0) ); buttonRevert.setMargin( new Insets(0,0,0,0) ); + SpellChecker.getInstance().getSpellChecker().attachSpellCheckToComponent( fieldText ); } private void startupLayout( boolean textField ) diff --git a/trunk/common/src/siprp/SpellChecker.java b/trunk/common/src/siprp/SpellChecker.java new file mode 100644 index 00000000..bd22e234 --- /dev/null +++ b/trunk/common/src/siprp/SpellChecker.java @@ -0,0 +1,33 @@ +package siprp; + +import com.evolute.modules.spellchecker.EvoSpellChecker; +import com.evolute.modules.spellchecker.EvoSpellChecker.Dictionary; + + +public class SpellChecker +{ + + private static SpellChecker instance = null; + + private final EvoSpellChecker spellChecker; + + private SpellChecker() + { + this.spellChecker = new EvoSpellChecker( Dictionary.PT_PT ); + } + + public static SpellChecker getInstance() + { + if( instance == null ) + { + instance = new SpellChecker(); + } + return instance; + } + + public EvoSpellChecker getSpellChecker() + { + return spellChecker; + } + +} diff --git a/trunk/lib/evospellchecker.jar b/trunk/lib/evospellchecker.jar new file mode 100644 index 00000000..3c254eb4 Binary files /dev/null and b/trunk/lib/evospellchecker.jar differ diff --git a/trunk/lib/jazzy-core.jar b/trunk/lib/jazzy-core.jar new file mode 100644 index 00000000..50d31354 Binary files /dev/null and b/trunk/lib/jazzy-core.jar differ