@Override
 public void mouseMoved(MouseEvent e) {
   panel.setToolTipText(null);
   if (getXY(e.getX(), e.getY())) {
     if (enabled) {
       panel.setToolTipText(
           "Click on the weather animation to toggle it on and off. To disable tooltip, rightclick");
     } else {
       panel.setToolTipText(null);
     }
   }
 }
Beispiel #2
0
 @Override
 public void setToolTipText(@Nullable String toolTipTextKey) {
   if (LocaleUtils.isEmpty(toolTipTextKey)) {
     toolTipText = null;
     super.setToolTipText("");
   } else {
     toolTipText =
         toolTipText == null
             ? new LocaledString(toolTipTextKey)
             : toolTipText.setKey(toolTipTextKey);
     super.setToolTipText(LocaledString.valueOf(toolTipText));
   }
 }
  private JPanel createParallelGenerationGroup() {
    JPanel parallelGen = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = 0;
    parallelGen.add(myUseNewGenerator, c);
    final ChangeListener listener =
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            myUseNewGenerator.setEnabled(myStrictMode.isSelected());
            myNumberOfParallelThreads.setEditable(
                myUseNewGenerator.isSelected() && myStrictMode.isSelected());
          }
        };
    myStrictMode.addChangeListener(listener);
    myUseNewGenerator.addChangeListener(listener);
    c.insets.left = 7;
    parallelGen.add(new JLabel("Use"), c);
    c.insets.left = 3;
    myNumberOfParallelThreads.setColumns(2);
    parallelGen.add(myNumberOfParallelThreads, c);
    c.insets.left = 2;
    parallelGen.add(new JLabel("cores"), c);
    c.weightx = 1;
    parallelGen.add(new JPanel(), c);

    parallelGen.setToolTipText(
        String.format(
            "This computer has %d processors", Runtime.getRuntime().availableProcessors()));

    myButtonState.track(myUseNewGenerator);

    return parallelGen;
  }
Beispiel #4
0
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      BuildableType item = (BuildableType) value;
      JPanel panel = isSelected ? selectedPanel : itemPanel;
      panel.removeAll();

      ((ImageIcon) imageLabel.getIcon())
          .setImage(ResourceManager.getImage(item.getId() + ".image", buildingDimension));

      nameLabel.setText(Messages.message(item.getNameKey()));
      panel.setToolTipText(lockReasons.get(item));
      panel.add(imageLabel, "span 1 2");
      if (lockReasons.get(item) == null) {
        panel.add(nameLabel, "wrap");
      } else {
        panel.add(nameLabel, "split 2");
        panel.add(lockLabel, "wrap");
      }

      List<AbstractGoods> required = item.getRequiredGoods();
      int size = required.size();
      for (int i = 0; i < size; i++) {
        AbstractGoods goods = required.get(i);
        ImageIcon icon =
            new ImageIcon(ResourceManager.getImage(goods.getType().getId() + ".image", 0.66));
        JLabel goodsLabel =
            new JLabel(Integer.toString(goods.getAmount()), icon, SwingConstants.CENTER);
        if (i == 0 && size > 1) {
          panel.add(goodsLabel, "split " + size);
        } else {
          panel.add(goodsLabel);
        }
      }
      return panel;
    }
  // ----------------------------------------------------------------------------
  private JPanel createFontEffects() {
    JPanel panel = new JPanel(new GridLayout(1, 3, 10, 5));
    panel.setToolTipText("Effects are only visible in Flash.");
    panel.setBorder(new TitledBorder(new EtchedBorder(), "Effects"));

    ButtonGroup group = new ButtonGroup();
    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            effect_ = Integer.parseInt(e.getActionCommand());
          }
        };

    effect_buttons_[0] = new JRadioButton("No effect");
    effect_buttons_[0].setSelected(true);
    effect_buttons_[0].setActionCommand("" + DrawSWFFont.NO_EFFECT);
    panel.add(effect_buttons_[0]);
    group.add(effect_buttons_[0]);
    effect_buttons_[0].addActionListener(listener);

    effect_buttons_[1] = new JRadioButton("Type chars");
    effect_buttons_[1].setActionCommand("" + DrawSWFFont.EFFECT_TYPE);
    panel.add(effect_buttons_[1]);
    group.add(effect_buttons_[1]);
    effect_buttons_[1].addActionListener(listener);

    effect_buttons_[2] = new JRadioButton("Fade in");
    effect_buttons_[2].setActionCommand("" + DrawSWFFont.EFFECT_FADE_IN);
    panel.add(effect_buttons_[2]);
    group.add(effect_buttons_[2]);
    effect_buttons_[2].addActionListener(listener);

    return panel;
  }
 SkeinforgeChoicePreference(
     String name, final String preferenceName, String defaultState, String toolTip) {
   component = new JPanel(new MigLayout());
   chosen = defaultState;
   if (preferenceName != null) {
     chosen = Base.preferences.get(preferenceName, defaultState);
   }
   model = new DefaultComboBoxModel();
   model.setSelectedItem(chosen);
   component.add(new JLabel(name));
   JComboBox cb = new JComboBox(model);
   component.add(cb);
   cb.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           chosen = (String) model.getSelectedItem();
           if (preferenceName != null) {
             Base.preferences.put(preferenceName, chosen);
           }
         }
       });
   if (toolTip != null) {
     component.setToolTipText(toolTip);
   }
 }
  private JComponent createSettingsPanel() {
    JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    result.add(new JLabel(ApplicationBundle.message("label.font.size")));
    myFontSizeSlider = new JSlider(JSlider.HORIZONTAL, 0, FontSize.values().length - 1, 3);
    myFontSizeSlider.setMinorTickSpacing(1);
    myFontSizeSlider.setPaintTicks(true);
    myFontSizeSlider.setPaintTrack(true);
    myFontSizeSlider.setSnapToTicks(true);
    UIUtil.setSliderIsFilled(myFontSizeSlider, true);
    result.add(myFontSizeSlider);
    result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1));

    myFontSizeSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (myIgnoreFontSizeSliderChange) {
              return;
            }
            EditorColorsManager colorsManager = EditorColorsManager.getInstance();
            EditorColorsScheme scheme = colorsManager.getGlobalScheme();
            scheme.setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]);
            applyFontSize();
          }
        });

    String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel");
    result.setToolTipText(tooltipText);
    myFontSizeSlider.setToolTipText(tooltipText);
    result.setVisible(false);
    result.setOpaque(true);
    myFontSizeSlider.setOpaque(true);
    return result;
  }
Beispiel #8
0
 public void setToolTipText(String text) {
   super.setToolTipText(text);
   // nameLabel.setToolTipText(text);
   // imageLabel.setToolTipText(text);
   //  sizeLabel.setToolTipText(text);
   //  locationLabel.setToolTipText(text);
   containingPanel.setToolTipText(text);
   grip.setToolTipText(text);
   // image.setToolTipText(text);
 }
  public DatabaseTab(final UISubsystem ui) throws Exception {
    init(ui.getRl(), ui.getRl().getResourceStream("xui/optionstabs/databasetab.xui.xml"));
    this.ui = ui;

    Language.translateXUIElements(getClass(), xui.getXUIComponents());
    SubstanceThemeHelper.setButtonsToGeneralArea(xui.getXUIComponents());
    tab = (JPanel) xui.getComponent("databasetab");
    tab.setName(Language.getLocalizedString(getClass(), "title"));
    tab.setToolTipText(Language.getLocalizedString(getClass(), "tooltip"));
  }
Beispiel #10
0
 private JPanel getJPanel0() {
   if (jPanel0 == null) {
     jPanel0 = new JPanel();
     jPanel0.setBorder(
         BorderFactory.createEtchedBorder(
             EtchedBorder.RAISED, Color.green, new Color(255, 128, 0)));
     jPanel0.setToolTipText("testing");
     jPanel0.setLayout(new GroupLayout());
   }
   return jPanel0;
 }
Beispiel #11
0
 protected void makeDndIconPanel(HashMap<String, NamedIcon> iconMap, String displayKey) {
   if (_supressDragging) {
     return;
   }
   if (!jmri.util.ThreadingUtil.isGUIThread())
     log.error("Not on GUI thread", new Exception("traceback"));
   _dragIconPanel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
   if (iconMap != null) {
     if (iconMap.get(displayKey) == null) {
       displayKey = (String) iconMap.keySet().toArray()[0];
     }
     NamedIcon ic = iconMap.get(displayKey);
     if (ic != null) {
       NamedIcon icon = new NamedIcon(ic);
       JPanel panel = new JPanel(new FlowLayout());
       String borderName = ItemPalette.convertText("dragToPanel");
       panel.setBorder(
           BorderFactory.createTitledBorder(
               BorderFactory.createLineBorder(Color.black), borderName));
       JLabel label;
       try {
         label = getDragger(new DataFlavor(Editor.POSITIONABLE_FLAVOR), iconMap);
         if (label != null) {
           label.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
           label.setIcon(icon);
           label.setName(borderName);
           panel.add(label);
         }
       } catch (java.lang.ClassNotFoundException cnfe) {
         log.warn("no DndIconPanel {} created", borderName, cnfe);
       }
       int width = Math.max(100, panel.getPreferredSize().width);
       panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height));
       panel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
       _dragIconPanel.add(panel);
       return;
     }
   } else {
     log.error("No iconMap for makeDndIconPanel");
   }
 }
 @Override
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JPanel panel = new JPanel();
   JCheckBox checkBox = new JCheckBox();
   panel.setLayout(new BorderLayout());
   panel.setOpaque(false);
   checkBox.setOpaque(false);
   Component renderer =
       delegateRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   checkBox.setSelected(model.isSelectedIndex(index));
   panel.add(checkBox, BorderLayout.WEST);
   panel.add(renderer, BorderLayout.CENTER);
   panel.setToolTipText(((JLabel) renderer).getToolTipText());
   return panel;
 }
Beispiel #13
0
  public void changeScreenLang(ResourceBundle messages) {
    setTitle(messages.getString("ShowConexiones.title"));
    jPanelConexiones.setToolTipText(messages.getString("ShowConexiones.title"));
    jButtonSalir.setText(messages.getString("ShowConexiones.jButtonSalir"));
    jButtonSalir.setToolTipText(messages.getString("ShowConexiones.jButtonSalir"));
    jButtonOperaciones.setText(messages.getString("ShowConexiones.jButtonOperaciones"));
    jButtonOperaciones.setToolTipText(
        messages.getString("ShowConexiones.jButtonOperacionesToolTip"));

    TableColumn tableColumn = jTableConexiones.getColumnModel().getColumn(0);
    tableColumn.setHeaderValue(messages.getString("ShowConexiones.column0"));
    tableColumn = jTableConexiones.getColumnModel().getColumn(1);
    tableColumn.setHeaderValue(messages.getString("ShowConexiones.column1"));
    tableColumn = jTableConexiones.getColumnModel().getColumn(2);
    tableColumn.setHeaderValue(messages.getString("ShowConexiones.column2"));
    tableColumn = jTableConexiones.getColumnModel().getColumn(3);
    tableColumn.setHeaderValue(messages.getString("ShowConexiones.column3"));
  }
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean sel,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus1) {

    Component comp =
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus1);

    // Set icon

    RocketComponent c = (RocketComponent) value;

    if (c.getClass().isAssignableFrom(MassComponent.class)) {
      MassComponentType t = ((MassComponent) c).getMassComponentType();
      setIcon(ComponentIcons.getSmallMassTypeIcon(t));
    } else {
      setIcon(ComponentIcons.getSmallIcon(value.getClass()));
    }
    if (c.isMassOverridden() || c.isCGOverridden()) {
      JPanel p = new JPanel();
      p.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
      p.setBackground(UIManager.getColor("Tree.textBackground"));
      p.setForeground(UIManager.getColor("Tree.textForeground"));
      p.add(comp /* , BorderLayout.WEST */);
      if (c.isMassOverridden()) {
        p.add(new JLabel(Icons.MASS_OVERRIDE));
      }
      if (c.isCGOverridden()) {
        p.add(new JLabel(Icons.CG_OVERRIDE));
      }
      p.setToolTipText(getToolTip(c));
      comp = p;
    }

    // Set tooltip
    this.setToolTipText(getToolTip(c));

    return comp;
  }
Beispiel #15
0
  public final void initUI() {

    JPanel panel = new JPanel();
    getContentPane().add(panel);

    panel.setLayout(null);
    panel.setToolTipText("A Panel container");

    JButton button = new JButton("Button");
    button.setBounds(100, 60, 100, 30);
    button.setToolTipText("A button component");

    panel.add(button);

    setTitle("Tooltip");
    setSize(300, 200);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  private JScrollPane createStatisticListPanel() {
    Map<String, BaseCounter> statMap = sgReg.getBaseCounters();
    int count = 0;
    JPanel panel = new JPanel();
    panel.setBackground(Color.white);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    Color stripeColor = new Color(235, 235, 235);

    for (final BaseCounter calc : statMap.values()) {
      JPanel calcPanel = new JPanel();
      calcPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      final String name = calc.getName();
      JCheckBox box = new JCheckBox();
      if (name.equals(
          SGStatisticsRegistry.NUC_DIVERSITY)) // bit of a hack here to make sure this box starts
      box.setSelected(true); // out selected
      box.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              toggleCalculator(name);
            }
          });
      calcPanel.add(box);
      JLabel lab = new JLabel(name);
      lab.setFont(new Font("Sans", Font.PLAIN, 11));
      calcPanel.add(lab);
      calcPanel.setBackground(Color.white);
      calcPanel.setMaximumSize(new Dimension(500, 24));
      calcPanel.setToolTipText(calc.getDescription());
      if (count % 2 == 0) {
        calcPanel.setBackground(stripeColor);
      } else {
        calcPanel.setBackground(Color.white);
      }
      panel.add(calcPanel);
      count++;
    }

    JScrollPane pane = new JScrollPane(panel);
    pane.getVerticalScrollBar().setAlignmentX(JComponent.LEFT_ALIGNMENT);
    return pane;
  }
Beispiel #17
0
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
  public JComponent createConstantComponent() {
    String[] descs = new String[groups.length];
    for (int i = 0; i < descs.length; i++) {
      descs[i] = groups[i].getDescription();
    }
    CheckList list = new CheckList(groupState, groups, descs);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setOpaque(false);
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            UIManager.getBorder("TextField.border"), // NOI18N
            BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    panel.add(list, BorderLayout.CENTER);
    panel.setToolTipText(Util.getString("group_desc")); // NOI18N

    list.getAccessibleContext().setAccessibleName(Util.getString("LBL_PriorityCheckList"));
    list.getAccessibleContext().setAccessibleDescription(Util.getString("LBL_PriorityCheckList"));

    list.getModel()
        .addListDataListener(
            new ListDataListener() {
              public void intervalAdded(ListDataEvent e) {}

              public void intervalRemoved(ListDataEvent e) {}

              public void contentsChanged(ListDataEvent e) {
                boolean atLeastOneGroupSelected = false;
                for (int i = 0; i < groupState.length; i++) {
                  if (groupState[i]) {
                    atLeastOneGroupSelected = true;
                    break;
                  }
                }
                panel.putClientProperty(
                    FilterCondition.PROP_VALUE_VALID, new Boolean(atLeastOneGroupSelected));
              }
            });

    return panel;
  }
Beispiel #19
0
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
Beispiel #20
0
 private JPanel getJPanel1() {
   if (jPanel1 == null) {
     jPanel1 = new JPanel();
     jPanel1.setBorder(
         BorderFactory.createEtchedBorder(
             EtchedBorder.RAISED, Color.green, new Color(255, 128, 0)));
     jPanel1.setToolTipText("testing");
     jPanel1.setLayout(new GroupLayout());
     jPanel1.add(
         getJButton1(), new Constraints(new Leading(200, 10, 10), new Leading(27, 10, 10)));
     jPanel1.add(
         getJButton2(), new Constraints(new Leading(345, 10, 10), new Leading(27, 10, 10)));
     jPanel1.add(getJButton0(), new Constraints(new Leading(41, 10, 10), new Leading(22, 10, 10)));
     jPanel1.add(
         getJLabel0(), new Constraints(new Leading(133, 73, 12, 12), new Leading(22, 23, 10, 10)));
     jPanel1.add(
         getJTextField0(), new Constraints(new Leading(60, 142, 10, 10), new Leading(93, 10, 10)));
     jPanel1.add(
         getJFormattedTextField0(),
         new Constraints(new Leading(224, 10, 10), new Leading(111, 10, 10)));
   }
   return jPanel1;
 }
Beispiel #21
0
  private void createUiComponent(boolean enabled) {
    bagSettingsPanel = createSettingsPanel();

    infoPanel = new JPanel(new GridBagLayout());
    infoPanel.setToolTipText(bagView.getPropertyMessage("bagView.bagInfoInputPane.help"));
    Border emptyBorder = new EmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(emptyBorder);

    GridBagConstraints gbc =
        LayoutUtil.buildGridBagConstraints(
            0, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    infoPanel.add(bagSettingsPanel, gbc);

    bagInfoInputPane = new BagInfoInputPane(bagView, false);
    bagInfoInputPane.setToolTipText(bagView.getPropertyMessage("bagView.bagInfoInputPane.help"));
    bagInfoInputPane.setEnabled(false);

    gbc =
        LayoutUtil.buildGridBagConstraints(
            0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.WEST);
    infoPanel.add(bagInfoInputPane, gbc);
    this.setViewportView(infoPanel);
  }
Beispiel #22
0
  /** Create the frame. */
  public principal() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 854, 566);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnCadastro = new JMenu("Cadastro");
    menuBar.add(mnCadastro);

    JMenuItem cadpessoas = new JMenuItem("Cadastro de Pessoas");
    cadpessoas.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            jifcadastro obj = new jifcadastro();
            jdpprincipal.add(obj);
            obj.setVisible(true);
          }
        });
    mnCadastro.add(cadpessoas);

    JMenu mnConsulta = new JMenu("Consulta");
    menuBar.add(mnConsulta);

    JMenuItem conspessoas = new JMenuItem("Consulta de Pessoas");
    mnConsulta.add(conspessoas);
    contentPane = new JPanel();
    contentPane.setToolTipText("");
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    jdpprincipal = new JDesktopPane();
    contentPane.add(jdpprincipal, BorderLayout.CENTER);
  }
  /**
   * Create and return the main panel.
   *
   * @return the main panel.
   */
  private JPanel createPanel() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    JPanel dirPanel = new JPanel();
    dirPanel.setLayout(new BoxLayout(dirPanel, BoxLayout.X_AXIS));
    JLabel dirLabel = new JLabel("Directory: ");
    dirLabel.setPreferredSize(new Dimension(60, 0));
    dirLabel.setToolTipText("Directory where the LTS and states are to be saved");
    dirPanel.add(dirLabel);
    dirPanel.add(getDirField());
    JButton browseButton = new JButton("Browse");
    browseButton.addActionListener(new BrowseButtonListener());
    browseButton.setPreferredSize(PREF_RIGHT);
    dirPanel.add(browseButton);

    JPanel ltsPanel = new JPanel();
    ltsPanel.setLayout(new BoxLayout(ltsPanel, BoxLayout.X_AXIS));
    JLabel ltsLabel = new JLabel("LTS filename pattern: ");
    ltsLabel.setPreferredSize(PREF_LEFT);
    ltsLabel.setToolTipText(
        String.format(
            "LTS file name: "
                + "'%s' is replaced by the grammar ID, extension determines file format",
            PLACEHOLDER));
    ltsPanel.add(ltsLabel);
    ltsPanel.add(getLTSPatternField());
    ltsPanel.add(Box.createHorizontalStrut(PREF_RIGHT.width));

    JPanel statePanel = new JPanel();
    statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.X_AXIS));
    JLabel stateLabel = new JLabel("State filename pattern: ");
    stateLabel.setPreferredSize(PREF_LEFT);
    stateLabel.setToolTipText(
        String.format(
            "Pattern for state file names: "
                + "'%s' is replaced by the state number, extension determines file format",
            PLACEHOLDER));
    statePanel.add(stateLabel);
    statePanel.add(getStatePatternField());
    statePanel.add(Box.createHorizontalStrut(PREF_RIGHT.width));

    JPanel filePanel = new JPanel(new BorderLayout());
    filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.PAGE_AXIS));
    filePanel.setBorder(new TitledBorder(new EtchedBorder(), "Destination"));
    filePanel.add(dirPanel);
    filePanel.add(ltsPanel);
    filePanel.add(statePanel);
    mainPanel.add(filePanel);

    JPanel labelPanel = new JPanel(new GridLayout(0, 1));
    labelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Label options"));
    labelPanel.add(createFlagPanel(Flag.START));
    labelPanel.add(createFlagPanel(Flag.FINAL));
    labelPanel.add(createFlagPanel(Flag.RESULT));
    labelPanel.add(createFlagPanel(Flag.OPEN));
    labelPanel.add(createFlagPanel(Flag.NUMBER));
    if (getGTS().hasTransientStates()) {
      labelPanel.add(createFlagPanel(Flag.TRANSIENT));
    }
    if (getGTS().getGrammar().hasRecipes()) {
      labelPanel.add(createFlagPanel(Flag.RECIPE));
    }
    mainPanel.add(labelPanel);

    JPanel savePanel = new JPanel(new GridLayout(0, 1));
    savePanel.setBorder(new TitledBorder(new EtchedBorder(), "Save states"));
    savePanel.setToolTipText(
        "Select which states should be saved along with the LTS (in the same directory)");

    savePanel.add(getExportButton(StateExport.NONE));
    savePanel.add(getExportButton(StateExport.RESULT));
    savePanel.add(getExportButton(StateExport.FINAL));
    if (getGTS().hasTransientStates()) {
      savePanel.add(getExportButton(StateExport.TOP));
    }
    savePanel.add(getExportButton(StateExport.ALL));
    mainPanel.add(savePanel);

    mainPanel.add(getErrorLabel());

    JPanel buttons = new JPanel();
    // OK or CANCEL
    this.okButton = getOkButton();
    this.cancelButton = getCancelButton();
    buttons.add(this.okButton);
    buttons.add(this.cancelButton);

    JPanel result = new JPanel(new BorderLayout());
    result.add(mainPanel);
    result.add(buttons, BorderLayout.SOUTH);
    return result;
  }
 @Override
 public void setToolTipText(String text) {
   super.setToolTipText(text);
   textLabel.setToolTipText(text);
   textField.setToolTipText(text);
 }
  /**
   * Constructor for the 2D view, creates JPanel within a frame and initializes the list of
   * listeners (input and drawable)
   */
  public View2D() {
    super();

    drawList = new ArrayList<Drawable2D>();

    mainWindow = new JFrame("World of the Nameless");
    mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // mainWindow.setBounds(100, 100, 730, 480);
    mainWindow.setResizable(false);
    mainWindow.setLayout(new BorderLayout());
    mainWindow.setVisible(true);

    drawArea = new Drawable2DArea();
    drawArea.addMouseListener(this);
    mapArea = new MapPanel();

    JPanel buttonPanel = new JPanel(new GridLayout(2, 4));

    inventoryButton = new JButton("Inventory");
    inventoryButton.addActionListener(this);

    characterButton = new JButton("Character");
    characterButton.addActionListener(this);

    helpButton = new JButton("Help");
    helpButton.addActionListener(this);

    quitButton = new JButton("Quit");
    quitButton.addActionListener(this);

    undoButton = new JButton("Undo");
    undoButton.addActionListener(this);

    redoButton = new JButton("Redo");
    redoButton.addActionListener(this);

    saveButton = new JButton("Save");
    saveButton.addActionListener(this);

    buttonPanel.add(inventoryButton);
    buttonPanel.add(characterButton);
    buttonPanel.add(undoButton);
    buttonPanel.add(redoButton);
    buttonPanel.add(helpButton);
    buttonPanel.add(quitButton);
    buttonPanel.add(saveButton);

    textAreaPanel = new JPanel(new BorderLayout());

    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setToolTipText("What is happening to me");

    // JScrollPane scrollPane = new JScrollPane(textArea);

    JPanel inputFieldPane = new JPanel(new BorderLayout());

    inputField = new JTextField();
    inputField.addActionListener(this);
    inputField.setToolTipText("Input Text commands here");

    JLabel inputLabel = new JLabel(" >");

    inputFieldPane.add(inputLabel, BorderLayout.WEST);
    inputFieldPane.add(inputField, BorderLayout.CENTER);

    textAreaPanel.add(textArea, BorderLayout.CENTER);
    textAreaPanel.add(inputFieldPane, BorderLayout.SOUTH);

    JPanel infoPanel = new JPanel(new GridLayout(2, 1));

    infoPanel.add(mapArea);
    infoPanel.add(textAreaPanel);

    JPanel gameContent = new JPanel(new GridLayout(1, 2));

    gameContent.add(drawArea);
    gameContent.add(infoPanel);
    gameContent.setToolTipText("Game Visuals");

    mainWindow.add(gameContent, BorderLayout.CENTER);
    mainWindow.add(buttonPanel, BorderLayout.SOUTH);
    mainWindow.pack();
  }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      final Component orig =
          super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (myPluginDescriptor != null) {
        myNameLabel.setText(myPluginDescriptor.getName());
        final PluginId pluginId = myPluginDescriptor.getPluginId();
        final String idString = pluginId.getIdString();
        if (myPluginDescriptor.isBundled()) {
          myBundledLabel.setText("Bundled");
        } else {
          final String host = myPlugin2host.get(idString);
          if (host != null) {
            String presentableUrl = VfsUtil.urlToPath(host);
            final int idx = presentableUrl.indexOf('/');
            if (idx > -1) {
              presentableUrl = presentableUrl.substring(0, idx);
            }
            myBundledLabel.setText("From " + presentableUrl);
          } else {
            if (PluginManagerUISettings.getInstance().getInstalledPlugins().contains(idString)) {
              myBundledLabel.setText("From repository");
            } else {
              myBundledLabel.setText("Custom");
            }
          }
        }
        if (myPluginDescriptor instanceof IdeaPluginDescriptorImpl
            && ((IdeaPluginDescriptorImpl) myPluginDescriptor).isDeleted()) {
          myNameLabel.setIcon(AllIcons.Actions.Clean);
        } else if (hasNewerVersion(pluginId)) {
          myNameLabel.setIcon(AllIcons.Nodes.Pluginobsolete);
          myPanel.setToolTipText("Newer version of the plugin is available");
        } else {
          myNameLabel.setIcon(AllIcons.Nodes.Plugin);
        }

        final Color fg = orig.getForeground();
        final Color bg = orig.getBackground();
        final Color grayedFg = isSelected ? fg : Color.GRAY;

        myPanel.setBackground(bg);
        myNameLabel.setBackground(bg);
        myBundledLabel.setBackground(bg);

        myNameLabel.setForeground(fg);
        final boolean wasUpdated = wasUpdated(pluginId);
        if (wasUpdated || PluginManager.getPlugin(pluginId) == null) {
          if (!isSelected) {
            myNameLabel.setForeground(FileStatus.COLOR_ADDED);
          }
          if (wasUpdated) {
            myPanel.setToolTipText(
                "Plugin was updated to the newest version. Changes will be available after restart");
          } else {
            myPanel.setToolTipText("Plugin will be activated after restart.");
          }
        }
        myBundledLabel.setForeground(grayedFg);

        final Set<PluginId> required = myDependentToRequiredListMap.get(pluginId);
        if (required != null && required.size() > 0) {
          myNameLabel.setForeground(Color.RED);

          final StringBuilder s = new StringBuilder();
          if (myEnabled.get(pluginId) == null) {
            s.append("Plugin was not loaded.\n");
          }
          if (required.contains(PluginId.getId("com.intellij.modules.ultimate"))) {
            s.append("The plugin requires IntelliJ IDEA Ultimate");
          } else {
            s.append("Required plugin").append(required.size() == 1 ? " \"" : "s \"");
            s.append(
                StringUtil.join(
                    required,
                    new Function<PluginId, String>() {
                      @Override
                      public String fun(final PluginId id) {
                        final IdeaPluginDescriptor plugin = PluginManager.getPlugin(id);
                        return plugin == null ? id.getIdString() : plugin.getName();
                      }
                    },
                    ","));

            s.append(required.size() == 1 ? "\" is not enabled!" : "\" are not enabled!");
          }
          myPanel.setToolTipText(s.toString());
        }

        if (PluginManager.isIncompatible(myPluginDescriptor)) {
          myPanel.setToolTipText(
              IdeBundle.message(
                  "plugin.manager.incompatible.tooltip.warning",
                  ApplicationNamesInfo.getInstance().getFullProductName()));
          myNameLabel.setForeground(Color.red);
        }
      }

      return myPanel;
    }
  /** Create the frame. */
  public App() {
    setTitle("inFarma - Conversor de dados");
    setResizable(false);
    setBounds(100, 100, 460, 314);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panelTop = new JPanel();
    getContentPane().add(panelTop, BorderLayout.NORTH);
    panelTop.setLayout(new MigLayout("", "[fill][grow][][grow]", "[][][][]"));

    JLabel lblNewLabel = new JLabel("BD Antigo");
    panelTop.add(lblNewLabel, "cell 0 0,alignx trailing");

    txtFBBanco = new JTextField();
    txtFBBanco.setText("softpharma");
    panelTop.add(txtFBBanco, "cell 1 0,growx");
    txtFBBanco.setColumns(10);

    JLabel lblNewLabel_1 = new JLabel("VMD Servidor");
    panelTop.add(lblNewLabel_1, "cell 0 1,alignx trailing");

    txtVmdServidor = new JTextField();
    txtVmdServidor.setText("localhost");
    panelTop.add(txtVmdServidor, "cell 1 1,growx");
    txtVmdServidor.setColumns(10);

    JLabel lblNewLabel_2 = new JLabel("Banco");
    panelTop.add(lblNewLabel_2, "cell 2 1,alignx trailing,aligny baseline");

    txtVmdBanco = new JTextField();
    txtVmdBanco.setText("VMD_Vazio");
    panelTop.add(txtVmdBanco, "cell 3 1,growx");
    txtVmdBanco.setColumns(10);

    JLabel lblNewLabel_3 = new JLabel("Converte uma base para o Varejo");
    panelTop.add(lblNewLabel_3, "cell 0 3 4 1");

    final JPanel panel = new JPanel();
    getContentPane().add(panel, BorderLayout.SOUTH);

    class ProcessaWorker extends SwingWorker<Void, Void> {

      @Override
      protected Void doInBackground() throws Exception {
        progressBar.setValue(0);
        progressBar.setMaximum(31);
        btn_limpa_dados.setEnabled(false);
        btn_processa.setEnabled(false);

        int resp =
            JOptionPane.showConfirmDialog(
                panel, "Confirma?", "Processar Dados", JOptionPane.YES_NO_OPTION);

        if (resp == 0) {
          Connection ms = Conexao.getMysqlConnection();
          Connection vmd = Conexao.getSqlConnection();

          if (cboxTBNCM.isSelected()
              && cboxTBSEC.isSelected()
              && cboxFABRI.isSelected()
              && cboxPRODU.isSelected()
              && cboxCLIEN.isSelected()
              && cboxFORNE.isSelected()
              && cboxENDER.isSelected()) {

            // APAGANDO DADOS
            // PRODUTO
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM PRODU");
              stmt.close();
              System.out.println("Deletou PRODU");
              progressBar.setValue(1);
            }

            // FABRI
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM FABRI");
              stmt.close();
              System.out.println("Deletou FABRI");
              progressBar.setValue(2);
            }

            // FORNE
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM FORNE");
              stmt.close();
              System.out.println("Deletou FORNE");
              progressBar.setValue(3);
            }

            // TBNCM
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM TBNCM");
              stmt.close();
              System.out.println("Deletou TBNCM");
              progressBar.setValue(4);
            }

            // TBSEC
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM TBSEC");
              stmt.close();
              System.out.println("Deletou TBSEC");
              progressBar.setValue(5);
            }

            // CLIEN
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM CLIEN");
              stmt.close();
              System.out.println("Deletou CLIEN");
              progressBar.setValue(6);
            }

            // CLXED
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM CLXED");
              stmt.close();
              System.out.println("Deletou CLXED");
              progressBar.setValue(7);
            }

            // ENDER
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM ENDER");
              stmt.close();
              System.out.println("Deletou ENDER");
              progressBar.setValue(8);
            }
          }

          // IMPORTAÇÃO
          // TBNCM
          if (cboxTBNCM.isSelected()) {
            System.out.println("COMEÇOU TBNCM");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM TBNCM");
              stmt.close();
              System.out.println("Deletou TBNCM");
              progressBar.setValue(9);
            }

            progressBar2.setValue(0);

            String msGRPRC = "SELECT * FROM ESTNCM";
            String vGRPRC = "Insert Into TBNCM (Cod_Ncm, Des_Ncm) Values (?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vGRPRC);
                PreparedStatement pMs = ms.prepareStatement(msGRPRC)) {
              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("ESTNCM");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // grava no varejo
                String ncm = rs.getString("ncm_codigo");
                if (ncm != null) {
                  ncm = ncm.replaceAll("\\D", "");
                  if (ncm.length() <= 8) {
                    pVmd.setString(1, rs.getString("ncm_codigo"));
                    pVmd.setString(2, rs.getString("ncm_descricao"));
                    pVmd.executeUpdate();
                  }
                }

                registros++;
                progressBar2.setValue(registros);
              }
              System.out.println("Funcionou TBNCM");
              pVmd.close();
              pMs.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(10);
          }

          // TBSEC
          if (cboxTBSEC.isSelected()) {
            System.out.println("COMEÇOU TBSEC");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate(
                  "IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'tbsec' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'cod_aux' AND DATA_TYPE = 'VARCHAR' AND CHARACTER_MAXIMUM_LENGTH = 15 ) BEGIN ALTER TABLE tbsec ADD cod_aux VARCHAR(15) END ");
              stmt.close();
              System.out.println("CRIOU COLUNA AUX EM TBSEC");
              progressBar.setValue(11);
            }

            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM TBSEC");
              stmt.close();
              System.out.println("Deletou TBSEC");
              progressBar.setValue(12);
            }

            progressBar2.setValue(0);

            String msTBSEC = "SELECT * FROM ESTSEC";
            String vTBSEC = "Insert Into TBSEC (Cod_Seccao, Des_Seccao, Cod_Aux) Values (?,?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vTBSEC);
                PreparedStatement pMs = ms.prepareStatement(msTBSEC)) {

              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("ESTSEC");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // grava no varejo
                pVmd.setInt(1, prox("Cod_Seccao", "TBSEC"));
                pVmd.setString(2, rs.getString("sec_descricao"));
                pVmd.setString(3, rs.getString("sec_secao"));
                pVmd.executeUpdate();

                registros++;
                progressBar2.setValue(registros);
              }

              System.out.println("Funcionou TBSEC");
              pVmd.close();
              pMs.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(13);
          }

          // FABRI
          if (cboxFABRI.isSelected()) {
            System.out.println("COMEÇOU FABRI");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM FABRI");
              stmt.close();
              System.out.println("Deletou FABRI");
              progressBar.setValue(14);
            }

            progressBar2.setValue(0);

            String msFabri = "SELECT * FROM ESTLAB";
            String vFabri = "Insert Into FABRI (Cod_Fabric, Des_Fabric, Num_Cnpj) Values (?,?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vFabri);
                PreparedStatement pFb = ms.prepareStatement(msFabri)) {

              ResultSet rs = pFb.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("ESTLAB");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // grava no varejo
                pVmd.setInt(1, rs.getInt("lab_laboratorio"));
                pVmd.setString(
                    2,
                    rs.getString("lab_razao").length() > 25
                        ? rs.getString("lab_razao").substring(0, 24)
                        : rs.getString("lab_razao"));
                pVmd.setString(
                    3,
                    rs.getString("lab_cnpj").length() > 14
                        ? rs.getString("lab_cnpj").substring(0, 14)
                        : rs.getString("lab_cnpj"));

                pVmd.executeUpdate();

                registros++;
                progressBar2.setValue(registros);
              }

              System.out.println("Funcionou Fabri");
              pVmd.close();
              pFb.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(15);
          }

          // PRODU
          if (cboxPRODU.isSelected()) {
            System.out.println("COMEÇOU PRODU");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM PRODU");
              System.out.println("Deletou PRODU");
              progressBar.setValue(16);
            }

            progressBar2.setValue(0);

            String MsPRODU = "select * from estcad";
            String vPRODU =
                "Insert Into PRODU (Cod_Produt, Des_Produt, Des_Resumi, Des_Comple, Dat_Implan, Cod_Fabric, Cod_EAN, Cod_Ncm, Qtd_FraVen, Qtd_EmbVen, Ctr_Origem, Cod_Classi, Cod_Seccao, Cod_ClaTri, Ctr_Preco, Ctr_Lista, Ctr_Venda, Cod_GrpPrc) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vPRODU);
                PreparedStatement pMs = ms.prepareStatement(MsPRODU); ) {

              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("ESTCAD");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // GRAVA NA PRODU
                pVmd.setInt(1, rs.getInt("CAD_CODIGO"));
                pVmd.setString(
                    2,
                    rs.getString("CAD_DESCRICAO").length() > 40
                        ? rs.getString("CAD_DESCRICAO").substring(0, 39)
                        : rs.getString("CAD_DESCRICAO"));
                pVmd.setString(
                    3,
                    rs.getString("CAD_DESCRICAO").length() > 24
                        ? rs.getString("CAD_DESCRICAO").substring(0, 23)
                        : rs.getString("CAD_DESCRICAO"));
                pVmd.setString(
                    4,
                    rs.getString("CAD_DESCRICAO").length() > 50
                        ? rs.getString("CAD_DESCRICAO").substring(0, 49)
                        : rs.getString("CAD_DESCRICAO"));
                pVmd.setDate(5, rs.getDate("CAD_DT_CADASTRO"));
                pVmd.setString(6, rs.getString("CAD_LABORATORIO"));
                pVmd.setString(7, rs.getString("CAD_COD_BARRA"));

                String ncm = rs.getString("CAD_NCM");
                if (ncm != null) {
                  ncm = ncm.replaceAll("\\D", "");
                  if (ncm.length() <= 8 && !ncm.equals("")) {
                    pVmd.setString(8, ncm);
                  } else {
                    pVmd.setString(8, "30049099");
                  }
                  pVmd.setString(8, "30049099");
                }

                pVmd.setString(9, rs.getString("CAD_QTDE_CAIXA"));
                pVmd.setInt(10, rs.getInt("CAD_QTDE_EMBALAGEM"));
                pVmd.setInt(11, 0);
                pVmd.setString(12, "0199");
                pVmd.setInt(13, 1);
                pVmd.setString(14, "A");
                pVmd.setString(15, "C");
                pVmd.setString(16, "N");
                pVmd.setString(17, "L");
                pVmd.setString(18, "A");

                pVmd.executeUpdate();

                // cadastraCamposQueFaltamPRODU(rs.getString("CODBARRA"));
                registros++;
                progressBar2.setValue(registros);
              }

              System.out.println("Funcionou PRODU");
              pVmd.close();
              pMs.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(17);
          }

          // PRXLJ
          if (cboxPRXLJ.isSelected()) {

            progressBar.setValue(18);

            String mProdu =
                "select CAD_CODIGO, CAD_CUSTO_MEDIO, CAD_ULT_PCOMPRA, CAD_PCUSTO from estcad1";
            String vPrxlj =
                "Update PRXLJ set Prc_CusLiqMed = ?, Prc_CusEnt = ?, Prc_CusLiq = ?, Prc_VenAtu = ? where Cod_Produt = ?";
            try (PreparedStatement pVmd = vmd.prepareStatement(vPrxlj);
                PreparedStatement pMs = ms.prepareStatement(mProdu)) {

              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("ESTCAD1");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // grava no varejo
                System.out.println(rs.getInt("CAD_CODIGO"));
                pVmd.setInt(1, rs.getInt("CAD_CUSTO_MEDIO"));
                pVmd.setString(2, rs.getString("CAD_ULT_PCOMPRA"));
                pVmd.setString(3, rs.getString("CAD_ULT_PCOMPRA"));
                pVmd.setString(4, rs.getString("CAD_PCUSTO"));
                pVmd.setInt(5, rs.getInt("CAD_CODIGO"));

                pVmd.executeUpdate();

                registros++;
                progressBar2.setValue(registros);
              }
              System.out.println("CADASTROU PRXLJ");
              ms.close();
              rs.close();

              progressBar2.setValue(0);
            }

            progressBar.setValue(19);
          }

          // FORNE
          if (cboxFORNE.isSelected()) {
            System.out.println("COMEÇOU FORNE");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM FORNE");
              stmt.close();
              System.out.println("Deletou FORNE");
              progressBar.setValue(20);
            }

            progressBar2.setValue(0);

            String msFORNE =
                "select a.*, b.cid_cod_ibge as cod_ibge, b.cid_nome as cidade, b.cid_uf as uf from cpacdf a join carcid b on b.cid_cidade = a.cdf_cidade";
            String vFORNE =
                "Insert Into FORNE (Cod_Fornec, Num_CgcCpf, Num_CgfRg, Des_RazSoc, Des_Fantas, Cod_IBGE, Des_Endere, Des_Bairro, Num_Cep, Flg_Bloque, Num_Fone, Num_Fax, Des_Estado, Des_Cidade, Cod_RegTri, Nom_Contat, Des_Observ) Values (?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vFORNE);
                PreparedStatement pMs = ms.prepareStatement(msFORNE)) {

              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("CPACDF");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                String tel = rs.getString("CDF_FONE");
                if (tel != null) {
                  tel = tel.replaceAll("\\D", "");
                }

                // grava no varejo
                pVmd.setInt(1, rs.getInt("CDF_COD_FORN"));
                pVmd.setString(
                    2, rs.getString("CDF_CNPJ").replace(".", "").replace("/", "").replace("-", ""));
                pVmd.setString(
                    3,
                    rs.getString("CDF_INSCRICAO")
                        .replace(".", "")
                        .replace("/", "")
                        .replace("-", ""));
                pVmd.setString(
                    4,
                    rs.getString("CDF_RAZAO").length() > 35
                        ? rs.getString("CDF_RAZAO").substring(0, 34)
                        : rs.getString("CDF_RAZAO"));
                pVmd.setString(
                    5,
                    rs.getString("CDF_RAZAO").length() > 25
                        ? rs.getString("CDF_RAZAO").substring(0, 24)
                        : rs.getString("CDF_RAZAO"));
                pVmd.setInt(6, rs.getInt("COD_IBGE"));
                pVmd.setString(
                    7,
                    rs.getString("CDF_ENDERECO").length() > 25
                        ? rs.getString("CDF_ENDERECO").substring(0, 24)
                        : rs.getString("CDF_ENDERECO"));
                pVmd.setString(
                    8,
                    rs.getString("CDF_BAIRRO").length() > 25
                        ? rs.getString("CDF_BAIRRO").substring(0, 24)
                        : rs.getString("CDF_BAIRRO"));
                pVmd.setString(
                    9, rs.getString("CDF_CEP").replace(".", "").replace("/", "").replace("-", ""));

                pVmd.setString(10, tel.length() > 11 ? tel.substring(0, 11) : tel);
                pVmd.setString(
                    11,
                    rs.getString("CDF_FAX")
                        .replace(".", "")
                        .replace("(", "")
                        .replace(")", "")
                        .replace("-", "")
                        .replaceAll(" ", ""));
                pVmd.setString(12, rs.getString("UF"));
                pVmd.setString(
                    13,
                    rs.getString("CIDADE").length() > 25
                        ? rs.getString("CIDADE").substring(0, 24)
                        : rs.getString("CIDADE"));

                if (rs.getString("UF").equals("CE")) {
                  pVmd.setInt(14, 4);
                }

                if (rs.getString("UF").equals("AC")
                    || rs.getString("UF").equals("AL")
                    || rs.getString("UF").equals("AP")
                    || rs.getString("UF").equals("AM")
                    || rs.getString("UF").equals("BA")
                    || rs.getString("UF").equals("DF")
                    || rs.getString("UF").equals("GO")
                    || rs.getString("UF").equals("MA")
                    || rs.getString("UF").equals("MT")
                    || rs.getString("UF").equals("MS")
                    || rs.getString("UF").equals("PB")
                    || rs.getString("UF").equals("PA")
                    || rs.getString("UF").equals("PE")
                    || rs.getString("UF").equals("PI")
                    || rs.getString("UF").equals("RN")
                    || rs.getString("UF").equals("RO")
                    || rs.getString("UF").equals("RR")
                    || rs.getString("UF").equals("SE")
                    || rs.getString("UF").equals("TO")) {
                  pVmd.setInt(14, 1);
                }

                if (rs.getString("UF").equals("ES")
                    || rs.getString("UF").equals("MG")
                    || rs.getString("UF").equals("PR")
                    || rs.getString("UF").equals("RJ")
                    || rs.getString("UF").equals("RS")
                    || rs.getString("UF").equals("SC")
                    || rs.getString("UF").equals("SP")) {

                  pVmd.setInt(14, 9);
                }

                pVmd.setString(
                    15,
                    rs.getString("CDF_CONTATO").length() > 25
                        ? rs.getString("CDF_CONTATO").substring(0, 24)
                        : rs.getString("CDF_CONTATO"));
                pVmd.setString(
                    16,
                    rs.getString("CDF_OBS").length() > 16
                        ? rs.getString("CDF_OBS").substring(0, 15)
                        : rs.getString("CDF_OBS"));

                // todo demais campo
                pVmd.executeUpdate();

                registros++;
                progressBar2.setValue(registros);
              }
              System.out.println("Funcionou FORNE");
              pVmd.close();
              pMs.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(21);
          }

          // CLIEN
          if (cboxCLIEN.isSelected()) {
            System.out.println("COMEÇOU CLIEN");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate(
                  "IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'clien' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'clien_aux' AND DATA_TYPE = 'INT') BEGIN ALTER TABLE clien ADD clien_aux INT END ");
              stmt.close();
              System.out.println("CRIOU COLUNA clien_AUX");
              progressBar.setValue(22);
            }

            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate(
                  "IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'clien' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'empre_aux' AND DATA_TYPE = 'INT') BEGIN ALTER TABLE clien ADD empre_aux INT END ");
              stmt.close();
              System.out.println("CRIOU COLUNA empre_AUX");
              progressBar.setValue(23);
            }

            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM CLIEN");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(24);
            }

            progressBar2.setValue(0);

            String msCLIEN =
                "select a.*,b.cid_nome as cidade, b.cid_uf as uf, c.bai_nome as bairro from carcdc a left join cadbai c on c.bai_codigo = a.cdc_bairro and c.bai_cidade = a.cdc_cidade left join carcid b on b.cid_cidade = a.cdc_cidade";
            String vCLIEN =
                "Insert Into CLIEN (Cod_Client, Nom_Client, Dat_Cadast, Num_CpfCgc, Num_RgCgf, Num_FonCel, Des_Email, Des_Observ, Cod_RegTri, clien_aux, empre_aux, Sex_Client, Cod_GrpCli, Ctr_Vencim, Dat_UltCpr, Cod_EndRes) Values (?,?,?,?,?,?,?,?,?,?,?,null,1,'N',?,?)";
            try (PreparedStatement pVmd = vmd.prepareStatement(vCLIEN);
                PreparedStatement pMs = ms.prepareStatement(msCLIEN)) {

              ResultSet rs = pMs.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("CARCDC");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {

                // grava no varejo
                int codigo = prox("Cod_Client", "CLIEN");
                pVmd.setInt(1, codigo);
                pVmd.setString(
                    2,
                    rs.getString("CDC_RAZAO").length() > 35
                        ? rs.getString("CDC_RAZAO").substring(0, 34)
                        : rs.getString("CDC_RAZAO"));
                pVmd.setDate(3, rs.getDate("CDC_DT_CADASTRO"));

                String cpf = rs.getString("CDC_CPF");
                if (cpf != null) {
                  cpf = cpf.replaceAll("\\D", "");
                  pVmd.setString(4, cpf.length() > 14 ? cpf.substring(0, 14) : cpf);
                }

                String rg = rs.getString("CDC_RG");
                if (rg != null) {
                  rg = rg.replaceAll("\\D", "");
                  pVmd.setString(5, rg.length() > 15 ? rg.substring(0, 15) : rg);
                }

                String cel = rs.getString("CDC_CELULAR");
                if (cel != null) {
                  cel = cel.replaceAll("\\D", "");
                  pVmd.setString(6, cel.length() > 15 ? cel.substring(0, 15) : cel);
                }

                pVmd.setString(7, rs.getString("CDC_EMAIL"));

                String obs = rs.getString("CDC_OBSERVACAO1");
                if (obs != null) {
                  pVmd.setString(8, obs.length() > 16 ? obs.substring(0, 16) : obs);
                }

                if (rs.getString("UF").equals("CE")) {
                  pVmd.setInt(9, 4);
                }
                if (rs.getString("UF").equals("AC")
                    || rs.getString("UF").equals("AL")
                    || rs.getString("UF").equals("AP")
                    || rs.getString("UF").equals("AM")
                    || rs.getString("UF").equals("BA")
                    || rs.getString("UF").equals("DF")
                    || rs.getString("UF").equals("GO")
                    || rs.getString("UF").equals("MA")
                    || rs.getString("UF").equals("MT")
                    || rs.getString("UF").equals("MS")
                    || rs.getString("UF").equals("PB")
                    || rs.getString("UF").equals("PA")
                    || rs.getString("UF").equals("PE")
                    || rs.getString("UF").equals("PI")
                    || rs.getString("UF").equals("RN")
                    || rs.getString("UF").equals("RO")
                    || rs.getString("UF").equals("RR")
                    || rs.getString("UF").equals("SE")
                    || rs.getString("UF").equals("TO")) {
                  pVmd.setInt(9, 1);
                }

                if (rs.getString("UF").equals("ES")
                    || rs.getString("UF").equals("MG")
                    || rs.getString("UF").equals("PR")
                    || rs.getString("UF").equals("RJ")
                    || rs.getString("UF").equals("RS")
                    || rs.getString("UF").equals("SC")
                    || rs.getString("UF").equals("SP")) {
                  pVmd.setInt(9, 9);
                }

                pVmd.setString(10, rs.getString("CDC_CLIENTE"));
                pVmd.setString(11, rs.getString("CDC_EMPRESA"));
                pVmd.setDate(12, rs.getDate("CDC_DT_ULT_COMPRA"));

                String tel = rs.getString("CDC_TELEFONE");
                if (tel != null && !tel.equals("")) {
                  tel = tel.replace("\\D", "");
                  if (tel.length() > 15) {
                    tel = tel.substring(0, 15);
                  }
                  pVmd.setString(13, tel);
                } else {
                  pVmd.setString(13, Integer.toString(codigo));
                }

                pVmd.executeUpdate();

                registros++;
                progressBar2.setValue(registros);
              }
              System.out.println("Funcionou CLIEN");
              pVmd.close();
              pMs.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(25);
          }

          // ENDER
          if (cboxENDER.isSelected()) {
            System.out.println("COMEÇOU ENDER");
            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM CLXED");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(26);
            }

            try (Statement stmt = vmd.createStatement()) {
              stmt.executeUpdate("DELETE FROM ENDER");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(27);
            }

            progressBar2.setValue(0);

            String msCLIEN_ENDER =
                "select a.cdc_cliente, a.cdc_cpf, a.cdc_empresa, a.cdc_telefone, a.cdc_razao, a.cdc_endereco, a.cdc_cep, a.cdc_dt_cadastro, "
                    + "a.cdc_proximo, a.cdc_complemento, b.cid_nome as cidade, b.cid_uf as uf, c.bai_nome as bairro "
                    + "from carcdc a left join cadbai c on c.bai_codigo = a.cdc_bairro and c.bai_cidade = a.cdc_cidade "
                    + "left join carcid b on b.cid_cidade = a.cdc_cidade";
            String vENDER =
                "Insert Into ENDER (Cod_EndFon, Nom_Contat, Des_Endere, Des_Bairro, Num_CEP, Des_Estado, Des_Cidade, Dat_Cadast) Values (?,?,?,?,?,?,?,?)";
            String vCLXED = "Insert Into CLXED (Cod_Client, Cod_EndFon) Values (?,?)";
            // String vCLIEN = "Update CLIEN set Cod_EndRes = ? where Cod_Client = ?";
            try (PreparedStatement pVmd = vmd.prepareStatement(vENDER);
                PreparedStatement pMS = ms.prepareStatement(msCLIEN_ENDER);
                PreparedStatement pVmdCLXED = vmd.prepareStatement(vCLXED);
                // PreparedStatement pVmdCLIEN = vmd.prepareStatement(vCLIEN)
                ) {

              ResultSet rs = pMS.executeQuery();

              // contar a qtde de registros
              int registros = contaRegistros("CARCDC");
              progressBar2.setMaximum(registros);
              registros = 0;

              while (rs.next()) {
                // grava no varejo
                // esta indo codigo repetido
                int codigo = getCod_Clien(rs.getInt("CDC_CLIENTE"), rs.getInt("CDC_EMPRESA"));

                String tel = rs.getString("CDC_TELEFONE");
                if (tel != null) {
                  tel = tel.replaceAll("\\D", "");
                  if (tel.length() > 15) {
                    tel = tel.substring(0, 15);
                  }

                  if (!existeCod_EndFon(tel)) {
                    pVmd.setString(1, tel);

                    String razao = rs.getString("CDC_RAZAO");
                    if (razao != null) {
                      pVmd.setString(2, razao.length() > 35 ? razao.substring(0, 35) : razao);
                    }

                    pVmd.setString(3, rs.getString("CDC_ENDERECO"));

                    String bairro = rs.getString("BAIRRO");
                    if (bairro != null) {
                      pVmd.setString(4, bairro.length() > 25 ? bairro.substring(0, 25) : bairro);
                    }

                    String cep = rs.getString("CDC_CEP");
                    if (cep != null) {
                      cep = cep.replaceAll("\\D", "");
                      pVmd.setString(5, cep.length() > 8 ? cep.substring(0, 8) : cep);
                    }

                    pVmd.setString(6, rs.getString("UF"));

                    String cidade = rs.getString("CIDADE");
                    if (cidade != null) {
                      pVmd.setString(7, cidade.length() > 25 ? cidade.substring(0, 15) : cidade);
                    }

                    pVmd.setDate(8, rs.getDate("CDC_DT_CADASTRO"));
                    pVmd.executeUpdate();

                    // CLXED
                    pVmdCLXED.setInt(1, codigo);
                    pVmdCLXED.setString(2, tel);
                    pVmdCLXED.executeUpdate();

                    // CLIEN
                    // pVmdCLIEN.setString(1, wfone);
                    // pVmdCLIEN.setString(2, rs.getString("CODCLI"));
                    // pVmdCLIEN.executeUpdate();

                    registros++;
                    progressBar2.setValue(registros);
                  }
                }
              }
              System.out.println("Funcionou ENDER");
              pVmd.close();
              pMS.close();

              progressBar2.setValue(0);
            }
            progressBar.setValue(28);
          }

          try (Statement stmt = vmd.createStatement()) {
            stmt.executeUpdate(
                "IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'tbsec' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'cod_aux' AND DATA_TYPE = 'VARCHAR' AND CHARACTER_MAXIMUM_LENGTH = 15 ) BEGIN ALTER TABLE tbsec DROP COLUMN cod_aux END ");
            stmt.close();
            System.out.println("DELETOU COLUNA COD_AUX DA TBSEC");
            progressBar.setValue(29);
          }

          try (Statement stmt = vmd.createStatement()) {
            stmt.executeUpdate(
                "IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'clien' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'clien_aux' AND DATA_TYPE = 'VARCHAR' AND CHARACTER_MAXIMUM_LENGTH = 15 ) BEGIN ALTER TABLE clien DROP COLUMN clien_aux END ");
            stmt.close();
            System.out.println("DELETOU COLUNA CLIEN_AUX DA CLIEN");
            progressBar.setValue(30);
          }

          try (Statement stmt = vmd.createStatement()) {
            stmt.executeUpdate(
                "IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS C WHERE TABLE_NAME = 'clien' AND TABLE_SCHEMA = 'dbo' AND COLUMN_NAME = 'empre_aux' AND DATA_TYPE = 'VARCHAR' AND CHARACTER_MAXIMUM_LENGTH = 15 ) BEGIN ALTER TABLE clien DROP COLUMN empre_aux END ");
            stmt.close();
            System.out.println("DELETOU COLUNA EMPRE_AUX DA CLIEN");
            progressBar.setValue(31);
          }

          // JOptionPane.showMessageDialog(null,
          // "Dados importados com sucesso.");
          JOptionPane.showMessageDialog(
              getContentPane(),
              "Processamento de dados realizado com sucesso",
              "Informação",
              JOptionPane.INFORMATION_MESSAGE);

        } else {
          JOptionPane.showMessageDialog(
              getContentPane(),
              "Processamento de dados cancelado",
              "Informação",
              JOptionPane.INFORMATION_MESSAGE);
        }

        return null;
      }

      @Override
      protected void done() {
        try {
          progressBar.setValue(0);
          btn_limpa_dados.setEnabled(true);
          btn_processa.setEnabled(true);
          getContentPane().setCursor(Cursor.getDefaultCursor());
          // Descobre como está o processo. É responsável por lançar
          // as exceptions
          get();
          // JOptionPane.showMessageDialog(getContentPane(),
          // "Processamento de dados realizado com sucesso",
          // "Informação", JOptionPane.INFORMATION_MESSAGE);
        } catch (ExecutionException e) {
          final String msg = String.format("Erro ao exportar dados: %s", e.getCause().toString());
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  JOptionPane.showMessageDialog(
                      getContentPane(),
                      "Erro ao exportar: " + msg,
                      "Erro",
                      JOptionPane.ERROR_MESSAGE);
                }
              });
        } catch (InterruptedException e) {
          System.out.println("Processo de exportação foi interrompido");
        }
      }
    }

    btn_processa = new JButton("Processa");
    btn_processa.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Conexao.MYSQL_BANCO = txtFBBanco.getText();
            Conexao.SQL_BANCO = txtVmdBanco.getText();
            Conexao.SQL_SERVIDOR = txtVmdServidor.getText();
            // Conexao.SQL_SERVIDOR_CONSULTA = txtVmdServidorConsulta.getText();
            // Conexao.SQL_BANCO_CONSULTA = txtVmdBancoConsulta.getText();
            new ProcessaWorker().execute();
          }
        });

    class LimpaDadosWorker extends SwingWorker<Void, Void> {

      @Override
      protected Void doInBackground() throws Exception {
        progressBar.setValue(0);
        progressBar.setMaximum(6);
        btn_limpa_dados.setEnabled(false);
        btn_processa.setEnabled(false);
        int resp =
            JOptionPane.showConfirmDialog(
                panel, "Confirma?", "Limpeza de Dados", JOptionPane.YES_NO_OPTION);

        if (resp == 0) {
          // APAGANDO DADOS

          // PRODUTO
          if (cboxPRODU.isSelected()) {
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM PRODU");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(1);
            }
          }

          // FABRI
          if (cboxFABRI.isSelected()) {
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM FABRI");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(2);
            }
          }

          // FORNE
          if (cboxFORNE.isSelected()) {

            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM FORNE");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(3);
            }
          }

          // CLIEN
          if (cboxCLIEN.isSelected()) {

            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM CLIEN");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(4);
            }
          }

          // ENDER
          if (cboxENDER.isSelected()) {
            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM CLXED");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(5);
            }

            try (Statement stmt = Conexao.getSqlConnection().createStatement()) {
              stmt.executeUpdate("DELETE FROM ENDER");
              stmt.close();
              System.out.println("Deletou");
              progressBar.setValue(6);
            }
          }
          // JOptionPane.showMessageDialog(null,
          // "Dados importados com sucesso.");
          JOptionPane.showMessageDialog(
              getContentPane(),
              "Limpeza de dados realizada com sucesso",
              "Informação",
              JOptionPane.INFORMATION_MESSAGE);

        } else {
          JOptionPane.showMessageDialog(
              getContentPane(),
              "Limpeza de dados cancelada",
              "Informação",
              JOptionPane.INFORMATION_MESSAGE);
        }
        return null;
      }

      @Override
      protected void done() {
        try {
          progressBar.setValue(0);
          btn_limpa_dados.setEnabled(true);
          btn_processa.setEnabled(true);
          getContentPane().setCursor(Cursor.getDefaultCursor());

          // Descobre como está o processo. É responsável por lançar
          // as exceptions
          get();

          //					JOptionPane.showMessageDialog(getContentPane(),
          //							"Limpeza de dados realizada com sucesso", "Info",
          //							JOptionPane.INFORMATION_MESSAGE);
        } catch (ExecutionException e) {
          final String msg = String.format("Erro ao limpar dados: %s", e.getCause().toString());
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  JOptionPane.showMessageDialog(
                      getContentPane(),
                      "Erro ao limpar: " + msg,
                      "Erro",
                      JOptionPane.ERROR_MESSAGE);
                }
              });
        } catch (InterruptedException e) {
          System.out.println("Processo de exportação foi interrompido");
        }
      }
    }

    btn_limpa_dados = new JButton("Limpa Dados");
    btn_limpa_dados.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Conexao.MYSQL_BANCO = txtFBBanco.getText();
            Conexao.SQL_BANCO = txtVmdBanco.getText();
            Conexao.SQL_SERVIDOR = txtVmdServidor.getText();
            new LimpaDadosWorker().execute();
          }
        });
    panel.add(btn_limpa_dados);
    panel.add(btn_processa);

    JPanel panel_1 = new JPanel();
    panel_1.setToolTipText("");
    getContentPane().add(panel_1, BorderLayout.CENTER);
    panel_1.setLayout(new MigLayout("", "[][][][][][][grow,fill]", "[][][][][][][][][][][][]"));

    cboxTBNCM = new JCheckBox("1-TBNCM");
    cboxTBNCM.setSelected(true);
    panel_1.add(cboxTBNCM, "cell 0 0");

    cboxFABRI = new JCheckBox("3-FABRI");
    cboxFABRI.setSelected(true);
    panel_1.add(cboxFABRI, "cell 1 0");

    cboxPRXLJ = new JCheckBox("5-PRXLJ");
    cboxPRXLJ.setSelected(true);
    panel_1.add(cboxPRXLJ, "cell 2 0");

    cboxCLIEN = new JCheckBox("7-CLIEN");
    cboxCLIEN.setSelected(true);
    panel_1.add(cboxCLIEN, "cell 3 0");

    cboxTBSEC = new JCheckBox("2-TBSEC");
    cboxTBSEC.setSelected(true);
    panel_1.add(cboxTBSEC, "cell 0 1");

    cboxPRODU = new JCheckBox("4-PRODU");
    cboxPRODU.setSelected(true);
    panel_1.add(cboxPRODU, "cell 1 1");

    cboxFORNE = new JCheckBox("6-FORNE");
    cboxFORNE.setSelected(true);
    panel_1.add(cboxFORNE, "cell 2 1");

    cboxENDER = new JCheckBox("8-ENDER");
    cboxENDER.setSelected(true);
    panel_1.add(cboxENDER, "cell 3 1");

    progressBar = new JProgressBar();
    progressBar.setMaximum(31);
    panel_1.add(progressBar, "cell 0 10 7 1,growx");

    progressBar2 = new JProgressBar();
    panel_1.add(progressBar2, "cell 0 11 7 1,growx");
  }
Beispiel #28
0
  private void addResultTable(
      final String sql, long duration, final StatementExecutionResultSetResult resultSetResult) {
    int rowCount = resultSetResult.getRowCount();
    JPanel resultPane = addResultPane();
    final JLabel label = new JLabel(" " + rowCount + " rows");
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 0, 0);
    flowLayout.setAlignOnBaseline(true);
    JPanel statusPane = new JPanel(flowLayout);
    statusPane.setOpaque(false);
    if (rowCount <= resultSetResult.getRetainParsedRSDataRowCountThreshold()) {
      final JTableX table = new ResultTable(resultSetResult);
      JTableHeader tableHeader =
          new JTableHeader(table.getColumnModel()) {
            @Override
            public String getToolTipText(MouseEvent e) {
              int col = getTable().convertColumnIndexToModel(columnAtPoint(e.getPoint()));
              return col == 0 ? null : resultSetResult.getTypeInfos()[col - 1].toString();
            }
          };
      ToolTipManager.sharedInstance().registerComponent(tableHeader);
      table.setTableHeader(tableHeader);
      table.setDefaultRenderer(
          String.class,
          new DefaultTableCellRenderer() {
            @Override
            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              if (value != null) {
                value = "\"" + value + "\"";
              }
              return super.getTableCellRendererComponent(
                  table, value, isSelected, hasFocus, row, column);
            }
          });
      final TableCellRenderer booleanRenderer = table.getDefaultRenderer(Boolean.class);
      table.setDefaultRenderer(
          Boolean.class,
          new DefaultTableCellRenderer() {
            @Override
            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              Component c = null;
              if (value == null) {
                c =
                    super.getTableCellRendererComponent(
                        table, " ", isSelected, hasFocus, row, column);
              } else {
                c =
                    booleanRenderer.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
              }
              if (!isSelected) {
                c.setBackground(
                    row % 2 == 0
                        ? UIManager.getColor("Table.background")
                        : JTableX.getTableAlternateRowBackgroundColor());
              }
              return c;
            }
          });
      table.setDefaultRenderer(
          Timestamp.class,
          new DefaultTableCellRenderer() {
            @SuppressWarnings("deprecation")
            @Override
            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              Component c =
                  super.getTableCellRendererComponent(
                      table, value, isSelected, hasFocus, row, column);
              if (value != null && c instanceof JLabel) {
                Timestamp timestamp = (Timestamp) value;
                String s;
                if (timestamp.getHours() != 0
                    || timestamp.getMinutes() != 0
                    || timestamp.getSeconds() != 0) {
                  s = Utils.formatDateTimeGMT((Timestamp) value);
                } else {
                  s = Utils.formatDateGMT((Timestamp) value);
                }
                ((JLabel) c).setText(s);
              }
              return c;
            }
          });
      table.setDefaultRenderer(
          byte[].class,
          new DefaultTableCellRenderer() {
            @Override
            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              Component c =
                  super.getTableCellRendererComponent(
                      table, value, isSelected, hasFocus, row, column);
              if (value != null && c instanceof JLabel) {
                byte[] bytes = (byte[]) value;
                ((JLabel) c).setText("Blob (" + bytes.length + " bytes)");
              }
              return c;
            }
          });
      table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      table.setAutoCreateRowSorter(true);
      table
          .getRowSorter()
          .setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
      table.setColumnSelectionAllowed(true);
      table.applyMinimumAndPreferredColumnSizes(200);
      resultPane.add(new JScrollPane(table), BorderLayout.CENTER);
      table
          .getSelectionModel()
          .addListSelectionListener(
              new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                  int selectedRowCount = table.getSelectedRowCount();
                  label.setText(
                      " "
                          + resultSetResult.getRowData().length
                          + " rows"
                          + (selectedRowCount == 0
                              ? ""
                              : " - " + selectedRowCount + " selected rows"));
                }
              });
      table.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              int row = table.rowAtPoint(e.getPoint());
              int column = table.columnAtPoint(e.getPoint());
              if (!table.isCellSelected(row, column)) {
                table.changeSelection(row, column, false, false);
              }
              maybeShowPopup(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
              maybeShowPopup(e);
            }

            private void maybeShowPopup(MouseEvent e) {
              if (!e.isPopupTrigger()) {
                return;
              }
              boolean isEditable = resultSetResult.isEditable();
              JPopupMenu menu = new JPopupMenu();
              int selectedRowCount = table.getSelectedRowCount();
              int selectedColumnCount = table.getSelectedColumnCount();
              boolean isAddingSeparator = false;
              // Here to add custom menus.
              if (isEditable) {
                if (isAddingSeparator) {
                  isAddingSeparator = false;
                  menu.addSeparator();
                }
                JMenuItem insertNullMenuItem = new JMenuItem("Insert NULL");
                insertNullMenuItem.addActionListener(
                    new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent e) {
                        int row = table.getSelectedRow();
                        int column = table.getSelectedColumn();
                        table.setValueAt(null, row, column);
                      }
                    });
                insertNullMenuItem.setEnabled(
                    selectedRowCount == 1
                        && selectedColumnCount == 1
                        && table.convertColumnIndexToModel(table.getSelectedColumn()) != 0);
                menu.add(insertNullMenuItem);
                menu.addSeparator();
                JMenuItem deleteRowMenuItem =
                    new JMenuItem(
                        "Delete " + (selectedRowCount > 1 ? selectedRowCount + " rows" : "row"));
                deleteRowMenuItem.addActionListener(
                    new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent e) {
                        int[] selectedRows = table.getSelectedRows();
                        for (int i = selectedRows.length - 1; i >= 0; i--) {
                          selectedRows[i] = table.convertRowIndexToModel(selectedRows[i]);
                        }
                        Arrays.sort(selectedRows);
                        for (int i = selectedRows.length - 1; i >= 0; i--) {
                          int row = selectedRows[i];
                          boolean isSuccess = resultSetResult.deleteRow(row);
                          if (isSuccess) {
                            ((AbstractTableModel) table.getModel()).fireTableRowsDeleted(row, row);
                          }
                        }
                      }
                    });
                deleteRowMenuItem.setEnabled(selectedRowCount > 0);
                menu.add(deleteRowMenuItem);
              }
              if (menu.getComponentCount() > 0) {
                menu.show(e.getComponent(), e.getX(), e.getY());
              }
            }
          });
      final JPanel filterPane = new JPanel(flowLayout);
      filterPane.setOpaque(false);
      final JToggleButton filterToggleButton =
          new JToggleButton(
              new ImageIcon(
                  getClass().getResource("/org/jooq/debug/console/resources/Search16.png")));
      filterToggleButton.setOpaque(false);
      filterToggleButton.setToolTipText(
          "Filter ("
              + KeyEvent.getKeyModifiersText(InputEvent.CTRL_MASK)
              + "+"
              + KeyEvent.getKeyText(KeyEvent.VK_F)
              + ")");
      filterToggleButton.setMargin(new Insets(0, 0, 0, 0));
      filterPane.add(filterToggleButton);
      final JTextField searchField = new JTextField(7);
      searchField
          .getDocument()
          .addDocumentListener(
              new DocumentListener() {
                @Override
                public void removeUpdate(DocumentEvent e) {
                  adjustFilter();
                }

                @Override
                public void insertUpdate(DocumentEvent e) {
                  adjustFilter();
                }

                @Override
                public void changedUpdate(DocumentEvent e) {
                  adjustFilter();
                }

                private void adjustFilter() {
                  setFilter(table, searchField.getText());
                }
              });
      searchField.setVisible(false);
      filterPane.add(searchField);
      filterToggleButton.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              boolean isActive = e.getStateChange() == ItemEvent.SELECTED;
              searchField.setVisible(isActive);
              if (isActive) {
                searchField.requestFocus();
              } else {
                searchField.setText("");
                table.requestFocus();
              }
              filterPane.revalidate();
              filterPane.repaint();
            }
          });
      searchField.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                e.consume();
                filterToggleButton.setSelected(false);
              } else if (e.getKeyCode() == KeyEvent.VK_F && e.isControlDown()) {
                filterToggleButton.setSelected(false);
              }
            }
          });
      table.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_F && e.isControlDown()) {
                e.consume();
                filterToggleButton.setSelected(true);
                searchField.requestFocus();
                searchField.selectAll();
              }
            }
          });
      statusPane.add(filterPane);
    }
    JPanel southResultPanel = new JPanel(new BorderLayout());
    southResultPanel.setOpaque(false);
    if (isUsingMaxRowCount && rowCount == MAX_ROW_COUNT) {
      label.setForeground(Color.RED);
    }
    statusPane.add(label);
    southResultPanel.add(statusPane, BorderLayout.WEST);
    southResultPanel.add(
        new JLabel(
            Utils.formatDuration(duration)
                + " - "
                + Utils.formatDuration(resultSetResult.getResultSetParsingDuration())),
        BorderLayout.EAST);
    resultPane.add(southResultPanel, BorderLayout.SOUTH);
    southResultPanel.setToolTipText(sql);
    resultPane.revalidate();
    resultPane.repaint();
  }
Beispiel #29
0
 /**
  * Component initialization.
  *
  * @throws java.lang.Exception
  */
 private void jbInit() throws Exception {
   contentPane = (JPanel) getContentPane();
   contentPane.setLayout(xYLayoutServer);
   setSize(new Dimension(365, 327));
   setTitle("ProgDan® Codename Avalon: Parser Server v. 0.1");
   statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
   statusBar.setText("Server stopped!");
   jPanelFiles.setBorder(BorderFactory.createEtchedBorder());
   jPanelFiles.setToolTipText("");
   jPanelFiles.setLayout(xYLayout1);
   jLabelFiles.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
   jLabelFiles.setText("Files received:");
   jLabelConverted.setText("Files converted:");
   jProgressBarConvert.setMaximum(0);
   jProgressBarConvert.setString("0");
   jProgressBarConvert.setStringPainted(true);
   jLabelNoConvert.setText("Files not converted:");
   jProgressBarNoConvert.setMaximum(0);
   jProgressBarNoConvert.setString("0");
   jProgressBarNoConvert.setStringPainted(true);
   jProgressBarNoConvert.addPropertyChangeListener(
       new FrameServer_jProgressBarNoConvert_propertyChangeAdapter(this));
   jButtonStart.setSelected(false);
   jButtonStart.setText("Start");
   jButtonStart.addActionListener(new FrameServer_jButtonStart_actionAdapter(this));
   jButtonStop.setEnabled(false);
   jButtonStop.setText("Stop");
   jButtonStop.addActionListener(new FrameServer_jButtonStop_actionAdapter(this));
   jButtonExit.setText("Exit");
   jButtonExit.addActionListener(new FrameServer_jButtonExit_actionAdapter(this));
   jButtonConfig.setText("Config");
   jButtonConfig.addActionListener(new FrameServer_jButtonConfig_actionAdapter(this));
   jLabelActiveConnections.setText("Active Connections:");
   jTextFieldConnections.setEditable(false);
   jTextFieldConnections.setText("0");
   jTextFieldConnections.setHorizontalAlignment(SwingConstants.CENTER);
   jProgressBarFiles.setMaximum(0);
   jProgressBarFiles.setString("0");
   jProgressBarFiles.setStringPainted(true);
   jButtonText.setEnabled(false);
   jButtonText.setText("...");
   jButtonText.addActionListener(new FrameServer_jButtonText_actionAdapter(this));
   jPanelLogo.setBorder(null);
   jPanelLogo.setMinimumSize(new Dimension(10, 10));
   jPanelLogo.setPreferredSize(new Dimension(10, 10));
   jPanelLogo.setLayout(null);
   jLabelTitle.setFont(new java.awt.Font("Dialog", Font.BOLD, 14));
   jLabelTitle.setText("ProgDan® Codename Avalon");
   jLabelApplication.setFont(new java.awt.Font("Dialog", Font.BOLD, 24));
   jLabelApplication.setForeground(Color.red);
   jLabelApplication.setText("Parser Server");
   jLabelRelease.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
   jLabelRelease.setForeground(Color.red);
   jLabelRelease.setText("Release 0.1 - Beta");
   jLabelCopyright.setText("Copyright 2004-2005 - ProgDan® Software");
   jPanelFiles.add(jLabelFiles, new XYConstraints(8, 5, -1, -1));
   jPanelFiles.add(jLabelNoConvert, new XYConstraints(8, 50, -1, -1));
   jPanelFiles.add(jLabelConverted, new XYConstraints(8, 28, -1, -1));
   jPanelFiles.add(jProgressBarFiles, new XYConstraints(108, 3, 160, -1));
   jPanelFiles.add(jProgressBarConvert, new XYConstraints(108, 26, 160, -1));
   jPanelFiles.add(jProgressBarNoConvert, new XYConstraints(108, 48, 160, -1));
   jPanelFiles.add(jButtonText, new XYConstraints(279, 46, -1, -1));
   contentPane.add(jTextFieldConnections, new XYConstraints(158, 118, 131, -1));
   contentPane.add(jLabelActiveConnections, new XYConstraints(45, 121, -1, -1));
   contentPane.add(jButtonExit, new XYConstraints(277, 238, 65, -1));
   contentPane.add(jButtonStart, new XYConstraints(11, 238, 65, -1));
   contentPane.add(jButtonStop, new XYConstraints(100, 238, 65, -1));
   contentPane.add(jButtonConfig, new XYConstraints(188, 238, 65, -1));
   contentPane.add(statusBar, new XYConstraints(6, 272, 344, -1));
   contentPane.add(jPanelFiles, new XYConstraints(13, 148, 327, 77));
   contentPane.add(jPanelLogo, new XYConstraints(13, 15, 112, 96));
   contentPane.add(jLabelTitle, new XYConstraints(141, 14, -1, -1));
   contentPane.add(jLabelApplication, new XYConstraints(165, 40, -1, -1));
   contentPane.add(jLabelRelease, new XYConstraints(250, 66, -1, -1));
   contentPane.add(jLabelCopyright, new XYConstraints(137, 95, -1, -1));
 }
    private void createGUI() {
      setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

      setBackground(bgColor);
      setBorder(
          BorderFactory.createCompoundBorder(
              BorderFactory.createMatteBorder(0, 0, 1, 0, LINE),
              BorderFactory.createEmptyBorder(10, 5, 10, 5)));

      Font labelFont = UIManager.getFont("Label.font");
      Font boldFont = labelFont.deriveFont(Font.BOLD, labelFont.getSize2D() * 1.2f);

      JPanel titlePanel = new JPanel();
      titlePanel.setLayout(new BorderLayout());
      titlePanel.setBackground(bgColor);
      titlePanel.setToolTipText(
          "<html><b>"
              + propDef.getPropertyType().value()
              + "</b> ("
              + propDef.getCardinality().value()
              + " value)"
              + (propDef.getDescription() != null ? "<br>" + propDef.getDescription() : ""));
      add(titlePanel);

      JPanel namePanel = new JPanel();
      namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
      namePanel.setBackground(bgColor);
      JLabel displayNameLabel = new JLabel(propDef.getDisplayName());
      displayNameLabel.setFont(boldFont);
      namePanel.add(displayNameLabel);
      JLabel idLabel = new JLabel(propDef.getId());
      namePanel.add(idLabel);

      titlePanel.add(namePanel, BorderLayout.LINE_START);

      changeBox = new JComboBox(new Object[] {"Don't change     ", "Update    ", "Unset     "});
      titlePanel.add(changeBox, BorderLayout.LINE_END);

      valueComponents = new LinkedList<JComponent>();
      if (propDef.getCardinality() == Cardinality.SINGLE) {
        JComponent valueField = createInputField(value);
        valueComponents.add(valueField);
        add(valueField);
      } else {
        if (value instanceof List<?>) {
          for (Object v : (List<?>) value) {
            JComponent valueField =
                new MultiValuePropertyInputField(createInputField(v), this, bgColor);
            valueComponents.add(valueField);
            add(valueField);
          }
        }

        JPanel addPanel = new JPanel(new BorderLayout());
        addPanel.setBackground(bgColor);
        JButton addButton = new JButton(ICON_ADD);
        addButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                addNewValue();
                setStatus(StatusFlag.Update);
              }
            });
        addPanel.add(addButton, BorderLayout.LINE_END);
        add(addPanel);

        updatePositions();
      }

      setMaximumSize(new Dimension(Short.MAX_VALUE, getPreferredSize().height));
    }