Issue #639 adding new files missed in last commit
Former-commit-id: 26ada47164c9b004cff5e869735ee11655af6a40
This commit is contained in:
parent
78e44746d6
commit
3795f90712
4 changed files with 1049 additions and 0 deletions
|
@ -0,0 +1,470 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
* Simple search composite control for a text based composite..
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 31, 2012 bgonzale Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bgonzale
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SearchComposite extends Composite {
|
||||
|
||||
// final Color HIGHLIGHT_COLOR = Display.getCurrent().getSystemColor(
|
||||
// SWT.COLOR_YELLOW);
|
||||
|
||||
private StringBuilder text;
|
||||
|
||||
private Button caseSensitive;
|
||||
|
||||
private boolean searchFWD = true;
|
||||
|
||||
private String searchText;
|
||||
|
||||
private List<MatchResult> results = new ArrayList<MatchResult>();
|
||||
|
||||
private ListIterator<MatchResult> resultIter;
|
||||
|
||||
private SearchView searchView;
|
||||
|
||||
private KeyListener searchKeyListener;
|
||||
|
||||
private Text searchTextBox;
|
||||
|
||||
private Button bck;
|
||||
|
||||
private Button fwd;
|
||||
|
||||
private Button first;
|
||||
|
||||
private Button last;
|
||||
|
||||
// public static class HighlightSelection {
|
||||
// public final int start;
|
||||
//
|
||||
// public final int length;
|
||||
//
|
||||
// public HighlightSelection(int start, int length) {
|
||||
// this.start = start;
|
||||
// this.length = length;
|
||||
// }
|
||||
// }
|
||||
|
||||
public static interface SearchView {
|
||||
|
||||
void select(int start, int end);
|
||||
|
||||
void reachedLast();
|
||||
|
||||
void reachedFirst();
|
||||
|
||||
// void setHighlights(HighlightSelection[] selections);
|
||||
// void removeHighlights();
|
||||
|
||||
}
|
||||
|
||||
public class DefaultSearchView implements SearchView {
|
||||
private StyledText searchView;
|
||||
|
||||
public DefaultSearchView(StyledText searchView) {
|
||||
this.searchView = searchView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(int start, int end) {
|
||||
this.searchView.setSelectionRange(start, end - start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reachedLast() {
|
||||
// go to first
|
||||
while (resultIter.hasPrevious()) {
|
||||
resultIter.previous();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reachedFirst() {
|
||||
// go to last
|
||||
while (resultIter.hasNext()) {
|
||||
resultIter.next();
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setHighlights(HighlightSelection[] selections) {
|
||||
// StyleRange[] ranges = new StyleRange[selections.length];
|
||||
// for (int i = 0; i < selections.length; ++i) {
|
||||
// HighlightSelection sel = selections[i];
|
||||
// ranges[i] = new StyleRange(sel.start, sel.length,
|
||||
// FOREGROUND_COLOR, HIGHLIGHT_COLOR);
|
||||
// }
|
||||
// searchView.setStyleRanges(ranges);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void removeHighlights() {
|
||||
// StyleRange[] ranges = searchView.getStyleRanges();
|
||||
// for (StyleRange style : ranges) {
|
||||
// if (style.background == HIGHLIGHT_COLOR) {
|
||||
// style.background = searchView.getBackground();
|
||||
// }
|
||||
// }
|
||||
// searchView.setStyleRanges(ranges);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public SearchComposite(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
this.setLayout(new GridLayout(6, false));
|
||||
this.setLayoutData(gd);
|
||||
|
||||
searchTextBox = new Text(this, SWT.RESIZE);
|
||||
searchTextBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
|
||||
false));
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
searchTextBox.setLayoutData(gd);
|
||||
searchTextBox.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
first = new Button(this, SWT.PUSH);
|
||||
first.setText("<<");
|
||||
first.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
first.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
searchFWD = false;
|
||||
MatchResult result = null;
|
||||
while (resultIter.hasPrevious()) {
|
||||
result = resultIter.previous();
|
||||
}
|
||||
if (result != null) {
|
||||
searchView.select(result.start(), result.end());
|
||||
}
|
||||
if (result == null && resultIter.hasNext()) {
|
||||
result = resultIter.next();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
bck = new Button(this, SWT.PUSH);
|
||||
bck.setText("<");
|
||||
bck.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
bck.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
searchFWD = false;
|
||||
nextSearchMatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
fwd = new Button(this, SWT.PUSH);
|
||||
fwd.setText(">");
|
||||
fwd.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
fwd.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
searchFWD = true;
|
||||
nextSearchMatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
last = new Button(this, SWT.PUSH);
|
||||
last.setText(">>");
|
||||
last.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
last.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
searchFWD = true;
|
||||
MatchResult result = null;
|
||||
while (resultIter.hasNext()) {
|
||||
result = resultIter.next();
|
||||
}
|
||||
if (result == null && resultIter.hasPrevious()) {
|
||||
result = resultIter.previous();
|
||||
}
|
||||
if (result != null) {
|
||||
searchView.select(result.start(), result.end());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
caseSensitive = new Button(this, SWT.CHECK);
|
||||
caseSensitive.setText("Case");
|
||||
caseSensitive.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
|
||||
false));
|
||||
|
||||
searchKeyListener = new KeyListener() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (search(e)) {
|
||||
} else if (e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) {
|
||||
if (searchText == null
|
||||
|| !searchText.equals(searchTextBox.getText())) {
|
||||
searchText = searchTextBox.getText();
|
||||
updateMatches();
|
||||
}
|
||||
if (searchFWD) {
|
||||
fwd.setFocus();
|
||||
} else {
|
||||
bck.setFocus();
|
||||
}
|
||||
nextSearchMatch();
|
||||
} else {
|
||||
searchTextBox.setFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.addKeyListener(searchKeyListener);
|
||||
searchTextBox.addKeyListener(searchKeyListener);
|
||||
bck.addKeyListener(searchKeyListener);
|
||||
fwd.addKeyListener(searchKeyListener);
|
||||
caseSensitive.addKeyListener(searchKeyListener);
|
||||
|
||||
caseSensitive.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateMatches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
updateMatches();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean search(KeyEvent e) {
|
||||
boolean result = false;
|
||||
if (((e.stateMask & SWT.CTRL) == SWT.CTRL)) {
|
||||
if (e.keyCode == 'f' || e.keyCode == 'b' || e.keyCode == 'B') {
|
||||
searchFWD = e.keyCode == 'f' ? true : false;
|
||||
hide(false);
|
||||
// redraw();
|
||||
searchTextBox.setFocus();
|
||||
if (searchFWD) {
|
||||
fwd.setFocus();
|
||||
} else {
|
||||
bck.setFocus();
|
||||
}
|
||||
if (text == null) {
|
||||
reachedLimit();
|
||||
}
|
||||
if (searchText == null
|
||||
|| !searchText.equals(searchTextBox.getText())) {
|
||||
searchText = searchTextBox.getText();
|
||||
updateMatches();
|
||||
}
|
||||
nextSearchMatch();
|
||||
result = true;
|
||||
}
|
||||
} else if (e.keyCode == SWT.ESC) {
|
||||
hide(true);
|
||||
redraw();
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void hide(boolean isHidden) {
|
||||
((GridData) getLayoutData()).exclude = isHidden;
|
||||
setVisible(!isHidden);
|
||||
// if (searchView != null) {
|
||||
// searchView.removeHighlights();
|
||||
// }
|
||||
getParent().layout();
|
||||
}
|
||||
|
||||
/**
|
||||
* increment/decrement to next match. if at end of matches, increment to
|
||||
* next/previous leaf.
|
||||
*
|
||||
* @param tree2
|
||||
*/
|
||||
protected void nextSearchMatch() {
|
||||
boolean hasNextInSequence;
|
||||
|
||||
if (resultIter == null) {
|
||||
hasNextInSequence = false;
|
||||
} else {
|
||||
hasNextInSequence = searchFWD ? resultIter.hasNext() : resultIter
|
||||
.hasPrevious();
|
||||
}
|
||||
if (hasNextInSequence) {
|
||||
MatchResult current = searchFWD ? resultIter.next() : resultIter
|
||||
.previous();
|
||||
searchView.select(current.start(), current.end());
|
||||
} else {
|
||||
reachedLimit();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMatches() {
|
||||
int patternFlags = caseSensitive.getSelection() ? 0
|
||||
: Pattern.CASE_INSENSITIVE;
|
||||
|
||||
results.clear();
|
||||
|
||||
if (text == null) {
|
||||
reachedLimit();
|
||||
}
|
||||
|
||||
if (searchText != null) {
|
||||
Pattern pattern = Pattern.compile(searchText, patternFlags);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
results.add(matcher.toMatchResult());
|
||||
}
|
||||
|
||||
// HighlightSelection[] highlights = new HighlightSelection[results
|
||||
// .size()];
|
||||
// for (ListIterator<MatchResult> iter = results.listIterator();
|
||||
// iter
|
||||
// .hasNext();) {
|
||||
// int index = iter.nextIndex();
|
||||
// MatchResult mr = iter.next();
|
||||
// highlights[index] = new HighlightSelection(mr.start(), mr.end()
|
||||
// - mr.start());
|
||||
// }
|
||||
// searchView.setHighlights(highlights);
|
||||
|
||||
int index = searchFWD ? 0 : results.size();
|
||||
resultIter = results.listIterator(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void reachedLimit() {
|
||||
if (searchFWD) {
|
||||
searchView.reachedLast();
|
||||
} else {
|
||||
searchView.reachedFirst();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchView
|
||||
* the SearchView to set
|
||||
*/
|
||||
public void setSearchView(SearchView searchView) {
|
||||
this.searchView = searchView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text
|
||||
*/
|
||||
public String getText() {
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text
|
||||
* the text to set
|
||||
*/
|
||||
public void setText(String text) {
|
||||
if (this.text == null) {
|
||||
this.text = new StringBuilder();
|
||||
}
|
||||
this.text.setLength(0);
|
||||
this.text.append(text);
|
||||
updateMatches();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the searchKeyListener
|
||||
*/
|
||||
public KeyListener getSearchKeyListener() {
|
||||
return searchKeyListener;
|
||||
}
|
||||
|
||||
public void setDefaultSearchView(StyledText styledText) {
|
||||
setText(styledText.getText());
|
||||
setSearchView(new DefaultSearchView(styledText));
|
||||
}
|
||||
|
||||
public void appendText(String newText) {
|
||||
this.text.append(newText);
|
||||
updateMatches();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,425 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SearchComposite.SearchView;
|
||||
|
||||
/**
|
||||
* Browse, view, and search messages in the archive.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 22, 2012 bgonzale Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bgonzale
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SessionMsgArchiveBrowser extends Composite implements SearchView {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SessionMsgArchiveBrowser.class);
|
||||
|
||||
final Color INACTIVE_COLOR = Display.getCurrent().getSystemColor(
|
||||
SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
|
||||
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd.hhmmss");
|
||||
|
||||
final SimpleDateFormat newSdf = new SimpleDateFormat(
|
||||
"EEE d MMM yyyy HH:mm:ss z");
|
||||
|
||||
private StyledText logView;
|
||||
|
||||
private Label logName;
|
||||
|
||||
private List<TreeItem> leaves;
|
||||
|
||||
private ListIterator<TreeItem> leafIter;
|
||||
|
||||
private Tree tree;
|
||||
|
||||
private SearchComposite searchComp;
|
||||
|
||||
private String browserName;
|
||||
|
||||
private Object logDir;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public SessionMsgArchiveBrowser(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
this.setLayout(new GridLayout(1, true));
|
||||
this.setLayoutData(gd);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public SessionMsgArchiveBrowser(Composite parent, int style,
|
||||
LocalizationFile logDir) {
|
||||
this(parent, style);
|
||||
setDir(logDir);
|
||||
}
|
||||
|
||||
public void setDir(LocalizationFile logDir) {
|
||||
|
||||
if (this.logDir != null && this.logDir.equals(logDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (logDir == null) {
|
||||
UserId user = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
logDir = SessionMsgArchive.getArchiveDir(user.getHost(),
|
||||
user.getName(), null);
|
||||
}
|
||||
this.logDir = logDir;
|
||||
setBrowserName(logDir);
|
||||
populateTree(tree, leaves, logDir);
|
||||
leafIter = leaves.listIterator();
|
||||
} catch (ParseException e) {
|
||||
statusHandler
|
||||
.error("Unable to parse log directory tree to produce collaboration log view",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
SashForm mainForm = new SashForm(this, SWT.HORIZONTAL);
|
||||
mainForm.setLayout(new GridLayout(2, false));
|
||||
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gd.widthHint = 800;
|
||||
gd.heightHint = 600;
|
||||
mainForm.setLayoutData(gd);
|
||||
|
||||
Composite childBarComp = new Composite(mainForm, SWT.NONE);
|
||||
childBarComp.setLayout(new GridLayout(1, false));
|
||||
childBarComp
|
||||
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
tree = new Tree(childBarComp, SWT.BORDER);
|
||||
leaves = new ArrayList<TreeItem>();
|
||||
leafIter = leaves.listIterator();
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gd.heightHint = 300;
|
||||
gd.widthHint = 400;
|
||||
tree.setLayoutData(gd);
|
||||
|
||||
Composite logViewPart = new Composite(mainForm, SWT.NONE);
|
||||
logViewPart.setLayout(new GridLayout(1, false));
|
||||
logViewPart.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
|
||||
|
||||
Composite logHeaderPart = new Composite(logViewPart, SWT.NONE);
|
||||
logHeaderPart.setLayout(new GridLayout(1, false));
|
||||
logHeaderPart.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false,
|
||||
false));
|
||||
|
||||
logName = new Label(logHeaderPart, SWT.READ_ONLY);
|
||||
gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
|
||||
gd.widthHint = 180;
|
||||
logName.setLayoutData(gd);
|
||||
|
||||
logView = new StyledText(logViewPart, SWT.V_SCROLL | SWT.H_SCROLL
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
logView.setLayoutData(gd);
|
||||
logView.setEditable(false);
|
||||
|
||||
searchComp = new SearchComposite(logViewPart, SWT.BORDER);
|
||||
searchComp.setSearchView(this);
|
||||
searchComp.hide(true);
|
||||
|
||||
tree.addKeyListener(searchComp.getSearchKeyListener());
|
||||
logView.addKeyListener(searchComp.getSearchKeyListener());
|
||||
|
||||
tree.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
Object data = event.item.getData();
|
||||
if (data != null) {
|
||||
TreeItem tItem = (TreeItem) event.item;
|
||||
setLogView(tItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
mainForm.setWeights(new int[] { 30, 70 });
|
||||
mainForm.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current leaf displayed in the log viewer. If search is on, then
|
||||
*
|
||||
* @param tItem
|
||||
*/
|
||||
private void setLogView(TreeItem tItem) {
|
||||
Object data = tItem.getData();
|
||||
|
||||
if (data != null) {
|
||||
tItem.setExpanded(true);
|
||||
tItem.getParent().setSelection(tItem);
|
||||
|
||||
try {
|
||||
LocalizationFile lFile = (LocalizationFile) tItem.getData();
|
||||
File file = lFile.getFile(true);
|
||||
|
||||
if (file != null && file.exists()) {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
FileReader fReader = new FileReader(file);
|
||||
|
||||
reader = new BufferedReader(fReader);
|
||||
char[] cbuf = new char[1024];
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (reader.read(cbuf) != -1) {
|
||||
sb.append(cbuf);
|
||||
}
|
||||
logName.setText(tItem.getText());
|
||||
searchComp.setText(sb.toString());
|
||||
logView.setText(sb.toString());
|
||||
logView.setStyleRange(null);
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler
|
||||
.error("Unable to retrieve collaboration log file from localization",
|
||||
e);
|
||||
} catch (FileNotFoundException e) {
|
||||
statusHandler
|
||||
.error("Unable to find collaboration log file in localization",
|
||||
e);
|
||||
} catch (IOException e) {
|
||||
statusHandler
|
||||
.error("Unable to read collaboration log file from localization",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populateTree(Tree tree, List<TreeItem> leaves,
|
||||
LocalizationFile logDir) throws ParseException {
|
||||
|
||||
tree.clearAll(true);
|
||||
leaves.clear();
|
||||
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext[] contexts = pm.getLocalSearchHierarchy(logDir
|
||||
.getContext().getLocalizationType());
|
||||
LocalizationFile[] files = pm.listFiles(contexts, logDir.getName(),
|
||||
null, true, true); // Win32
|
||||
|
||||
Map<String, TreeItem> itemMap = new HashMap<String, TreeItem>(
|
||||
files.length);
|
||||
for (final LocalizationFile lFile : files) {
|
||||
String name = lFile.getName().replaceFirst(
|
||||
logDir.getName() + File.separator, "");
|
||||
String[] parts = name.split(File.separator);
|
||||
String parentPath = "";
|
||||
for (int i = 0; i < parts.length; ++i) {
|
||||
String part = parts[i];
|
||||
TreeItem parentItem = itemMap.get(parentPath);
|
||||
|
||||
parentPath += File.separator + part;
|
||||
TreeItem item = itemMap.get(parentPath);
|
||||
if (item == null) {
|
||||
if (parentItem == null) {
|
||||
item = new TreeItem(tree, SWT.NONE);
|
||||
} else {
|
||||
item = new TreeItem(parentItem, SWT.NONE);
|
||||
}
|
||||
|
||||
boolean isLeaf = (i == parts.length - 1);
|
||||
|
||||
if (isLeaf) {
|
||||
item.setData(lFile);
|
||||
|
||||
String datePart = part.substring(0,
|
||||
part.lastIndexOf("."));
|
||||
Date d = sdf.parse(datePart);
|
||||
item.setText(newSdf.format(d));
|
||||
leaves.add(item);
|
||||
} else {
|
||||
item.setForeground(INACTIVE_COLOR);
|
||||
item.setText(part);
|
||||
}
|
||||
item.setExpanded(!isLeaf);
|
||||
itemMap.put(parentPath, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(int start, int end) {
|
||||
logView.setSelection(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* searching forward, reached last item.
|
||||
*/
|
||||
@Override
|
||||
public void reachedLast() {
|
||||
TreeItem selected = null;
|
||||
TreeItem[] arr = tree.getSelection();
|
||||
|
||||
if (arr.length > 0) {
|
||||
selected = arr[0];
|
||||
} else {
|
||||
selected = leaves.get(0);
|
||||
}
|
||||
if (leafIter.hasNext()) {
|
||||
selected = leafIter.next();
|
||||
} else {
|
||||
leafIter = leaves.listIterator();
|
||||
selected = leafIter.next();
|
||||
}
|
||||
setLogView(selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* searching backward, reached first item.
|
||||
*/
|
||||
@Override
|
||||
public void reachedFirst() {
|
||||
TreeItem selected = null;
|
||||
TreeItem[] arr = tree.getSelection();
|
||||
|
||||
if (arr.length > 0) {
|
||||
selected = arr[0];
|
||||
} else {
|
||||
selected = leaves.get(0);
|
||||
}
|
||||
if (leafIter.hasPrevious()) {
|
||||
selected = leafIter.previous();
|
||||
} else {
|
||||
int index = leaves.size();
|
||||
leafIter = leaves.listIterator(index);
|
||||
selected = leafIter.previous();
|
||||
}
|
||||
setLogView(selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the browserName
|
||||
*/
|
||||
public String getBrowserName() {
|
||||
return browserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param logDir
|
||||
* the logDir that defines the browserName
|
||||
*/
|
||||
private void setBrowserName(LocalizationFile logDir) {
|
||||
String name = logDir.getName();
|
||||
String[] parts = name.split(File.separator);
|
||||
|
||||
if (parts.length > 0) {
|
||||
String lastPart = parts[parts.length - 1];
|
||||
|
||||
if (lastPart == null || lastPart.isEmpty()) {
|
||||
if (parts.length > 1) {
|
||||
lastPart = parts[parts.length - 2];
|
||||
}
|
||||
}
|
||||
this.browserName = "Log: " + lastPart;
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setHighlights(HighlightSelection[] selections) {
|
||||
// StyleRange[] ranges = new StyleRange[selections.length];
|
||||
// for (int i = 0; i < selections.length; ++i) {
|
||||
// HighlightSelection sel = selections[i];
|
||||
// ranges[i] = new StyleRange(sel.start, sel.length,
|
||||
// logView.getBackground(), HIGHLIGHT_COLOR);
|
||||
// }
|
||||
// logView.setStyleRanges(ranges);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void removeHighlights() {
|
||||
// StyleRange[] ranges = logView.getStyleRanges();
|
||||
// for (StyleRange style : ranges) {
|
||||
// if (style.background == HIGHLIGHT_COLOR) {
|
||||
// style.background = logView.getBackground();
|
||||
// }
|
||||
// }
|
||||
// logView.setStyleRanges(ranges);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Dialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 22, 2012 bgonzale Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bgonzale
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SessionMsgArchiveDialog extends Dialog {
|
||||
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
public SessionMsgArchiveDialog(Shell parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public SessionMsgArchiveDialog(Shell parent, int style) {
|
||||
super(parent, style);
|
||||
}
|
||||
|
||||
public void open(LocalizationFile logDir) {
|
||||
Shell parent = getParent();
|
||||
|
||||
shell = new Shell(parent.getDisplay(), SWT.TITLE | SWT.RESIZE);
|
||||
shell.setText(getText());
|
||||
shell.setLayout(new GridLayout(1, false));
|
||||
|
||||
SessionMsgArchiveBrowser smab = new SessionMsgArchiveBrowser(shell,
|
||||
SWT.NONE, logDir);
|
||||
|
||||
shell.pack();
|
||||
shell.open();
|
||||
|
||||
// Wait until the shell is disposed.
|
||||
Display display = parent.getDisplay();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.viz.ui.views.CaveFloatingView;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 22, 2012 bgonzale Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bgonzale
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SessionMsgArchiveView extends CaveFloatingView {
|
||||
|
||||
private SessionMsgArchiveBrowser browser;
|
||||
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
super.createPartControl(parent);
|
||||
browser = new SessionMsgArchiveBrowser(parent, SWT.NONE);
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
parent.layout();
|
||||
}
|
||||
|
||||
public void setDir(LocalizationFile dir) {
|
||||
browser.setDir(dir);
|
||||
setPartName(browser.getBrowserName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue