public void doPaste() { JTable table = editor.getSeriesDataMatrix().myTable; int col = table.getSelectedColumn(); int row = table.getSelectedRow(); ArrayList<Integer> values = getValuesFromClipboard(); if (values == null || values.size() == 0) { Alert.message( App.mainWindow, "Paste failed", "Paste failed. Check the data you are pasting is a column list of integers"); return; } for (Integer value : values) { if (table.isCellEditable(row, col)) { table.setValueAt(value, row, col); } else { log.error("Failed"); Alert.message( App.mainWindow, "Paste failed", "Paste failed. Check the data you are pasting is a column list of integers"); return; } TableCoords nextCell = ((DecadalModel) table.getModel()).getCoordsOfNextCell(row, col); row = nextCell.getRow(); col = nextCell.getCol(); } }
private void lookupUsersAndGroups() { PermissionsEntityType pEntityType; if (theentity instanceof TridasObject) { pEntityType = PermissionsEntityType.OBJECT; } else if (theentity instanceof TridasElement) { pEntityType = PermissionsEntityType.ELEMENT; } else if (theentity instanceof TridasMeasurementSeries) { pEntityType = PermissionsEntityType.MEASUREMENT_SERIES; } else if (theentity instanceof TridasDerivedSeries) { pEntityType = PermissionsEntityType.DERIVED_SERIES; } else { Alert.error( "Error", "Permissions information is only available for objects, elements and series"); return; } PermissionsResource resource = new PermissionsResource(); for (WSISecurityUser user : (ArrayList<WSISecurityUser>) Dictionary.getDictionaryAsArrayList("securityUserDictionary")) { if (!user.isIsActive()) continue; resource.addPermission(pEntityType, theentity.getIdentifier().getValue(), user); } for (WSISecurityGroup grp : (ArrayList<WSISecurityGroup>) Dictionary.getDictionaryAsArrayList("securityGroupDictionary")) { resource.addPermission(pEntityType, theentity.getIdentifier().getValue(), grp); } // Query db TellervoResourceAccessDialog dialog = new TellervoResourceAccessDialog(resource); resource.query(); dialog.setVisible(true); if (!dialog.isSuccessful()) { log.error("Error getting permissions info"); Alert.error("Error", "Error getting permissions info"); return; } permsList = resource.getAssociatedResult(); if (tblGroupPerms != null) tblGroupPerms.repaint(); if (tblUserPerms != null) tblUserPerms.repaint(); if (permsList.size() == 0) { Alert.error("Error", "No records found"); return; } }
@Override public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals("SearchDB")) { searchDatabaseForMatches(); } else if (evt.getActionCommand().equals("Finish")) { commit(); } else if (evt.getActionCommand().equals("Cancel")) { containerFrame.dispose(); } else if (evt.getActionCommand().equals("DefineByPattern")) { fillTableByPattern(); } else if (evt.getActionCommand().equals("IncludeExcludeSubObjects")) { table.getColumnExt("SubObjectColumn").setVisible(this.chkIncludeSubobjects.isSelected()); } else if (evt.getActionCommand().equals("SetDefaults")) { /*MVCArrayList<ControlledVoc> objectdic = Dictionary.getMutableDictionary("objectTypeDictionary"); for(ControlledVoc item : objectdic) { if(item.getNormal().equals("Site")) { defaultEntitiesDialog.setDefaultValues(item); } }*/ defaultEntitiesDialog.setVisible(true); if (defaultEntitiesDialog == null) { defaultEntitiesDialog = new DefaultEntityParametersDialog(containerFrame); } } else if (evt.getActionCommand().equals("GenerateMissing")) { if (model.areThereEmptyCells(this.chkIncludeSubobjects.isSelected())) { Alert.message( containerFrame, "Missing entries", "You must provide titles for all entities in the table."); return; } searchDatabaseForMatches(); if (!model.areThereMissingEntites(true)) { Alert.message(containerFrame, "Nothing to do", "There are no entities to create!"); return; } Object[] options = {"Yes", "No", "Cancel"}; int n = JOptionPane.showOptionDialog( this, "You are about to create basic database entities for all the red crosses in the table.\n" + "Are you sure you want to continue?", "Confirmation", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.OK_OPTION) { model.generateMissingEntities( this.chkIncludeSubobjects.isSelected(), this.defaultEntitiesDialog); } return; } }
/** * Parse the specified legacy data file for series * * @param file * @param fileType */ private void parseFile(File file, AbstractDendroFormat format) { ArrayList<Sample> sampleList = new ArrayList<Sample>(); // Create a reader based on the file type supplied AbstractDendroFileReader reader = TridasIO.getFileReaderFromFormat(format); if (reader == null) { Alert.error(containerFrame, "Error", "Unknown file type"); return; } // Try and load the file try { reader.loadFile(file.getAbsolutePath()); } catch (IOException e) { Alert.errorLoading(file.getAbsolutePath(), e); return; } catch (InvalidDendroFileException e) { Alert.error( containerFrame, "Error", "The selected file is not a valid " + format.getShortName() + " file.\nPlease check and try again"); return; } catch (NullPointerException e) { Alert.error(containerFrame, "Invalid File", e.getLocalizedMessage()); } TridasTridas tc = reader.getTridasContainer(); log.debug("Project count: " + tc.getProjects().size()); Boolean hideWarningsFlag = false; for (TridasProject p : tc.getProjects()) { for (TridasObject o : p.getObjects()) { for (TridasElement e : TridasUtils.getElementList(o)) { log.debug("Element count: " + o.getElements().size()); for (TridasSample s : e.getSamples()) { for (TridasRadius r : s.getRadiuses()) { for (TridasMeasurementSeries ms : r.getMeasurementSeries()) { Sample sample = EditorFactory.createSampleFromSeries(ms, e, file, format, hideWarningsFlag); if (sample == null) { hideWarningsFlag = true; } else { sampleList.add(sample); } } } } } } for (TridasDerivedSeries ds : p.getDerivedSeries()) { Sample sample = EditorFactory.createSampleFromSeries(ds, null, file, format, hideWarningsFlag); if (sample == null) { hideWarningsFlag = true; } else { sampleList.add(sample); } } } Boolean unitsSet = false; for (ITridasSeries ser : getSeries(sampleList)) { for (TridasValues tv : ser.getValues()) { if (tv.isSetUnit()) { if (tv.getUnit().isSetNormalTridas()) { unitsSet = true; } } } } if (unitsSet == false && sampleList.size() > 0 && unitsIfNotSpecified == null) { Object[] possibilities = {"1/1000th mm", "1/100th mm", "1/50th mm", "1/20th mm", "1/10th mm"}; Object s = JOptionPane.showInputDialog( containerFrame, "One or more series has no units defined.\n" + "Please specify units below:", "Set Units", JOptionPane.PLAIN_MESSAGE, null, possibilities, "1/1000th mm"); if (s.equals("1/1000th mm")) { unitsIfNotSpecified = NormalTridasUnit.MICROMETRES; } else if (s.equals("1/100th mm")) { unitsIfNotSpecified = NormalTridasUnit.HUNDREDTH_MM; } else if (s.equals("1/50th mm")) { unitsIfNotSpecified = NormalTridasUnit.FIFTIETH_MM; } else if (s.equals("1/20th mm")) { unitsIfNotSpecified = NormalTridasUnit.TWENTIETH_MM; } else if (s.equals("1/10th mm")) { unitsIfNotSpecified = NormalTridasUnit.TENTH_MM; } else { Alert.error(containerFrame, "Error", "Invalid measurement units specified"); return; } } for (Sample sample : sampleList) { ITridasSeries series = sample.getSeries(); try { for (int i = 0; i < series.getValues().size(); i++) { TridasValues tv = series.getValues().get(i); if (tv.isSetUnit()) { if (!tv.getUnit().isSetNormalTridas()) { tv.getUnit().setNormalTridas(unitsIfNotSpecified); } } else { TridasUnit unit = new TridasUnit(); unit.setNormalTridas(unitsIfNotSpecified); tv.setUnit(unit); tv.setUnitless(null); } tv = UnitUtils.convertTridasValues(NormalTridasUnit.MICROMETRES, tv, true); TridasUnit unit = new TridasUnit(); unit.setNormalTridas(NormalTridasUnit.MICROMETRES); tv.setUnit(unit); series.getValues().set(i, tv); } } catch (NumberFormatException e) { Alert.error("Error", "One or more data values are not numbers."); return; } catch (ConversionWarningException e) { Alert.error("Error", "Error converting units"); return; } } for (Sample s : sampleList) { SeriesIdentity id = new SeriesIdentity(file, format, s); model.addItem(id); } }