|
From: <de...@us...> - 2012-10-22 14:02:12
|
Revision: 7771
http://fudaa.svn.sourceforge.net/fudaa/?rev=7771&view=rev
Author: deniger
Date: 2012-10-22 14:01:58 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/soft/fudaa-crue/ui-sysdoc/pom.xml
trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocAdminUI.java
trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocTopComponent.java
trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/Bundle.properties
Added Paths:
-----------
trunk/soft/fudaa-crue/ui-sysdoc/nb-configuration.xml
trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/rechercher.png
Added: trunk/soft/fudaa-crue/ui-sysdoc/nb-configuration.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-sysdoc/nb-configuration.xml (rev 0)
+++ trunk/soft/fudaa-crue/ui-sysdoc/nb-configuration.xml 2012-10-22 14:01:58 UTC (rev 7771)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-shared-configuration>
+ <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+ <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+ <!--
+Properties that influence various parts of the IDE, especially code formatting and the like.
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->
+ <netbeans.hint.jdkPlatform>JDK_1.6</netbeans.hint.jdkPlatform>
+ </properties>
+</project-shared-configuration>
Modified: trunk/soft/fudaa-crue/ui-sysdoc/pom.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-sysdoc/pom.xml 2012-10-19 23:26:06 UTC (rev 7770)
+++ trunk/soft/fudaa-crue/ui-sysdoc/pom.xml 2012-10-22 14:01:58 UTC (rev 7771)
@@ -121,7 +121,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocAdminUI.java
===================================================================
--- trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocAdminUI.java 2012-10-19 23:26:06 UTC (rev 7770)
+++ trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocAdminUI.java 2012-10-22 14:01:58 UTC (rev 7771)
@@ -9,17 +9,26 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.MissingResourceException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import org.apache.commons.lang.StringUtils;
+import org.fudaa.ctulu.CtuluLog;
import org.fudaa.dodico.crue.projet.conf.OptionsEnum;
import org.fudaa.dodico.crue.projet.conf.UserConfiguration;
import org.fudaa.dodico.crue.projet.conf.UserOption;
+import org.fudaa.dodico.crue.sysdoc.SysdocBuilder;
+import org.fudaa.dodico.crue.sysdoc.index.FileIndexer;
+import org.fudaa.fudaa.crue.common.helper.CrueProgressUtils;
+import org.fudaa.fudaa.crue.common.log.LogsDisplayer;
import org.fudaa.fudaa.crue.options.services.ConfigurationManagerService;
+import org.netbeans.api.progress.ProgressHandle;
+import org.netbeans.api.progress.ProgressRunnable;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
@@ -31,6 +40,9 @@
private ConfigurationManagerService configurationManagerService = Lookup.getDefault().lookup(ConfigurationManagerService.class);
+ /**
+ * permet d'activer le role d'admin sysdoc: utiliser pour le OptionProcessor ManagerRoleOptionProcessor.
+ */
protected static void activeRole() {
System.setProperty("sysdoc-admin", "true");
}
@@ -42,14 +54,6 @@
public void decore(SysdocTopComponent sysdocTopComponent) {
this.sysdocTopComponent = sysdocTopComponent;
-
- JButton btBuildToc = new JButton(NbBundle.getMessage(SysdocAdminUI.class, "BuildToc.Button"));
- btBuildToc.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- rebuildToc();
- }
- });
JPanel top = new JPanel(new FlowLayout(FlowLayout.LEFT));
sysdocTopComponent.add(top, BorderLayout.NORTH);
String available = configurationManagerService.getOptionsManager().getOption(OptionsEnum.AVAILABLE_LANGUAGE).getValeur();
@@ -81,7 +85,9 @@
});
top.add(cbLanguage);
- top.add(btBuildToc);
+
+ top.add(createBtEmptyPage());
+ top.add(createBtBuildToc());
}
private UserOption getUserOption(Collection<UserOption> options) {
@@ -94,5 +100,59 @@
}
protected void rebuildToc() {
+ File sysdocLocaleDir = sysdocTopComponent.getSysdocLocaleDir();
+ RebuildTocProcessor rebuildTocProcessor = new RebuildTocProcessor(sysdocLocaleDir);
+ final String title = NbBundle.getMessage(SysdocAdminUI.class, "ReloadToc.ProgressMsg");
+ CtuluLog log = CrueProgressUtils.showProgressDialogAndRun(rebuildTocProcessor, title);
+ SysdocAdminUI.this.sysdocTopComponent.setEmptyPage();
+ SysdocAdminUI.this.sysdocTopComponent.reloadToc();
+ if (log != null && log.isNotEmpty()) {
+ LogsDisplayer.displayError(log, title);
+ }
}
+
+ private JButton createBtBuildToc() throws MissingResourceException {
+ JButton btBuildToc = new JButton(NbBundle.getMessage(SysdocAdminUI.class, "BuildToc.Button"));
+ btBuildToc.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ rebuildToc();
+ }
+ });
+ return btBuildToc;
+ }
+
+ private JButton createBtEmptyPage() throws MissingResourceException {
+ JButton btBuildToc = new JButton(NbBundle.getMessage(SysdocAdminUI.class, "EmptyPage.Button"));
+ btBuildToc.setToolTipText(NbBundle.getMessage(SysdocAdminUI.class, "EmptyPage.Button.Tooltip"));
+ btBuildToc.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ sysdocTopComponent.setEmptyPage();
+ }
+ });
+ return btBuildToc;
+ }
+
+ private class RebuildTocProcessor implements ProgressRunnable<CtuluLog> {
+
+ private final File baseDir;
+
+ public RebuildTocProcessor(File baseDir) {
+ this.baseDir = baseDir;
+ }
+
+ @Override
+ public CtuluLog run(ProgressHandle handle) {
+ handle.switchToIndeterminate();
+ SysdocBuilder builder = new SysdocBuilder(baseDir);
+ CtuluLog log = builder.build();
+ FileIndexer fileIndexer = new FileIndexer(baseDir, configurationManagerService.getCurrentLocale());
+ CtuluLog index = fileIndexer.index();
+ if (index != null && index.isNotEmpty()) {
+ log.addAllLogRecord(index);
+ }
+ return log;
+ }
+ }
}
Modified: trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocTopComponent.java
===================================================================
--- trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocTopComponent.java 2012-10-19 23:26:06 UTC (rev 7770)
+++ trunk/soft/fudaa-crue/ui-sysdoc/src/main/java/org/fudaa/fudaa/crue/sysdoc/SysdocTopComponent.java 2012-10-22 14:01:58 UTC (rev 7771)
@@ -1,26 +1,48 @@
package org.fudaa.fudaa.crue.sysdoc;
import com.jidesoft.swing.JideSplitPane;
+import com.jidesoft.swing.JideTabbedPane;
+import com.memoire.bu.BuResource;
+import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ActionMap;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
import javax.swing.JComponent;
+import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.tree.TreeSelectionModel;
import org.apache.commons.lang.StringUtils;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
import org.fudaa.ctulu.CtuluIOResult;
+import org.fudaa.ctulu.CtuluResource;
import org.fudaa.dodico.crue.common.Pair;
import org.fudaa.dodico.crue.io.ccal.LienDocumentation;
import org.fudaa.dodico.crue.sysdoc.Sysdoc;
-import org.fudaa.dodico.crue.sysdoc.SysdocBuilder;
+import org.fudaa.dodico.crue.sysdoc.SysdocLoader;
import org.fudaa.dodico.crue.sysdoc.common.SysdocFolder;
import org.fudaa.dodico.crue.sysdoc.common.DocEntry;
import org.fudaa.fudaa.crue.common.AbstractTopComponent;
@@ -37,6 +59,7 @@
import org.openide.explorer.view.TreeView;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
+import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
@@ -63,6 +86,9 @@
private ExplorerManager em;
private HtmlBrowser browser;
private JTextField txtUrl;
+ private JideTabbedPane tabbedPane;
+ private JPanel pnSearch;
+ JTextField tf;
public SysdocTopComponent() {
initComponents();
@@ -83,7 +109,30 @@
treeView = new BeanTreeView();
treeView.setRootVisible(false);
JideSplitPane splitPane = new JideSplitPane();
- splitPane.add(treeView);
+ tabbedPane = new JideTabbedPane();
+ tabbedPane.add(treeView);
+ pnSearch = new JPanel(new BorderLayout());
+ tf = new JTextField(10);
+ JButton bt = new JButton();
+ final ImageIcon searchIcon = ImageUtilities.loadImageIcon("org/fudaa/fudaa/crue/sysdoc/rechercher.png", false);
+ bt.setIcon(searchIcon);
+ bt.setBorderPainted(false);
+ bt.setBorderPainted(false);
+ final ActionListener actionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ search();
+ }
+ };
+ bt.addActionListener(actionListener);
+ tf.addActionListener(actionListener);
+ JPanel topPanel = new JPanel(new BorderLayout());
+ topPanel.add(tf);
+ topPanel.add(bt, BorderLayout.EAST);
+ pnSearch.add(topPanel, BorderLayout.NORTH);
+ tabbedPane.addTab(StringUtils.EMPTY, BuResource.BU.getIcon("crystal_arbre"), treeView, NbBundle.getMessage(SysdocTopComponent.class, "Sysdoc.TocTooltip"));
+ tabbedPane.addTab(StringUtils.EMPTY, searchIcon, pnSearch, NbBundle.getMessage(SysdocTopComponent.class, "Sysdoc.SearchTooltip"));
+ splitPane.add(tabbedPane);
splitPane.add(browser);
splitPane.setShowGripper(true);
add(splitPane);
@@ -106,10 +155,107 @@
}
}
+ protected void search() {
+ System.err.println("search");
+ SysdocFolder sysdocFolder = new SysdocFolder(sysdocLocaleDir);
+ IndexReader reader = null;
+ try {
+ reader = DirectoryReader.open(FSDirectory.open(sysdocFolder.getSysdocIndexDir()));
+ IndexSearcher searcher = new IndexSearcher(reader);
+ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
+ String field = "contents";
+ QueryParser parser = new QueryParser(Version.LUCENE_40, field, analyzer);
+ Query query = parser.parse(tf.getText());
+ System.out.println("Searching for: " + query.toString(field));
+ searcher.search(query, null, 100);
+ doPagingSearch(searcher, query, 10, false, true);
+ } catch (Exception exception) {
+ Exceptions.printStackTrace(exception);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+ }
+ }
+
+ public static void doPagingSearch(IndexSearcher searcher, Query query,
+ int hitsPerPage, boolean raw, boolean interactive) throws IOException {
+
+ // Collect enough docs to show 5 pages
+ TopDocs results = searcher.search(query, 5 * hitsPerPage);
+ ScoreDoc[] hits = results.scoreDocs;
+
+ int numTotalHits = results.totalHits;
+ System.out.println(numTotalHits + " total matching documents");
+
+ int start = 0;
+ int end = Math.min(numTotalHits, hitsPerPage);
+
+ while (true) {
+
+ if (end > hits.length) {
+ System.out.println("Only results 1 - " + hits.length + " of " + numTotalHits + " total matching documents collected.");
+ System.out.println("Collect more (y/n) ?");
+
+// String line = in.readLine();
+// if (line.length() == 0 || line.charAt(0) == 'n') {
+// break;
+// }
+
+ hits = searcher.search(query, numTotalHits).scoreDocs;
+ }
+
+ end = Math.min(hits.length, start + hitsPerPage);
+
+ for (int i = start; i < end; i++) {
+ if (raw) { // output raw format
+ System.out.println("doc=" + hits[i].doc + " score=" + hits[i].score);
+ continue;
+ }
+
+ Document doc = searcher.doc(hits[i].doc);
+ String path = doc.get("path");
+ if (path != null) {
+ System.out.println((i + 1) + ". " + path);
+ String title = doc.get("title");
+ if (title != null) {
+ System.out.println(" Title: " + doc.get("title"));
+ }
+ } else {
+ System.out.println((i + 1) + ". " + "No path for this document");
+ }
+
+ }
+
+ if (end == 0) {
+ break;
+ }
+ if (end >= numTotalHits) {
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ * @return le dossier localisé de sysdoc contenant la documentation et le dossier de config
+ */
public File getSysdocBaseDir() {
return sysdocBaseDir;
}
+ /**
+ *
+ * @return le dossier contenant les locales de Sysdoc
+ */
+ protected File getSysdocLocaleDir() {
+ return sysdocLocaleDir;
+ }
+
protected void urlChanged() {
if (sysdocLocaleDir != null && nodeByPath != null && !isUpdating) {
String location = browser.getBrowserImpl().getLocation();
@@ -254,7 +400,7 @@
mustReload = folder.getTocFile().lastModified() > timeStampToc;
}
if (mustReload) {
- SysdocBuilder builder = new SysdocBuilder(sysdocLocaleDir);
+ SysdocLoader builder = new SysdocLoader(sysdocLocaleDir);
CtuluIOResult<Sysdoc> load = builder.load();
if (load.getAnalyze().isNotEmpty()) {
LogsDisplayer.displayError(load.getAnalyze(), getDisplayName());
@@ -297,4 +443,13 @@
void reloadToc() {
updateContent();
}
+
+ void setEmptyPage() {
+ browser.getBrowserImpl().stopLoading();
+ try {
+ browser.setURL(new SysdocFolder(getSysdocLocaleDir()).getSysdocHelpFile().toURI().toURL());
+ } catch (Exception e) {
+ Exceptions.printStackTrace(e);
+ }
+ }
}
Modified: trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/Bundle.properties 2012-10-19 23:26:06 UTC (rev 7770)
+++ trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/Bundle.properties 2012-10-22 14:01:58 UTC (rev 7771)
@@ -9,4 +9,10 @@
FileNotFoundError=Le fichier cible n''existe pas: {0}
OpenDocLink.Error=Le chemin {0} n''est pas d\u00e9fini dans Sysdoc
BuildToc.Button=Construire l'arborescence
+EmptyPage.Button=Page vide
+EmptyPage.Button.Tooltip=Utiliser ce bouton pour charger un page vide et d\u00e9bloquer l'acc\u00e8s aux fichiers de sysdoc
SysdocAdmin.ChangeLanguage=Change la langue utilis\u00e9e dans l'application ( sauvegard\u00e9e dans la configuration utilisateur)
+ReloadToc.ProgressMsg=Construction de la table des mati\u00e8res
+ReloadToc.ProgressMsgTest=Construction de la table des mati\u00e8res
+Sysdoc.TocTooltip=Table des mati\u00e8res
+Sysdoc.SearchTooltip=Rechercher
Added: trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/rechercher.png
===================================================================
(Binary files differ)
Property changes on: trunk/soft/fudaa-crue/ui-sysdoc/src/main/resources/org/fudaa/fudaa/crue/sysdoc/rechercher.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|