11 |
11 |
import java.awt.event.KeyEvent;
|
12 |
12 |
import java.awt.event.MouseAdapter;
|
13 |
13 |
import java.awt.event.MouseEvent;
|
|
14 |
import java.io.InputStream;
|
14 |
15 |
import java.net.URL;
|
15 |
16 |
import java.util.ArrayList;
|
16 |
17 |
import java.util.Collection;
|
17 |
18 |
import java.util.HashSet;
|
18 |
19 |
import java.util.List;
|
|
20 |
import java.util.Locale;
|
19 |
21 |
import java.util.Objects;
|
20 |
22 |
import javax.swing.DefaultListCellRenderer;
|
21 |
23 |
import javax.swing.ImageIcon;
|
... | ... | |
43 |
45 |
import javax.swing.tree.TreeModel;
|
44 |
46 |
import javax.swing.tree.TreePath;
|
45 |
47 |
import org.apache.commons.io.FilenameUtils;
|
|
48 |
import org.apache.commons.io.IOUtils;
|
46 |
49 |
import org.apache.commons.lang3.StringUtils;
|
47 |
50 |
import org.gvsig.expressionevaluator.Expression;
|
48 |
51 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
|
... | ... | |
99 |
102 |
private final String labelDescription;
|
100 |
103 |
private final String labelAdditionalPanel;
|
101 |
104 |
private final JPanel pnlContainer;
|
|
105 |
|
|
106 |
private final String defautltDescription;
|
102 |
107 |
|
103 |
108 |
private String description;
|
104 |
109 |
private Component additionalPanel;
|
105 |
110 |
|
106 |
|
public InfoPanel(JPanel pnlContainer) {
|
|
111 |
public InfoPanel(JPanel pnlContainer, String defautltDescription) {
|
107 |
112 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
|
108 |
113 |
I18nManager i18n = ToolsLocator.getI18nManager();
|
109 |
114 |
|
|
115 |
this.defautltDescription = defautltDescription;
|
110 |
116 |
this.pnlContainer = pnlContainer;
|
111 |
117 |
this.labelDescription = i18n.getTranslation("_Description");
|
112 |
118 |
this.labelAdditionalPanel = i18n.getTranslation("_Assistant");
|
... | ... | |
141 |
147 |
if( StringUtils.isBlank(this.description) ) {
|
142 |
148 |
if( this.additionalPanel==null ) {
|
143 |
149 |
// Sin descripcion ni panel adicional, mostramos
|
144 |
|
// la descripcion vacia.
|
|
150 |
// la descripcion por defecto.
|
|
151 |
this.txtDescription.setText(this.defautltDescription);
|
|
152 |
this.txtDescription.setCaretPosition(0);
|
145 |
153 |
return this.scrDescription;
|
146 |
154 |
}
|
147 |
155 |
// Sin descripcion pero con panel adicional, mostramos el
|
... | ... | |
322 |
330 |
}
|
323 |
331 |
|
324 |
332 |
};
|
325 |
|
this.infoPanel = new InfoPanel(this.pnlDescription);
|
|
333 |
this.infoPanel = new InfoPanel(this.pnlDescription, load_description_from_resource());
|
326 |
334 |
|
327 |
335 |
this.btnTip.setVisible(false);
|
328 |
336 |
this.btnTip.addActionListener(new ActionListener() {
|
... | ... | |
601 |
609 |
this.pnlScriptEditorContainer.add(this.scriptEditor.asJComponent(), BorderLayout.CENTER);
|
602 |
610 |
|
603 |
611 |
this.tabExpressionBuilder.setEnabledAt(0, this.config.getScriptsEnabled());
|
|
612 |
|
|
613 |
this.infoPanel.repaint();
|
|
614 |
|
604 |
615 |
this.setPreferredSize(new Dimension(650, 350));
|
605 |
616 |
}
|
606 |
617 |
|
... | ... | |
613 |
624 |
return s;
|
614 |
625 |
}
|
615 |
626 |
|
|
627 |
@Override
|
616 |
628 |
public void insertText(String text) {
|
617 |
629 |
doInsert(text);
|
618 |
630 |
}
|
619 |
631 |
|
|
632 |
@Override
|
620 |
633 |
public String getText() {
|
621 |
634 |
return this.txtExpression.getText();
|
622 |
635 |
}
|
... | ... | |
884 |
897 |
);
|
885 |
898 |
}
|
886 |
899 |
}
|
|
900 |
|
|
901 |
private String load_description_from_resource() {
|
|
902 |
String lang = Locale.getDefault().getLanguage();
|
|
903 |
URL url = this.getClass().getResource("/org/gvsig/expressionevaluator/swing/jexpressionbuilder/"+lang+"/description.html");
|
|
904 |
if( url == null ) {
|
|
905 |
url = this.getClass().getResource("/org/gvsig/expressionevaluator/swing/jexpressionbuilder/en/description.html");
|
|
906 |
if( url == null ) {
|
|
907 |
return null;
|
|
908 |
}
|
|
909 |
}
|
|
910 |
InputStream is = null;
|
|
911 |
try {
|
|
912 |
is = url.openStream();
|
|
913 |
List<String> lines = IOUtils.readLines(is);
|
|
914 |
return StringUtils.join(lines, "\n");
|
|
915 |
} catch (Exception ex) {
|
|
916 |
return null;
|
|
917 |
} finally {
|
|
918 |
IOUtils.closeQuietly(is);
|
|
919 |
}
|
|
920 |
}
|
887 |
921 |
}
|