// documentation inherited
  public void doLayout() {
    super.doLayout();

    // compute our translation coordinates based on our size
    _tx = (getWidth() - TILE_WIDTH * _width) / 2;
    _ty = (getHeight() - TILE_HEIGHT * _height) / 2;
  }
예제 #2
0
 private JPanel createPreviewPanel() {
   JPanel p = new JPanel();
   p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
   _screenshot = new PatternPaneScreenshot(_simg);
   createMarginBox(p, _screenshot);
   p.add(Box.createVerticalStrut(5));
   p.add(_screenshot.createControls());
   p.add(Box.createVerticalStrut(5));
   p.add(msgApplied[tabSequence]);
   p.doLayout();
   return p;
 }
예제 #3
0
 private JPanel createTargetPanel() {
   JPanel p = new JPanel();
   p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
   _tarOffsetPane =
       new PatternPaneTargetOffset(_simg, _imgBtn.getFilename(), _imgBtn.getTargetOffset());
   createMarginBox(p, _tarOffsetPane);
   p.add(Box.createVerticalStrut(5));
   p.add(_tarOffsetPane.createControls());
   p.add(Box.createVerticalStrut(5));
   p.add(msgApplied[tabSequence]);
   p.doLayout();
   return p;
 }
  private void showHelp(String help[]) {

    txtCommand.setText(help[0]);

    bHelp = true;

    pResult.removeAll();
    pResult.add(txtResultScroll, BorderLayout.CENTER);
    pResult.doLayout();
    txtResult.setText(help[1]);
    pResult.repaint();
    txtCommand.requestFocus();
    txtCommand.setCaretPosition(help[0].length());
  }
    public MyValidatableComponent() {
      myNameLabel.setLabelFor(myNameText);
      myNameText.setDocument(myNameDocument);

      getEditor()
          .addSettingsEditorListener(
              new SettingsEditorListener() {
                public void stateChanged(SettingsEditor settingsEditor) {
                  updateWarning();
                }
              });

      myWarningLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png"));

      myComponentPlace.setLayout(new GridBagLayout());
      myComponentPlace.add(
          getEditorComponent(),
          new GridBagConstraints(
              0,
              0,
              1,
              1,
              1.0,
              1.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.BOTH,
              new Insets(0, 0, 0, 0),
              0,
              0));
      myComponentPlace.doLayout();
      myFixButton.setIcon(IconLoader.getIcon("/actions/quickfixBulb.png"));
      updateWarning();
      myFixButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              if (myQuickFix == null) {
                return;
              }
              myQuickFix.run();
              myValidationResultValid = false;
              updateWarning();
            }
          });
    }
  private void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add(gScrollPane, BorderLayout.CENTER);
        pResult.doLayout();
        gResult.fireTableChanged(null);
        pResult.repaint();

        bHelp = false;
      }
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }
예제 #7
0
  public void doLayout() {
    if (getLayout() != null) {
      // A layout manager has been set, so delegate to it
      super.doLayout();
      return;
    }

    Dimension d = getSize();
    Insets i = getInsets();

    if (collapsed) {
      if (label != null) {
        Dimension p = label.getPreferredSize();
        label.setBounds(
            i.left, i.top + (d.height - i.top - i.bottom - p.height) / 2, p.width, p.height);
      }
    } else {
      if (comp != null) {
        comp.setBounds(i.left, i.top, d.width - i.left - i.right, d.height - i.top - i.bottom);
      }
    }
  }
예제 #8
0
 public void doLayout() {
   RootPanel rootPanel = frame.getRoot();
   if (rootPanel != null && isWindowResizing()) {
     rootPanel.doLayout();
   } else super.doLayout();
 }
  public void actionPerformed(ActionEvent ev) {

    String s = ev.getActionCommand();

    if (s == null) {
      if (ev.getSource() instanceof JMenuItem) {
        JMenuItem i;

        s = ((JMenuItem) ev.getSource()).getText();
      }
    }

    /*
    // button replace by toolbar
            if (s.equals("Execute")) {
                execute();
            } else
    */
    if (s.equals("Exit")) {
      windowClosing(null);
    } else if (s.equals("Transfer")) {
      Transfer.work(null);
    } else if (s.equals("Dump")) {
      Transfer.work(new String[] {"-d"});
    } else if (s.equals("Restore")) {
      Transfer.work(new String[] {"-r"});
    } else if (s.equals("Logging on")) {
      javaSystem.setLogToSystem(true);
    } else if (s.equals("Logging off")) {
      javaSystem.setLogToSystem(false);
    } else if (s.equals("Refresh Tree")) {
      refreshTree();
    } else if (s.startsWith("#")) {
      int i = Integer.parseInt(s.substring(1));

      txtCommand.setText(sRecent[i]);
    } else if (s.equals("Connect...")) {
      connect(ConnectionDialogSwing.createConnection(fMain, "Connect"));
      refreshTree();
    } else if (s.equals("Results in Grid")) {
      iResult = 0;

      pResult.removeAll();
      pResult.add(gScrollPane, BorderLayout.CENTER);
      pResult.doLayout();
      gResult.fireTableChanged(null);
      pResult.repaint();
    } else if (s.equals("Open Script...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Open Script...");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showOpenDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          StringBuffer buf = new StringBuffer();

          ifHuge = DatabaseManagerCommon.readFile(file.getAbsolutePath());

          if (4096 <= ifHuge.length()) {
            buf.append("This huge file cannot be edited. Please execute\n");
            txtCommand.setText(buf.toString());
          } else {
            txtCommand.setText(ifHuge);
          }
        }
      }
    } else if (s.equals("Save Script...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Save Script");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showSaveDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtCommand.getText());
        }
      }
    } else if (s.equals("Save Result...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Save Result...");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showSaveDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          showResultInText();
          DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtResult.getText());
        }
      }
    } else if (s.equals("Results in Text")) {
      iResult = 1;

      pResult.removeAll();
      pResult.add(txtResultScroll, BorderLayout.CENTER);
      pResult.doLayout();
      showResultInText();
      pResult.repaint();
    } else if (s.equals("AutoCommit on")) {
      try {
        cConn.setAutoCommit(true);
      } catch (SQLException e) {
      }
    } else if (s.equals("AutoCommit off")) {
      try {
        cConn.setAutoCommit(false);
      } catch (SQLException e) {
      }
    } else if (s.equals("Commit")) {
      try {
        cConn.commit();
      } catch (SQLException e) {
      }
    } else if (s.equals("Insert test data")) {
      insertTestData();
    } else if (s.equals("Rollback")) {
      try {
        cConn.rollback();
      } catch (SQLException e) {
      }
    } else if (s.equals("Disable MaxRows")) {
      try {
        sStatement.setMaxRows(0);
      } catch (SQLException e) {
      }
    } else if (s.equals("Set MaxRows to 100")) {
      try {
        sStatement.setMaxRows(100);
      } catch (SQLException e) {
      }
    } else if (s.equals("SELECT")) {
      showHelp(DatabaseManagerCommon.selectHelp);
    } else if (s.equals("INSERT")) {
      showHelp(DatabaseManagerCommon.insertHelp);
    } else if (s.equals("UPDATE")) {
      showHelp(DatabaseManagerCommon.updateHelp);
    } else if (s.equals("DELETE")) {
      showHelp(DatabaseManagerCommon.deleteHelp);
    } else if (s.equals("CREATE TABLE")) {
      showHelp(DatabaseManagerCommon.createTableHelp);
    } else if (s.equals("DROP TABLE")) {
      showHelp(DatabaseManagerCommon.dropTableHelp);
    } else if (s.equals("CREATE INDEX")) {
      showHelp(DatabaseManagerCommon.createIndexHelp);
    } else if (s.equals("DROP INDEX")) {
      showHelp(DatabaseManagerCommon.dropIndexHelp);
    } else if (s.equals("CHECKPOINT")) {
      showHelp(DatabaseManagerCommon.checkpointHelp);
    } else if (s.equals("SCRIPT")) {
      showHelp(DatabaseManagerCommon.scriptHelp);
    } else if (s.equals("SHUTDOWN")) {
      showHelp(DatabaseManagerCommon.shutdownHelp);
    } else if (s.equals("SET")) {
      showHelp(DatabaseManagerCommon.setHelp);
    } else if (s.equals("Test Script")) {
      showHelp(DatabaseManagerCommon.testHelp);
    }
  }