public UserDirectoryDialog(int nBuild) {
    super("View Directories");
    initBlink();
    try {
      // UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel" );
    } catch (Exception exc) {
      System.out.println("Error loading L&F: " + exc);
    }

    AppIF appIf = Util.getAppIF();
    if (appIf instanceof VAdminIF) m_adminIF = (VAdminIF) appIf;

    if (nBuild == BUILD_ALL) {
      JPanel left = new JPanel();
      left.setOpaque(true);
      left.setLayout(new BorderLayout());
      left.add(new ConstraintsPanel(), BorderLayout.CENTER);

      JPanel right = new JPanel();
      right.setLayout(new BorderLayout());
      right.setOpaque(true);
      // right.setBackground( Color.white );

      JTreeTableAdmin treeTable = new JTreeTableAdmin(new FileSystemModelAdmin());
      right.add(new JScrollPane(treeTable), BorderLayout.CENTER);

      JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
      pane.setContinuousLayout(true);
      pane.setOneTouchExpandable(true);
      getContentPane().add(pane, BorderLayout.CENTER);
    }

    m_mlTxf =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (timer != null) timer.cancel();
            if (e.getSource() instanceof JTextField) {
              JTextField txf2 = (JTextField) e.getSource();
              String strTxt = txf2.getText();
              if (strTxt != null && strTxt.equals(INFOSTR)) txf2.setText("");
            }
          }
        };
  }
  public static void main() {
    // Main
    frame = new JFrame("Java Playground");
    frame.setSize(640, 480);
    // Make sure the divider is properly resized
    frame.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent c) {
            splitter.setDividerLocation(.8);
          }
        });
    // Make sure the JVM is reset on close
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent w) {
            new FrameAction().kill();
          }
        });

    // Setting up the keybinding
    // Ctrl+k or Cmd+k -> compile
    bind(KeyEvent.VK_K);

    // Ctrl+e or Cmd+e -> console
    bind(KeyEvent.VK_E);

    // Save, New file, Open file, Print.
    // Currently UNUSED until I figure out how normal java files and playground files will
    // interface.
    bind(KeyEvent.VK_S);
    bind(KeyEvent.VK_N);
    bind(KeyEvent.VK_O);
    bind(KeyEvent.VK_P);

    // Binds the keys to the action defined in the FrameAction class.
    frame.getRootPane().getActionMap().put("console", new FrameAction());

    // The main panel for typing code in.
    text = new JTextPane();
    textScroll = new JScrollPane(text);
    textScroll.setBorder(null);
    textScroll.setPreferredSize(new Dimension(640, 480));

    // Document with syntax highlighting. Currently unfinished.
    doc = text.getStyledDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent d) {}

          public void insertUpdate(DocumentEvent d) {}

          public void removeUpdate(DocumentEvent d) {}
        });

    ((AbstractDocument) doc).setDocumentFilter(new NewLineFilter());

    // The output log; a combination compiler warning/error/runtime error/output log.
    outputText = new JTextPane();
    outputScroll = new JScrollPane(outputText);
    outputScroll.setBorder(null);

    // "Constant" for the error font
    error = new SimpleAttributeSet();
    error.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    error.addAttribute(StyleConstants.Foreground, Color.RED);

    // "Constant" for the warning message font
    warning = new SimpleAttributeSet();
    warning.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    warning.addAttribute(StyleConstants.Foreground, Color.PINK);

    // "Constant" for the debugger error font
    progErr = new SimpleAttributeSet();
    progErr.addAttribute(StyleConstants.Foreground, Color.BLUE);

    // Print streams to redirect System.out and System.err.
    out = new TextOutputStream(outputText, null);
    err = new TextOutputStream(outputText, error);
    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(err));

    // Sets up the output log
    outputText.setEditable(false);
    outputScroll.setVisible(true);

    // File input/output setup
    chooser = new JFileChooser();

    // Setting up miscellaneous stuff
    compiler = ToolProvider.getSystemJavaCompiler();
    JVMrunning = false;
    redirectErr = null;
    redirectOut = null;
    redirectIn = null;

    // Sets up the splitter pane and opens the program up
    splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textScroll, outputScroll);
    consoleDisplayed = false;
    splitter.remove(outputScroll); // Initially hides terminal until it is needed
    splitter.setOneTouchExpandable(true);
    frame.add(splitter);
    frame.setVisible(true);

    // Sets the divider to the proper one, for debugging
    // splitter.setDividerLocation(.8);
  }
Exemple #3
0
  public DOMTreeView(Document dom) {
    super("TreeWalkerView ");

    document = dom;
    // jtree  UI setup
    jtree = new DOMTreeFull((Node) document);
    jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Listen for when the selection changes, call nodeSelected(node)
    jtree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            TreePath path = (TreePath) e.getPath();
            TreeNode treeNode = (TreeNode) path.getLastPathComponent();
            if (jtree.getSelectionModel().isPathSelected(path)) nodeSelected(treeNode);
          }
        });

    treeScroll = new JScrollPane(jtree);
    treeScroll.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("DOM Tree View"),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    JPanel urlPanel = new JPanel();
    JLabel urlLabel = new JLabel("URL:");
    urlTextField = new JTextField(50);
    urlTextField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == urlTextField) {
              reloadJTree(urlTextField.getText());
            }
          }
        });
    urlPanel.add(urlLabel);
    urlPanel.add(urlTextField);

    JPanel selectedXPathPanel = new JPanel();
    JLabel xpathLabel = new JLabel("XPath: ");
    selectedXPathTextField = new JTextField(50);
    selectedXPathTextField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == selectedXPathTextField) {
              lookupByXPath(selectedXPathTextField.getText());
            }
          }
        });
    selectedXPathPanel.add(xpathLabel);
    selectedXPathPanel.add(selectedXPathTextField);

    JPanel lookupPanel = new JPanel();
    JLabel lookupLabel = new JLabel("look up:");
    lookupTextField = new JTextField(20);
    lookupTextField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == lookupTextField) {
              lookup(lookupTextField.getText());
            }
          }
        });
    foundList = new JList();
    foundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    foundList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent evt) {
            Object source = evt.getSource();
            if (source == foundList) {
              FoundItem fi = (FoundItem) foundList.getSelectedValue();
              if (fi == null) return;
              jtree.setSelectionPath(fi.treePath);
              jtree.scrollPathToVisible(fi.treePath);
            }
          }
        });

    JScrollPane foundScroll = new JScrollPane(foundList);
    foundScroll.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Nodes found"),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));
    // foundScroll.set
    JPanel queryPanel = new JPanel();
    queryPanel.add(lookupLabel);
    queryPanel.add(lookupTextField);
    lookupPanel.setLayout(new BorderLayout());
    lookupPanel.add(queryPanel, BorderLayout.NORTH);
    lookupPanel.add(foundScroll, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, lookupPanel);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);

    splitPane.setDividerLocation(400);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    mainPanel.add(urlPanel, BorderLayout.NORTH);
    mainPanel.add(selectedXPathPanel, BorderLayout.SOUTH);
    mainPanel.add(splitPane, BorderLayout.CENTER);
    // mainPanel.add(treeScroll, BorderLayout.CENTER);
    // mainPanel.add(lookupPanel, BorderLayout.EAST);

    getContentPane().add(mainPanel);
  }
  public QSAdminGUI(QSAdminMain qsadminMain, JFrame parentFrame) {
    this.parentFrame = parentFrame;
    Container cp = this;
    qsadminMain.setGUI(this);
    cp.setLayout(new BorderLayout(5, 5));
    headerPanel = new HeaderPanel(qsadminMain, parentFrame);
    mainCommandPanel = new MainCommandPanel(qsadminMain);
    cmdConsole = new CmdConsole(qsadminMain);
    propertiePanel = new PropertiePanel(qsadminMain);

    if (headerPanel == null
        || mainCommandPanel == null
        || cmdConsole == null
        || propertiePanel == null) {
      throw new RuntimeException("Loading of one of gui component failed.");
    }

    headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    cp.add(headerPanel, BorderLayout.NORTH);
    JScrollPane propertieScrollPane = new JScrollPane(propertiePanel);
    // JScrollPane commandScrollPane = new JScrollPane(mainCommandPanel);
    JSplitPane splitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, mainCommandPanel, cmdConsole);
    splitPane.setOneTouchExpandable(false);
    splitPane.setDividerLocation(250);
    // splitPane.setDividerLocation(0.70);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("Main", ball, splitPane, "Main Commands");
    tabbedPane.addTab("Get/Set", ball, propertieScrollPane, "Properties Panel");

    QSAdminPluginConfig qsAdminPluginConfig = null;
    PluginPanel pluginPanel = null;
    // -- start of loadPlugins
    try {
      File xmlFile = null;
      ClassLoader classLoader = null;
      Class mainClass = null;

      File file = new File(pluginDir);
      File dirs[] = null;

      if (file.canRead()) dirs = file.listFiles(new DirFileList());

      for (int i = 0; dirs != null && i < dirs.length; i++) {
        xmlFile = new File(dirs[i].getAbsolutePath() + File.separator + "plugin.xml");
        if (xmlFile.canRead()) {
          qsAdminPluginConfig = PluginConfigReader.read(xmlFile);
          if (qsAdminPluginConfig.getActive().equals("yes")
              && qsAdminPluginConfig.getType().equals("javax.swing.JPanel")) {
            classLoader = ClassUtil.getClassLoaderFromJars(dirs[i].getAbsolutePath());
            mainClass = classLoader.loadClass(qsAdminPluginConfig.getMainClass());
            logger.fine("Got PluginMainClass " + mainClass);
            pluginPanel = (PluginPanel) mainClass.newInstance();
            if (JPanel.class.isInstance(pluginPanel) == true) {
              logger.info("Loading plugin : " + qsAdminPluginConfig.getName());
              pluginPanelMap.put("" + (2 + i), pluginPanel);
              plugins.add(pluginPanel);
              tabbedPane.addTab(
                  qsAdminPluginConfig.getName(),
                  ball,
                  (JPanel) pluginPanel,
                  qsAdminPluginConfig.getDesc());
              pluginPanel.setQSAdminMain(qsadminMain);
              pluginPanel.init();
            }
          } else {
            logger.info(
                "Plugin "
                    + dirs[i]
                    + " is disabled so skipping "
                    + qsAdminPluginConfig.getActive()
                    + ":"
                    + qsAdminPluginConfig.getType());
          }
        } else {
          logger.info("No plugin configuration found in " + xmlFile + " so skipping");
        }
      }
    } catch (Exception e) {
      logger.warning("Error loading plugin : " + e);
      logger.fine("StackTrace:\n" + MyString.getStackTrace(e));
    }
    // -- end of loadPlugins

    tabbedPane.addChangeListener(
        new ChangeListener() {
          int selected = -1;
          int oldSelected = -1;

          public void stateChanged(ChangeEvent e) {
            // if plugin
            selected = tabbedPane.getSelectedIndex();
            if (selected >= 2) {
              ((PluginPanel) pluginPanelMap.get("" + selected)).activated();
            }
            if (oldSelected >= 2) {
              ((PluginPanel) pluginPanelMap.get("" + oldSelected)).deactivated();
            }
            oldSelected = selected;
          }
        });

    // tabbedPane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
    cp.add(tabbedPane, BorderLayout.CENTER);

    buildMenu();
  }
  public IndexingFrame(Frames parent, BatchState bs) {

    this.parent = parent;
    this.batchState = bs;
    this.indexingFrame = this;

    // Set the window's title
    this.setTitle("Indexing");

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create menu bar
    this.createMenuBar(this);

    this.setPreferredSize(new Dimension(2000, 1000));

    // Set the location of the window on the desktop
    this.setLocation(100, 100);

    // Size the window according to the preferred sizes and layout of its subcomponents
    this.pack();

    Container contentPane = this.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    ButtonBar buttonBar = new ButtonBar(this, batchState);
    contentPane.add(buttonBar);

    JTabbedPane leftTabbedPane = new JTabbedPane();
    formEntry = new FormEntry(this, batchState);
    // TableEntry table = new TableEntry();
    model =
        new DefaultTableModel() {
          @Override
          public boolean isCellEditable(int row, int column) {

            return column != 0;
          }
        };

    //		tableEntry = new JTable(model);
    //		tableEntry.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //		tableEntry.setColumnSelectionAllowed(true);
    //		tableEntry.setRowSelectionAllowed(true);
    //
    //		tableEntry.setGridColor(Color.BLACK);

    tableEntry = new TableEntry(this, batchState, model);

    JScrollPane scrollpane = new JScrollPane(tableEntry);
    leftTabbedPane.add("Table Entry", scrollpane);

    listModel = new DefaultListModel<String>();
    list = new JList(listModel);
    JScrollPane listScroll = new JScrollPane(list);

    JScrollPane formScroll = new JScrollPane(formEntry);

    JPanel formSplit = new JPanel();
    formSplit.setLayout(new BoxLayout(formSplit, BoxLayout.LINE_AXIS));
    formSplit.add(listScroll);
    formSplit.add(formScroll);

    leftTabbedPane.add("Form Entry", formSplit);

    JTabbedPane rightTabbedPane = new JTabbedPane();
    fieldHelp = new FieldHelp(batchState);
    JScrollPane helpScroll = new JScrollPane(fieldHelp);
    helpScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    ImageNavigation imageNavigation = new ImageNavigation();
    rightTabbedPane.add("Field Help", helpScroll);
    rightTabbedPane.add("Image Navigation", imageNavigation);

    horizontalSplitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftTabbedPane, rightTabbedPane);
    horizontalSplitPane.setAlignmentX(Component.CENTER_ALIGNMENT);
    horizontalSplitPane.setDividerLocation(this.getWidth() / 2);
    horizontalSplitPane.setOneTouchExpandable(true);
    horizontalSplitPane.setResizeWeight(0.5);

    this.imageComponent = new ImageComponent();

    componentPanel = new JPanel();
    // componentPanel.setBackground(Color.gray);
    // componentPanel.setPreferredSize(new Dimension(400,400));
    component = new DrawingComponent(this, batchState);
    componentPanel.add(component, BorderLayout.CENTER);

    //		slider = new JSlider(1, 100, 20);
    //		slider.addChangeListener(sliderChangeListener);
    //		componentPanel.add(slider, BorderLayout.SOUTH);

    verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, horizontalSplitPane);
    verticalSplitPane.setDividerLocation(this.getHeight() / 2);
    verticalSplitPane.setOneTouchExpandable(true);
    verticalSplitPane.setAlignmentX(Component.CENTER_ALIGNMENT);
    verticalSplitPane.setResizeWeight(0.5);

    contentPane.add(verticalSplitPane);

    this.pack();
  }