use of javax.swing.JProgressBar in project logisim-evolution by reds-heig.
the class VivadoDownload method Download.
public static boolean Download(String scriptPath, String sandboxPath, FPGAReport myReporter, boolean downloadOnly) {
GridBagConstraints gbc = new GridBagConstraints();
JFrame panel = new JFrame("Vivado Downloading");
panel.setResizable(false);
panel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
GridBagLayout thisLayout = new GridBagLayout();
panel.setLayout(thisLayout);
// PointerInfo mouseloc = MouseInfo.getPointerInfo();
// Point mlocation = mouseloc.getLocation();
// panel.setLocation(mlocation.x, mlocation.y);
JLabel locText = new JLabel("Generating FPGA files and performing download; this may take a while");
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel.add(locText, gbc);
JProgressBar progres = new JProgressBar(0, 3);
progresVal = 0;
progres.setValue(progresVal);
progres.setStringPainted(true);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel.add(progres, gbc);
panel.pack();
panel.setLocation(Projects.getCenteredLoc(panel.getWidth(), panel.getHeight() * 4));
panel.setVisible(true);
Rectangle labelRect = locText.getBounds();
labelRect.x = 0;
labelRect.y = 0;
locText.paintImmediately(labelRect);
VendorSoftware vivadoVendor = VendorSoftware.getSoftware(VendorSoftware.VendorVivado);
// Create Vivado project
if (!downloadOnly) {
boolean status = executeTclScript(vivadoVendor.getBinaryPath(0), scriptPath + File.separator + CREATE_PROJECT_TCL, "Create Vivado project", sandboxPath, myReporter, locText, progres);
if (!status) {
panel.dispose();
return false;
}
}
// Generate bitstream
if (!downloadOnly) {
boolean status = executeTclScript(vivadoVendor.getBinaryPath(0), scriptPath + File.separator + GENERATE_BITSTREAM_FILE, "Generate bitstream", sandboxPath, myReporter, locText, progres);
if (!status) {
panel.dispose();
return false;
}
boolean bitFileExists = new File(_bitStreamPath).exists();
if (!bitFileExists) {
myReporter.AddFatalError("Could not generate bitfile! Check Console tab for more details.");
panel.dispose();
return false;
}
}
// Download to board
// only if the bitfile exists
boolean bitFileExists = new File(_bitStreamPath).exists();
if (bitFileExists) {
Object[] options = { "Yes, download", "No, abort" };
if (JOptionPane.showOptionDialog(progres, "Verify that your board is connected and you are ready to download.", "Ready to download ?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]) != JOptionPane.YES_OPTION) {
myReporter.AddWarning("Download aborted.");
panel.dispose();
return false;
}
boolean status = executeTclScript(vivadoVendor.getBinaryPath(0), scriptPath + File.separator + LOAD_BITSTEAM_FILE, "Downloading bitfile", sandboxPath, myReporter, locText, progres);
panel.dispose();
return status;
} else {
myReporter.AddFatalError("No bitfile found!");
panel.dispose();
return false;
}
}
use of javax.swing.JProgressBar in project CCDD by nasa.
the class CcddSchedulerHandler method autoFill.
/**
********************************************************************************************
* Automatically fill the variables/applications in messages/time slots corresponding to their
* rate
********************************************************************************************
*/
protected void autoFill() {
canceled = false;
cancelDialog = new HaltDialog();
progBar = new JProgressBar();
progress = 0;
// Create the panel to contain the progress/cancellation dialog components
final JPanel dialogPnl = new JPanel(new GridBagLayout());
// Get the scheduler dialog type
final SchedulerType schedulerType = getSchedulerOption();
// Get the text that describes the type of object being assigned
final String variableType = schedulerType == SchedulerType.TELEMETRY_SCHEDULER ? "variables" : (schedulerType == SchedulerType.APPLICATION_SCHEDULER ? "applications" : "unknown");
// Create a thread to perform the auto-fill operation in the background
final Thread progressThread = new Thread(new Runnable() {
/**
************************************************************************************
* Auto-fill the telemetry messages (if this is the telemetry scheduler) or application
* time slots (if this is the application scheduler). Note that in the comments below
* 'variable' is used to describe the object being assigned, which is accurate for the
* telemetry scheduler. For the application scheduler substitute 'application' for
* 'variable'
************************************************************************************
*/
@Override
public void run() {
int numVariables = 0;
int unassigned = 0;
// Get an array of the available rates
String[] availableRates = schedulerInput.getAvailableRates();
// variables at each rate until no more rates are available
for (String rate : availableRates) {
// out using HTML tags
if (!rate.startsWith("<html>")) {
// Check if this is a telemetry scheduler
if (schedulerType == SchedulerType.TELEMETRY_SCHEDULER) {
// Get the reference to the variable tree in order to shorten the
// subsequent call
CcddTableTreeHandler variableTree = ((CcddTelemetrySchedulerInput) schedulerInput).getVariableTree();
// Add the number of unassigned variables at the given rate.
// getVariablesAtRate() could be used, but it performs other operations
// associated with links and is slower
numVariables += variableTree.getPrimitiveVariablePaths(variableTree.getRootNode(), true).size();
} else // Check if this is an application scheduler
if (schedulerType == SchedulerType.APPLICATION_SCHEDULER) {
// Add the number of unassigned applications at the given rate
numVariables += schedulerInput.getVariablesAtRate(rate).size();
}
}
}
// Check if there are any variables to assign
if (numVariables != 0) {
// Update the progress bar now that the number of variables is known
progBar.setMaximum(numVariables);
progBar.setIndeterminate(false);
// Total size of the variable or link
int totalSize;
// Message option to which the variable or link will be added
String option;
// Variable that will be added
Variable variable;
// Variables that will be removed from the remaining list
List<Variable> removedVars = new ArrayList<Variable>();
// List of variables at a given rate
List<Variable> varList;
// List of the variables to exclude from the Variables tree. This should be all
// of the variables unless there are any that can't be assigned
List<String> excludedVars = new ArrayList<String>();
// variables at each rate until no more rates are available
for (String rate : availableRates) {
// Check if the user canceled auto-fill
if (canceled) {
break;
}
// grayed out using HTML tags
if (!rate.startsWith("<html>")) {
// Show the current rate being processed in the progress bar
progBar.setString("Assigning " + rate + " Hz " + variableType);
// Get the rate as a floating point value
float rateVal = CcddUtilities.convertStringToFloat(rate);
// Get a list of all variables at the given rate (ones already assigned
// are not included)
varList = schedulerInput.getVariablesAtRate(rate);
// Sort the list from largest to smallest
Collections.sort(varList);
// Loop through the list of variables until all are removed
while (!varList.isEmpty()) {
// Check if the user canceled padding adjustment
if (canceled) {
break;
}
// Total size of the variable or link
totalSize = 0;
// Set to the first variable in the list
variable = varList.get(0);
// Check if the variable is linked
if (variable.getLink() != null) {
// Step through each variable in the variable list
for (Variable linkVar : varList) {
// variable
if (linkVar.getLink() != null && linkVar.getLink().equals(variable.getLink())) {
// Add the variable's size to the total size
totalSize += variable.getSize();
// Add the variable to the list of removed variables
removedVars.add(linkVar);
}
}
} else // The variable is unlinked
{
// Check if this is a telemetry scheduler
if (schedulerType == SchedulerType.TELEMETRY_SCHEDULER) {
// Set total size to the given variable's size
totalSize = variable.getSize();
// Get the total size (in bytes) and the list of the
// variable, or variables if this variable is associated
// with others due to bit-packing or string membership and
// therefore must be placed together in a message
AssociatedVariable associates = ((CcddTelemetrySchedulerInput) schedulerInput).getAssociatedVariables(varList);
// Set the total size to that of the associated variable(s)
// and add the variable(s) to the list of those to be
// removed
totalSize = associates.getTotalSize();
removedVars.addAll(associates.getAssociates());
} else // This is an application (or unknown type of) scheduler
{
// Set total size to the given variable's size
totalSize = variable.getSize();
// Add the variable to the list of removed variables
removedVars.add(variable);
}
}
// Find the option with the most room
option = getMessageWithRoom(rateVal, totalSize);
// Check to make sure there is an option
if (option != null) {
// Parse the option string to extract the sub-index (if this is
// a sub-option) and the message indices
Object[] parsedIndices = parseOption(option);
// Add the variable to the given message. If a sub-index is not
// given it will be set to -1. Add the list of added variables
// to the list of those to exclude in the Variables tree
excludedVars.addAll(addVariableToMessage(removedVars, (Integer[]) parsedIndices[1], (int) parsedIndices[0]));
} else // No option is available
{
// Increment the unplaced variable counter
unassigned++;
}
// Remove all the variables in removed variables list. This
// includes variables that did not fit into the telemetry table
varList.removeAll(removedVars);
// Clear the removed variables list
removedVars.clear();
// Update the auto-fill progress
progBar.setValue(progress);
progress++;
}
}
}
// Check if the auto-fill operation wasn't canceled by the user
if (!canceled) {
// Close the auto-fill progress/cancellation dialog
cancelDialog.closeDialog(CANCEL_BUTTON);
}
// Perform any updates needed following adding variables to messages
updateAfterVariableAdded();
// Set the variable tree to exclude the variable(s)
setVariableUnavailable(excludedVars);
// Display the originally selected rate's variable tree
schedulerInput.updateVariableTree(rateFilter.getSelectedItem().toString());
// Update the remaining bytes column values
schedulerEditor.updateRemainingBytesColumn();
// Update the unused bytes/time field
setUnusedField();
// Update the assigned variables/applications list panel
schedulerEditor.updateAssignmentList();
// Update the scheduler dialog's change indicator
getSchedulerDialog().updateChangeIndicator();
// Check if there are items that are not assigned
if (unassigned != 0) {
// Inform the user if there are items that are not assigned
new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b> Auto-fill unable to assign " + unassigned + " " + variableType, "Auto-fill", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
}
} else // There are no unassigned variables
{
// user
if (!canceled) {
// Close the auto-fill progress/cancellation dialog
cancelDialog.closeDialog(CANCEL_BUTTON);
}
new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b>All " + variableType + " with a rate are already assigned", "Auto-fill", JOptionPane.INFORMATION_MESSAGE, DialogOption.OK_OPTION);
}
}
});
// Execute the command in the background
CcddBackgroundCommand.executeInBackground(ccddMain, schedulerDlg.getDialog(), new BackgroundCommand() {
/**
************************************************************************************
* Build and display the auto-fill progress/cancellation dialog. This is done as a
* background operation so that the
************************************************************************************
*/
@Override
protected void execute() {
// Set the initial layout manager characteristics
GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing(), 0, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing()), 0, 0);
// Build the progress/cancellation dialog
dialogPnl.setBorder(BorderFactory.createEmptyBorder());
JLabel textLbl = new JLabel("<html><b>Assigning " + variableType + "...</b><br><br>", SwingConstants.LEFT);
textLbl.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
gbc.gridy++;
dialogPnl.add(textLbl, gbc);
JLabel textLbl2 = new JLabel("<html><b>" + CcddUtilities.colorHTMLText("*** Press </i>Halt<i> " + "to terminate auto-fill ***", Color.RED) + "</b><br><br>", SwingConstants.CENTER);
textLbl2.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
gbc.gridy++;
dialogPnl.add(textLbl2, gbc);
// Add a progress bar to the dialog
progBar.setIndeterminate(true);
progBar.setMinimum(0);
progBar.setValue(0);
progBar.setString("Calculating number of variables");
progBar.setStringPainted(true);
progBar.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
gbc.insets.right = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
gbc.insets.bottom = 0;
gbc.gridy++;
dialogPnl.add(progBar, gbc);
// the dialog if there are no variables to assign
if (!canceled) {
// Display the auto-fill progress/cancellation dialog
cancelDialog.showOptionsDialog(schedulerDlg.getDialog(), dialogPnl, "Auto-fill " + (schedulerType == SchedulerType.TELEMETRY_SCHEDULER ? "Telemetry Messages" : (schedulerType == SchedulerType.APPLICATION_SCHEDULER ? "Time Slots" : "")), DialogOption.HALT_OPTION, false, true);
}
}
});
// Perform the auto-fill operation in a background thread
progressThread.start();
}
use of javax.swing.JProgressBar in project CCDD by nasa.
the class CcddDbVerificationHandler method verifyDatabase.
/**
********************************************************************************************
* Perform a consistency check of the project database. Query the user for permission to make
* corrections, then apply the corrections at completion of the check. This method is executed
* in a separate thread since it can take a noticeable amount time to complete, and by using a
* separate thread the GUI is allowed to continue to update. The GUI menu commands, however,
* are disabled until the table data consistency check completes execution
********************************************************************************************
*/
private void verifyDatabase() {
CcddBackgroundCommand.executeInBackground(ccddMain, new BackgroundCommand() {
/**
************************************************************************************
* Verification cancellation dialog class
************************************************************************************
*/
@SuppressWarnings("serial")
class HaltDialog extends CcddDialogHandler {
/**
********************************************************************************
* Handle the close dialog button action
********************************************************************************
*/
@Override
protected void closeDialog(int button) {
// Set the flag to cancel verification
canceled = true;
super.closeDialog(button);
}
}
HaltDialog cancelDialog = new HaltDialog();
/**
************************************************************************************
* Perform project database verification
************************************************************************************
*/
@Override
protected void execute() {
// Set the initial layout manager characteristics
GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing(), 0, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing()), 0, 0);
// Create the cancellation dialog
JPanel dialogPnl = new JPanel(new GridBagLayout());
dialogPnl.setBorder(BorderFactory.createEmptyBorder());
JLabel textLbl = new JLabel("<html><b>Verification in progress...<br><br>", SwingConstants.LEFT);
textLbl.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
gbc.gridy++;
dialogPnl.add(textLbl, gbc);
JLabel textLbl2 = new JLabel("<html><b>" + CcddUtilities.colorHTMLText("*** Press </i>Halt<i> " + "to terminate verification ***", Color.RED) + "</b><br><br>", SwingConstants.CENTER);
textLbl2.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
gbc.gridy++;
dialogPnl.add(textLbl2, gbc);
// Set the total number of verification steps (this is the number of methods called
// to verify each portion of the database) and use it to calculate the number of
// divisions within each step
int numVerificationSteps = 6;
numDivisionPerStep = 100 / numVerificationSteps;
// Add a progress bar to the dialog
progBar = new JProgressBar(0, numVerificationSteps * numDivisionPerStep);
progBar.setValue(0);
progBar.setString("Verify owners");
progBar.setStringPainted(true);
progBar.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
gbc.insets.right = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
gbc.insets.bottom = 0;
gbc.gridy++;
dialogPnl.add(progBar, gbc);
// Display the verification cancellation dialog
cancelDialog.showOptionsDialog(ccddMain.getMainFrame(), dialogPnl, "Verifying Project", DialogOption.HALT_OPTION, false, false);
// Set flags indicating no changes are pending, no inconsistencies exist, and the
// user hasn't canceled the check
isChanges = false;
try {
// Get the comments for all data tables
comments = dbTable.queryDataTableComments(ccddMain.getMainFrame());
// Get metadata for all tables
ResultSet tableResult = dbCommand.getConnection().getMetaData().getTables(null, null, null, new String[] { "TABLE" });
// Check if verification isn't canceled
if (!canceled) {
// Check for inconsistencies in the owner role of the project database and
// its tables, sequences, indices, and functions
verifyOwners();
// Check if verification isn't canceled
if (!canceled) {
// Update the progress bar
progBar.setValue(numDivisionPerStep);
progBar.setString("Verify internal tables");
// Check for inconsistencies in the internal tables
verifyInternalTables(tableResult);
// Check if verification isn't canceled
if (!canceled) {
// Update the progress bar
progBar.setValue(numDivisionPerStep * 2);
progBar.setString("Verify path references");
// Verify the table and variable path references in the internal
// tables
verifyPathReferences(tableResult);
// Check if verification isn't canceled
if (!canceled) {
// Update the progress bar
progBar.setValue(numDivisionPerStep * 3);
progBar.setString("Verify input data types");
// verify the input data types in the table types and data
// fields internal tables
verifyInputTypes(tableResult);
// Check if verification isn't canceled
if (!canceled) {
// Update the progress bar
progBar.setValue(numDivisionPerStep * 4);
progBar.setString("Verify table types");
// Check for inconsistencies between the table type
// definitions and the tables of that type
verifyTableTypes(tableResult);
// Check if verification isn't canceled
if (!canceled) {
// Update the progress bar
progBar.setValue(numDivisionPerStep * 5);
progBar.setString("Verify data tables");
// Check for inconsistencies within the data tables
verifyDataTables();
// Update the progress bar
progBar.setValue(numDivisionPerStep * numVerificationSteps);
}
}
}
}
}
}
} catch (SQLException se) {
// Inform the user that obtaining the project database metadata failed
eventLog.logFailEvent(ccddMain.getMainFrame(), "Error obtaining project database '" + dbControl.getDatabaseName() + "' metadata; cause '" + se.getMessage() + "'", "<html><b>Error obtaining project database '" + dbControl.getDatabaseName() + "'metadata");
} catch (Exception e) {
// Display a dialog providing details on the unanticipated error
CcddUtilities.displayException(e, ccddMain.getMainFrame());
}
}
/**
************************************************************************************
* Project database verification command complete
************************************************************************************
*/
@Override
protected void complete() {
// Check if the user didn't cancel verification
if (!canceled) {
// Close the cancellation dialog
cancelDialog.closeDialog();
// Perform any corrections to the database authorized by the user
updateDatabase();
} else // Verification was canceled
{
// Note that verification was canceled in the event log
eventLog.logEvent(STATUS_MSG, "Verification terminated by user");
}
}
});
}
use of javax.swing.JProgressBar in project elki by elki-project.
the class LogPanel method removeProgressBar.
/**
* Remove a progress bar
*
* @param prog Progress
* @param pbar Associated progress bar
*/
private void removeProgressBar(Progress prog, JProgressBar pbar) {
synchronized (pbarmap) {
pbarmap.remove(prog);
final JProgressBar pbar2 = pbar;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
removeProgressBar(pbar2);
}
});
}
}
use of javax.swing.JProgressBar in project elki by elki-project.
the class LogPanel method getOrCreateProgressBar.
/**
* Get an existing or create a new progress bar.
*
* @param prog Progress
* @return Associated progress bar.
*/
private JProgressBar getOrCreateProgressBar(Progress prog) {
JProgressBar pbar = pbarmap.get(prog);
// Add a new progress bar.
if (pbar == null) {
synchronized (pbarmap) {
if (prog instanceof FiniteProgress) {
pbar = new JProgressBar(0, ((FiniteProgress) prog).getTotal());
pbar.setStringPainted(true);
} else if (prog instanceof IndefiniteProgress) {
pbar = new JProgressBar();
pbar.setIndeterminate(true);
pbar.setStringPainted(true);
} else if (prog instanceof MutableProgress) {
pbar = new JProgressBar(0, ((MutableProgress) prog).getTotal());
pbar.setStringPainted(true);
} else {
throw new RuntimeException("Unsupported progress record");
}
pbarmap.put(prog, pbar);
final JProgressBar pbar2 = pbar;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
addProgressBar(pbar2);
}
});
}
}
return pbar;
}
Aggregations