/** * Populates the turn restriction editor model with a turn restriction. {@code turnRestriction} is * an arbitrary relation. A tag type=restriction isn't required. If it is missing, it is added * here. {@code turnRestriction} must not be null and it must belong to a dataset. * * @param turnRestriction the turn restriction * @throws IllegalArgumentException thrown if turnRestriction is null * @throws IllegalArgumentException thrown if turnRestriction doesn't belong to a dataset */ public void populate(Relation turnRestriction) { CheckParameterUtil.ensureParameterNotNull(turnRestriction, "turnRestriction"); if (turnRestriction.getDataSet() != null && turnRestriction.getDataSet() != layer.data) { throw new IllegalArgumentException( // don't translate - it's a technical message MessageFormat.format( "turnRestriction {0} must not belong to a different dataset than the dataset of layer ''{1}''", turnRestriction.getId(), layer.getName())); } initFromTurnRestriction(turnRestriction); }
/** * Creates the task * * @param strategy the upload strategy. Must not be null. * @param layer the OSM data layer for which data is uploaded. Must not be null. * @param toUpload the collection of primitives to upload. Set to the empty collection if null. * @param changeset the changeset to use for uploading. Must not be null. changeset.getId() can be * 0 in which case the upload task creates a new changeset * @throws IllegalArgumentException thrown if layer is null * @throws IllegalArgumentException thrown if toUpload is null * @throws IllegalArgumentException thrown if strategy is null * @throws IllegalArgumentException thrown if changeset is null */ public UploadPrimitivesTask( UploadStrategySpecification strategy, OsmDataLayer layer, APIDataSet toUpload, Changeset changeset) { super( tr("Uploading data for layer ''{0}''", layer.getName()), false /* don't ignore exceptions */); ensureParameterNotNull(layer, "layer"); ensureParameterNotNull(strategy, "strategy"); ensureParameterNotNull(changeset, "changeset"); this.toUpload = toUpload; this.layer = layer; this.changeset = changeset; this.strategy = strategy; this.processedPrimitives = new HashSet<OsmPrimitive>(); }
/** * Sets the way participating in the turn restriction in a given role. * * @param role the role. Must not be null. * @param wayId the id of the way to set * @exception IllegalArgumentException thrown if role is null * @exception IllegalArgumentException thrown if wayId != null isn't the id of a way * @exception IllegalStateException thrown the no way with this id was found in the dataset */ public void setTurnRestrictionLeg(TurnRestrictionLegRole role, PrimitiveId wayId) { CheckParameterUtil.ensureParameterNotNull(role, "role"); if (wayId == null) { setTurnRestrictionLeg(role, (Way) null); return; } if (!wayId.getType().equals(OsmPrimitiveType.WAY)) { throw new IllegalArgumentException( MessageFormat.format( "parameter ''wayId'' of type {0} expected, got {1}", OsmPrimitiveType.WAY, wayId.getType())); } OsmPrimitive p = layer.data.getPrimitiveById(wayId); if (p == null) { throw new IllegalStateException( MessageFormat.format( "didn''t find way with id {0} in layer ''{1}''", wayId, layer.getName())); } setTurnRestrictionLeg(role, (Way) p); }
@Override public JPanel getExportPanel() { final JPanel p = new JPanel(new GridBagLayout()); JPanel topRow = new JPanel(new GridBagLayout()); export = new JCheckBox(); export.setSelected(true); final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT); lbl.setToolTipText(layer.getToolTipText()); JLabel lblData = new JLabel(tr("Data:")); /* I18n: Refer to a OSM data file in session file */ link = new JRadioButton(tr("local file")); link.putClientProperty("actionname", "link"); link.setToolTipText(tr("Link to a OSM data file on your local disk.")); /* I18n: Include OSM data in session file */ include = new JRadioButton(tr("include")); include.setToolTipText(tr("Include OSM data in the .joz session file.")); include.putClientProperty("actionname", "include"); ButtonGroup group = new ButtonGroup(); group.add(link); group.add(include); JPanel cardLink = new JPanel(new GridBagLayout()); final File file = layer.getAssociatedFile(); final LayerSaveAction saveAction = new LayerSaveAction(); final JButton save = new JButton(saveAction); if (file != null) { JosmTextField tf = new JosmTextField(); tf.setText(file.getPath()); tf.setEditable(false); cardLink.add(tf, GBC.std()); save.setMargin(new Insets(0, 0, 0, 0)); cardLink.add(save, GBC.eol().insets(2, 0, 0, 0)); } else { cardLink.add(new JLabel(tr("No file association")), GBC.eol()); } JPanel cardInclude = new JPanel(new GridBagLayout()); JLabel lblIncl = new JLabel(tr("OSM data will be included in the session file.")); lblIncl.setFont(lblIncl.getFont().deriveFont(Font.PLAIN)); cardInclude.add(lblIncl, GBC.eol().fill(GBC.HORIZONTAL)); final CardLayout cl = new CardLayout(); final JPanel cards = new JPanel(cl); cards.add(cardLink, "link"); cards.add(cardInclude, "include"); if (file != null) { link.setSelected(true); } else { link.setEnabled(false); link.setToolTipText(tr("No file association")); include.setSelected(true); cl.show(cards, "include"); } link.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { cl.show(cards, "link"); } }); include.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { cl.show(cards, "include"); } }); topRow.add(export, GBC.std()); topRow.add(lbl, GBC.std()); topRow.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL)); p.add(topRow, GBC.eol().fill(GBC.HORIZONTAL)); p.add(lblData, GBC.std().insets(10, 0, 0, 0)); p.add(link, GBC.std()); p.add(include, GBC.eol()); p.add(cards, GBC.eol().insets(15, 0, 3, 3)); export.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { GuiHelper.setEnabledRec(p, false); export.setEnabled(true); } else { GuiHelper.setEnabledRec(p, true); save.setEnabled(saveAction.isEnabled()); link.setEnabled(file != null); } } }); return p; }