Exemplo n.º 1
0
 private void addRule() {
   // We must add it just after the currently selected Rule.
   // Let's find which one it is. If there is none, we add it at the
   // end of the list.
   MultiInputPanel mip = new MultiInputPanel(I18N.tr("Choose a name for your rule"));
   mip.addInput("RuleName", I18N.tr("Name of the Rule : "), new TextBoxType(10));
   mip.addValidation(
       new MIPValidation() {
         @Override
         public String validate(MultiInputPanel mid) {
           String ruleName = mid.getInput("RuleName");
           return ruleName.isEmpty() ? I18N.tr("Rule name cannot be null or empty.") : null;
         }
       });
   if (UIFactory.showDialog(mip)) {
     String s = mip.getInput("RuleName");
     LegendTreeModel tm = (LegendTreeModel) tree.getModel();
     // We need to link our new RuleWrapper with the layer we are editing.
     Rule temp = new Rule(simpleStyleEditor.getStyleWrapper().getStyle().getLayer());
     temp.setName(s);
     Legend leg =
         LegendFactory.getLegend(temp.getCompositeSymbolizer().getSymbolizerList().get(0));
     // Initialize a panel for this legend.
     ILegendPanel ilp = ILegendPanelFactory.getILegendPanel(simpleStyleEditor, leg);
     List<ILegendPanel> list = new ArrayList<ILegendPanel>();
     list.add(ilp);
     RuleWrapper nrw = new RuleWrapper(simpleStyleEditor, temp, list);
     tm.addElement(tm.getRoot(), nrw, getSelectedRule());
     simpleStyleEditor.legendAdded(nrw.getPanel());
   }
 }
Exemplo n.º 2
0
 /**
  * Adds the rule panel attached to the given {@link RuleWrapper}.
  *
  * @param ruleWrapper RuleWrapper
  */
 private void addRulePanel(RuleWrapper ruleWrapper) {
   // Get the panel associated to this RuleWrapper, set its id,
   // initialize it and add a listener for when its node name changes.
   PnlRule rulePanel = ruleWrapper.getPanel();
   rulePanel.setId(createNewID());
   rulePanel.addPropertyChangeListener(
       EventHandler.create(PropertyChangeListener.class, this, "onNodeNameChange", ""));
   // Add the rule wrapper panel to the container after putting it in
   // a new JScrollPane.
   dialogContainer.add(rulePanel.getId(), getJScrollPane(rulePanel));
 }