-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
518 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ source.. = src/ | |
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.xml | ||
plugin.xml,\ | ||
icons/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...orm/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/AlertExportWizard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.subgraph.vega.ui.util.export; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.jface.wizard.Wizard; | ||
|
||
import com.subgraph.vega.api.model.alerts.IScanAlert; | ||
import com.subgraph.vega.api.model.alerts.IScanInstance; | ||
import com.subgraph.vega.export.AlertExporter; | ||
|
||
public class AlertExportWizard extends Wizard { | ||
|
||
protected ExportWizardPageOne one; | ||
protected ExportWizardPageTwo two; | ||
protected ExportWizardPageThree three; | ||
private IScanInstance scanInstance = null; | ||
|
||
public AlertExportWizard(IScanInstance s) { | ||
super(); | ||
scanInstance = s; | ||
} | ||
|
||
public AlertExportWizard() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void addPages() { | ||
one = new ExportWizardPageOne(); | ||
two = new ExportWizardPageTwo(scanInstance); | ||
three = new ExportWizardPageThree(); | ||
addPage(one); | ||
addPage(two); | ||
addPage(three); | ||
|
||
} | ||
|
||
@Override | ||
public boolean performFinish() { | ||
// TODO Auto-generated method stub | ||
|
||
|
||
List<IScanAlert> alerts; | ||
alerts = two.allAlertsFromTree(); | ||
System.out.println(alerts.size()); | ||
|
||
AlertExporter exporter = new AlertExporter(); | ||
exporter.exportAlertsbyList(alerts); | ||
|
||
return true; | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
...m/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageOne.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.subgraph.vega.ui.util.export; | ||
|
||
|
||
|
||
import org.eclipse.jface.wizard.WizardPage; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionAdapter; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.layout.RowLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Group; | ||
import org.eclipse.swt.widgets.Label; | ||
|
||
public class ExportWizardPageOne extends WizardPage { | ||
|
||
|
||
private Composite container; | ||
private Group radioGroup; | ||
private String choice = "HTML"; | ||
|
||
protected ExportWizardPageOne() { | ||
super("Output format"); | ||
setTitle("Output format"); | ||
setDescription("HTML or XML output format."); | ||
|
||
} | ||
|
||
@Override | ||
public void createControl(Composite parent) { | ||
|
||
container = new Composite(parent, SWT.NONE); | ||
|
||
GridData gd = new GridData(); | ||
gd.grabExcessHorizontalSpace = true; | ||
container.setLayoutData(gd); | ||
|
||
GridLayout layout = new GridLayout(); | ||
|
||
container.setLayout(layout); | ||
layout.numColumns = 1; | ||
|
||
/*Label l = new Label(container, SWT.NONE); | ||
l.setText("Select XML or HTML output.");*/ | ||
|
||
|
||
radioGroup = new Group(container, SWT.SHADOW_IN); | ||
radioGroup.setText("Select XML or HTML output."); | ||
gd.grabExcessHorizontalSpace = true; | ||
radioGroup.setLayoutData(gd); | ||
|
||
radioGroup.setLayout(new RowLayout(SWT.VERTICAL)); | ||
Button htmlButton = new Button(radioGroup, SWT.RADIO); | ||
Button xmlButton = new Button(radioGroup, SWT.RADIO); | ||
xmlButton.setText("XML"); | ||
htmlButton.setText("HTML"); | ||
htmlButton.setSelection(true); | ||
xmlButton.addSelectionListener(new SelectionAdapter() { | ||
|
||
public void widgetSelected(SelectionEvent e) { | ||
choice = xmlButton.getText(); | ||
} | ||
}); | ||
|
||
htmlButton.addSelectionListener(new SelectionAdapter() { | ||
|
||
public void widgetSelected(SelectionEvent e) { | ||
choice = xmlButton.getText(); | ||
} | ||
}); | ||
|
||
setControl(container); | ||
|
||
} | ||
|
||
protected String getChoice() { | ||
return this.choice; | ||
} | ||
|
||
} |
109 changes: 109 additions & 0 deletions
109
...com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageThree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.subgraph.vega.ui.util.export; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import org.eclipse.jface.wizard.IWizardPage; | ||
import org.eclipse.jface.wizard.WizardPage; | ||
import org.eclipse.swt.SWT; | ||
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.FileDialog; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.swt.widgets.Text; | ||
|
||
public class ExportWizardPageThree extends WizardPage { | ||
|
||
protected FileDialog dialog; | ||
protected Text textField; | ||
protected Composite container; | ||
private String saveFilename = null; | ||
private String filename = null; | ||
|
||
final static int VISIBLE_PATH_LENGTH = 255; | ||
|
||
protected ExportWizardPageThree() { | ||
super("Output destination"); | ||
|
||
|
||
|
||
setTitle("Destination for report output."); | ||
|
||
} | ||
|
||
@Override | ||
public void createControl(Composite parent) { | ||
|
||
container = new Composite(parent, SWT.NONE); | ||
|
||
GridLayout layout = new GridLayout(); | ||
container.setLayout(layout); | ||
layout.numColumns = 2; | ||
|
||
Label label = new Label(container, SWT.NONE); | ||
label.setText("Choose file:"); | ||
textField = new Text(container, SWT.READ_ONLY | SWT.FILL); | ||
textField.setSize(VISIBLE_PATH_LENGTH, textField.getSize().y); | ||
Button button = new Button(container, SWT.NONE); | ||
button.setText("Open"); | ||
|
||
GridData buttonGridData = new GridData(); | ||
buttonGridData.horizontalSpan = 2; | ||
buttonGridData.horizontalAlignment = SWT.END; | ||
button.setLayoutData(buttonGridData); | ||
|
||
GridData textFieldGridData = new GridData(); | ||
textFieldGridData.widthHint = 300; | ||
textField.setLayoutData(textFieldGridData); | ||
|
||
button.addSelectionListener (new SelectionListener() { | ||
|
||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
doFileDialog(parent.getShell()); | ||
} | ||
|
||
@Override | ||
public void widgetDefaultSelected(SelectionEvent e) { | ||
// TODO Auto-generated method stub | ||
|
||
}}); | ||
|
||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); | ||
filename = "Vega-report-"+dateFormat.format(new Date()); | ||
|
||
IWizardPage pageOne = getPreviousPage().getPreviousPage(); | ||
String ext = ((ExportWizardPageOne) pageOne).getChoice(); | ||
|
||
if (ext.equals("HTML")) { | ||
filename += ".html"; | ||
} else if (ext.equals("XML")){ | ||
filename += ".xml"; | ||
} | ||
|
||
setPageComplete(false); | ||
setControl(container); | ||
} | ||
|
||
private void doFileDialog(Shell shell) { | ||
dialog = new FileDialog(shell, SWT.SAVE); | ||
dialog.setText("Choose an output file"); | ||
|
||
dialog.setFileName(filename); | ||
saveFilename = dialog.open(); | ||
if (saveFilename != null) { | ||
textField.setText(saveFilename); | ||
setPageComplete(true); | ||
} | ||
} | ||
|
||
String getSaveFilename() { | ||
return saveFilename; | ||
} | ||
} |
Oops, something went wrong.