/** Exit if the user is not running a stable version */
  private static void checkVersion() {
    String versionText = wiki.getPageText(COMMONS_PAGE + "/MinimumVersion");
    if (versionText == null || versionText.equals("")) {
      exitWithWaring("Could not check for updates", "Update check failed");
    }

    String[] minVersion = versionText.substring(1).split("\\.", 3);

    // get int representation of three bytes
    int actualVersion = (VERSION_NUM[0] << 16) + (VERSION_NUM[1] << 8) + VERSION_NUM[2];
    int minimumVersion =
        (Byte.parseByte(minVersion[0]) << 16)
            + (Byte.parseByte(minVersion[1]) << 8)
            + Byte.parseByte(minVersion[2]);

    if (minimumVersion <= actualVersion) return;

    JTextArea msg =
        new JTextArea(
            "Current version: "
                + VERSION
                + "\n"
                + "Please update the program to version "
                + versionText
                + " or higher:"
                + "\n"
                + "https://github.com/Commonists/GlobalReplace/releases/latest"
                + "\nProgram will stop!");
    msg.setFocusable(true);
    exitWithWaring(msg, "Outdated version");
  }
  private void newComps() {
    ta = new JTextArea();
    // ta.setLineWrap(true);
    ta.setWrapStyleWord(true);
    ta.setFocusable(false);
    ta.setEditable(false);
    ta.setFont(new Font("Courier New", Font.BOLD, 20));
    ta.setBackground(Color.black);
    ta.setForeground(Color.GREEN);

    sc = new JScrollPane();
    sc.setViewportView(ta);

    btnExport = new JButton("Export");
    btnExport.setOpaque(false);
    btnExport.setFont(ta.getFont());
    btnExport.setFocusable(false);

    ckWrap = new JCheckBox("Wrap text");
    ckWrap.setOpaque(false);
    ckWrap.setForeground(Color.white);
    ckWrap.setFont(ta.getFont());
    ckWrap.setFocusable(false);

    chooser = new JFileChooser();
  }
  /**
   * Create a new JumpSourcePanel.
   *
   * @param tab parent JumpTab
   */
  public JumpSourcePanel(final JumpTab tab) {
    this.tab = tab;
    this.editorPane = new JTextArea();
    this.highlighter = new DefaultHighlighter();
    highlighter.setDrawsLayeredHighlights(false);

    setLayout(new BorderLayout());
    setBorder(new TitledBorder("Source"));
    editorPane.setFont(JumpGui.FONT_MONOSPACED);
    editorPane.setHighlighter(highlighter);
    final StringBuilder sb = new StringBuilder();
    for (int i = 1; i < MAXIMUM_LINE_NUMBER; ++i) {
      sb.append(String.format("%3d %n", i));
    }

    final JTextArea lineNumbers = new JTextArea(sb.toString());
    lineNumbers.setFont(editorPane.getFont());
    lineNumbers.setBackground(getBackground());
    lineNumbers.setEditable(false);
    lineNumbers.setFocusable(false);

    final JScrollPane scrollPane =
        new JScrollPane(
            editorPane,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setRowHeaderView(lineNumbers);
    add(scrollPane);
    SwingUtilities.invokeLater(this);
  }
  public Server() {
    super("SERVER");

    /*init ligne */
    try {
      InfoLigne = Utile.getStation();
      TabLigne[0] = true;
      ID_controleur[0] = true;
      for (int i = 1; i < TabLigne.length; i++) {
        TabLigne[i] = false;
        ID_controleur[i] = false;
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    /*init fenêtre*/
    this.setSize(840, 640);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.container.add(panBus, BorderLayout.WEST);
    this.container.add(panControleur, BorderLayout.EAST);
    this.container.add(jscroll, BorderLayout.SOUTH);

    this.panBus.setPreferredSize(new Dimension(515, 400));
    this.panBus.setToolTipText("Panneau de Serveur BUS");
    this.panBus.setAutoscrolls(true);

    jscroll.setBounds(100, 30, 250, 100);
    jscroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jscroll.setAutoscrolls(true);
    jscroll.setPreferredSize(new Dimension(830, 90));

    this.console.setPreferredSize(new Dimension(830, 100));
    this.console.setToolTipText("Console");
    this.console.setAutoscrolls(true);

    this.panControleur.setPreferredSize(new Dimension(315, 400));
    this.panControleur.setToolTipText("Panneau Controleur");
    this.panBus.setBackground(Color.GRAY);
    this.console.setBackground(Color.black);
    console.setForeground(Color.cyan);
    console.setBackground(Color.black);
    console.setAutoscrolls(true);
    console.setRows(rowConsole);
    console.setLineWrap(true);
    console.setFocusable(true);
    console.setEditable(false);
    console.setText(stConsole);

    this.getContentPane().add(container);
    this.setVisible(true);
  }
  /**
   * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>
   *     null</code> if dialog is used to create new mouse shortcut.
   */
  public MouseShortcutDialog(
      JComponent parentComponent,
      MouseShortcut shortcut,
      @NotNull Keymap keymap,
      @NotNull String actiondId,
      @NotNull Group mainGroup) {
    super(parentComponent, true);
    setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

    myKeymap = keymap;
    myActionId = actiondId;
    myMainGroup = mainGroup;

    myRbSingleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
    myRbDoubleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(myRbSingleClick);
    buttonGroup.add(myRbDoubleClick);

    myLblPreview = new JLabel(" ");

    myClickPad = new MyClickPad();

    myTarConflicts = new JTextArea();
    myTarConflicts.setFocusable(false);
    myTarConflicts.setEditable(false);
    myTarConflicts.setBackground(UIUtil.getPanelBackground());
    myTarConflicts.setLineWrap(true);
    myTarConflicts.setWrapStyleWord(true);

    if (shortcut != null) {
      if (shortcut.getClickCount() == 1) {
        myRbSingleClick.setSelected(true);
      } else {
        myRbDoubleClick.setSelected(true);
      }
      myButton = shortcut.getButton();
      myModifiers = shortcut.getModifiers();
    } else {
      myRbSingleClick.setSelected(true);
      myButton = -1;
      myModifiers = -1;
    }

    updatePreviewAndConflicts();

    init();
  }
  private void initUI() {
    // Create tabbed pane with commands in it
    tabbedPane = new JTabbedPane();
    getContentPane().add(tabbedPane, BorderLayout.NORTH);

    tabbedPane.addTab("Book", null, createBookPane(), "View book information");
    tabbedPane.addTab("Author", null, createAuthorPane(), "View author information");
    tabbedPane.addTab("Customer", null, createCustomerPane(), "View customer information");
    tabbedPane.addTab("Borrow Book", null, createBorrowPane(), "Borrow books for a customer");
    tabbedPane.addTab("Return Book", null, createReturnPane(), "Return books for a customer");

    // Create output area with scrollpane
    outputArea = new JTextArea();
    // outputArea.setFont(new Font("Monospaced",Font.PLAIN,12));
    outputArea.setFont(new Font("Monospaced", Font.ROMAN_BASELINE, 12));
    outputArea.setEditable(false);
    outputArea.setFocusable(false);
    outputArea.setTabSize(2);
    JScrollPane sp = new JScrollPane(outputArea);
    sp.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);

    getContentPane().add(sp, BorderLayout.CENTER);

    // Create menus
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    JMenuItem clearTextMenuItem = new JMenuItem(clearTextAction);
    JMenuItem exitMenuItem = new JMenuItem(exitAction);

    fileMenu.add(clearTextMenuItem);
    fileMenu.addSeparator();
    fileMenu.add(exitMenuItem);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);

    // Pack it all
    pack();
  }
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    optionsDialog = new javax.swing.JDialog();
    saveExitButton = new javax.swing.JButton();
    showPercentCheck = new javax.swing.JCheckBox();
    jButton1 = new javax.swing.JButton();
    closeOptionsButton = new javax.swing.JButton();
    endGameDialog = new javax.swing.JDialog();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jButton2 = new javax.swing.JButton();
    timeCompLabel = new javax.swing.JLabel();
    finalScoreLabel = new javax.swing.JLabel();
    wordsCompLabel = new javax.swing.JLabel();
    jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane2 = new javax.swing.JSplitPane();
    jPanel1 = new javax.swing.JPanel();
    optionsButton = new javax.swing.JButton();
    endTurnButton = new javax.swing.JButton();
    clues = new javax.swing.JTextArea();
    clues.setText(manager.currentGame.getClueList());
    clues.setFocusable(false);
    clues.setEditable(false);
    clues.setLineWrap(true);
    clues.setWrapStyleWord(true);
    jScrollPane1 = new javax.swing.JScrollPane(clues);

    saveExitButton.setText("Save & Exit");
    saveExitButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveExitButtonActionPerformed(evt);
          }
        });

    showPercentCheck.setText("Show # Words Correct");
    showPercentCheck.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(java.awt.event.ItemEvent evt) {
            showPercentCheckItemStateChanged(evt);
          }
        });
    showPercentCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            showPercentCheckActionPerformed(evt);
          }
        });

    jButton1.setText("End Game");
    jButton1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
          }
        });

    closeOptionsButton.setText("Close");
    closeOptionsButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            closeOptionsButtonActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout optionsDialogLayout =
        new javax.swing.GroupLayout(optionsDialog.getContentPane());
    optionsDialog.getContentPane().setLayout(optionsDialogLayout);
    optionsDialogLayout.setHorizontalGroup(
        optionsDialogLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                optionsDialogLayout
                    .createSequentialGroup()
                    .addGroup(
                        optionsDialogLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                optionsDialogLayout
                                    .createSequentialGroup()
                                    .addGap(112, 112, 112)
                                    .addComponent(showPercentCheck))
                            .addGroup(
                                optionsDialogLayout
                                    .createSequentialGroup()
                                    .addGap(125, 125, 125)
                                    .addGroup(
                                        optionsDialogLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(
                                                closeOptionsButton,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                jButton1,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                saveExitButton,
                                                javax.swing.GroupLayout.Alignment.LEADING))))
                    .addContainerGap(114, Short.MAX_VALUE)));
    optionsDialogLayout.setVerticalGroup(
        optionsDialogLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                optionsDialogLayout
                    .createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addComponent(showPercentCheck)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                    .addComponent(saveExitButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(closeOptionsButton)
                    .addGap(21, 21, 21)));

    jLabel1.setText("Time:");

    jLabel2.setText("Score:");

    jLabel3.setText("Words Complete:");

    jButton2.setText("Return to Menu");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });

    timeCompLabel.setText("jLabel5");

    finalScoreLabel.setText("jLabel6");

    wordsCompLabel.setText("jLabel7");

    javax.swing.GroupLayout endGameDialogLayout =
        new javax.swing.GroupLayout(endGameDialog.getContentPane());
    endGameDialog.getContentPane().setLayout(endGameDialogLayout);
    endGameDialogLayout.setHorizontalGroup(
        endGameDialogLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                endGameDialogLayout
                    .createSequentialGroup()
                    .addGroup(
                        endGameDialogLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                endGameDialogLayout
                                    .createSequentialGroup()
                                    .addGap(53, 53, 53)
                                    .addGroup(
                                        endGameDialogLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel3)
                                            .addComponent(jLabel2)
                                            .addComponent(jLabel1))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(
                                        endGameDialogLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(timeCompLabel)
                                            .addComponent(finalScoreLabel)
                                            .addComponent(wordsCompLabel)))
                            .addGroup(
                                endGameDialogLayout
                                    .createSequentialGroup()
                                    .addGap(119, 119, 119)
                                    .addComponent(jButton2)))
                    .addContainerGap(120, Short.MAX_VALUE)));
    endGameDialogLayout.setVerticalGroup(
        endGameDialogLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                endGameDialogLayout
                    .createSequentialGroup()
                    .addGap(26, 26, 26)
                    .addGroup(
                        endGameDialogLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(timeCompLabel))
                    .addGap(18, 18, 18)
                    .addGroup(
                        endGameDialogLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(finalScoreLabel))
                    .addGap(18, 18, 18)
                    .addGroup(
                        endGameDialogLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(wordsCompLabel))
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                    .addComponent(jButton2)
                    .addContainerGap()));

    jSplitPane1.setDividerLocation(150);
    jSplitPane1.setDividerSize(1);

    jSplitPane2.setDividerLocation((int) (getHeight() / 10));
    jSplitPane2.setDividerSize(1);
    jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    jPanel1.setPreferredSize(new java.awt.Dimension(100, 83));
    jPanel1.setLayout(new java.awt.GridLayout(1, 0));

    optionsButton.setText("Options");
    optionsButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            optionsButtonActionPerformed(evt);
          }
        });
    jPanel1.add(optionsButton);

    endTurnButton.setText("End Turn");
    if (manager.currentGame.twoPlayers)
      endTurnButton.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              endTurnButtonActionPerformed(evt);
            }
          });
    if (manager.currentGame.twoPlayers) jPanel1.add(endTurnButton);

    jSplitPane2.setTopComponent(jPanel1);

    jScrollPane1.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    jSplitPane2.setRightComponent(jScrollPane1);

    jSplitPane1.setLeftComponent(jSplitPane2);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                jSplitPane1,
                javax.swing.GroupLayout.Alignment.TRAILING,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                500,
                Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE));
  } // </editor-fold>//GEN-END:initComponents
  public void setEntity(ITridas entity) {
    theentity = entity;
    lookupUsersAndGroups();

    userTableModel = new UsersWithPermissionsTableModel(permsList);
    groupTableModel = new GroupsWithPermissionsTableModel(permsList);
    groupTableModel.addTableModelListener(
        new TableModelListener() {

          @Override
          public void tableChanged(TableModelEvent e) {
            updateUsersTable();
          }
        });
    setLayout(new MigLayout("", "[][grow]", "[86px][28.00][328px,grow]"));

    lblPermissionsInfoFor = new JLabel("Permissions info for:");
    add(lblPermissionsInfoFor, "cell 0 1,alignx trailing");

    // TODO : make this code pretty...
    txtLabCode = new JTextField();
    txtLabCode.setText(entity.getTitle());
    txtLabCode.setFocusable(false);

    txtLabCode.setEditable(false);
    add(txtLabCode, "cell 1 1,growx");
    txtLabCode.setColumns(10);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    add(tabbedPane, "cell 0 2 2 1,grow");

    panelGroups = new JPanel();
    tabbedPane.addTab(
        "Group permissions", Builder.getIcon("edit_group.png", 22), panelGroups, null);
    panelGroups.setLayout(new MigLayout("", "[648px,grow]", "[381px,grow][]"));

    JScrollPane scrollGroup = new JScrollPane();
    panelGroups.add(scrollGroup, "cell 0 0,grow");

    tblGroupPerms = new JXTable(groupTableModel);
    tblGroupPerms.setSortable(true);

    searchableGroup = new TableSearchable(tblGroupPerms);
    tblGroupPerms.setSearchable(searchableGroup);

    scrollGroup.setViewportView(tblGroupPerms);

    btnEditGroup = new JButton("View / Edit Group");
    btnEditGroup.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            editSelectedGroup();
          }
        });
    panelGroups.add(btnEditGroup, "flowx,cell 0 1");

    btnRevertToDefault = new JButton("Revert to database defaults");
    btnRevertToDefault.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            resetPermissionsForCurrentGroup();
          }
        });
    panelGroups.add(btnRevertToDefault, "cell 0 1");

    btnGroupRefresh = new JButton("Refresh");
    btnGroupRefresh.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            updateGroupsTable();
          }
        });
    panelGroups.add(btnGroupRefresh, "cell 0 1");

    tblGroupPerms.getColumnModel().getColumn(0).setPreferredWidth(15);
    tblGroupPerms.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblGroupPerms.getColumnModel().getColumn(2).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(3).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(4).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(5).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(6).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(7).setPreferredWidth(300);

    panelUsers = new JPanel();
    tabbedPane.addTab("Users with access", Builder.getIcon("edit_user.png", 22), panelUsers, null);
    panelUsers.setLayout(new MigLayout("", "[648px,grow]", "[381px,grow][]"));

    JScrollPane scrollUser = new JScrollPane();
    panelUsers.add(scrollUser, "cell 0 0,grow");

    tblUserPerms = new JXTable(userTableModel);

    searchableUser = new TableSearchable(tblUserPerms);
    tblUserPerms.setSearchable(searchableUser);

    tblUserPerms.setSortable(true);
    scrollUser.setViewportView(tblUserPerms);

    btnEditUser = new JButton("View / Edit User");
    btnEditUser.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            editSelectedUser();
          }
        });
    panelUsers.add(btnEditUser, "flowx,cell 0 1");

    btnUserRefresh = new JButton("Refresh");
    btnUserRefresh.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            updateUsersTable();
          }
        });
    panelUsers.add(btnUserRefresh, "cell 0 1");

    tblUserPerms.getColumnModel().getColumn(0).setPreferredWidth(15);
    tblUserPerms.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblUserPerms.getColumnModel().getColumn(2).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(3).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(4).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(5).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(6).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(7).setPreferredWidth(300);

    tblGroupPerms.addMouseListener(this);
    tblUserPerms.addMouseListener(this);

    panelTitle = new JPanel();
    add(panelTitle, "cell 0 0 2 1,growx,aligny top");
    panelTitle.setBackground(Color.WHITE);
    panelTitle.setLayout(new MigLayout("", "[411.00,grow][]", "[][grow]"));

    lblGroupPermissions = new JLabel("Access Permissions");
    lblGroupPermissions.setFont(new Font("Dialog", Font.BOLD, 14));
    panelTitle.add(lblGroupPermissions, "flowy,cell 0 0");

    panelIcon = new JPanel();
    panelIcon.setBackground(Color.WHITE);
    panelTitle.add(panelIcon, "cell 1 0 1 2,grow");

    lblIcon = new JLabel();
    lblIcon.setIcon(Builder.getIcon("trafficlight.png", 64));
    panelIcon.add(lblIcon);

    txtDescription = new JTextArea();
    txtDescription.setBorder(null);
    txtDescription.setEditable(false);
    txtDescription.setFocusable(false);
    txtDescription.setFont(new Font("Dialog", Font.PLAIN, 10));
    txtDescription.setLineWrap(true);
    txtDescription.setWrapStyleWord(true);
    txtDescription.setText(
        "Permissions are set on groups, not users.  You can set: create; read; "
            + "update; and delete permissions separately.  Permissions are inherited from the default "
            + "database permissions given to the group (editable in the main group dialog). If you "
            + "change permissions here you will override the access for the current entity and any "
            + "child entities in the database. "
            + "The users tab shows the current list of users who have permission to access this "
            + "entity in some way.");
    panelTitle.add(txtDescription, "cell 0 1,grow,wmin 10");
  }
Exemple #9
0
  Console() throws IllegalAccessException, InvocationTargetException, IOException {
    super(new BorderLayout());

    history = new History();

    console = new JTextArea();
    console.setMargin(new Insets(5, 5, 5, 5));
    console.setFont(new Font("Monospaced", Font.PLAIN, SMALL_FONT));
    console.setForeground(Color.green);
    console.setBackground(Color.black);

    console.setDoubleBuffered(true);
    console.setEditable(false);
    console.setFocusable(false);
    console.setLineWrap(true);

    prompt = new JTextField();
    prompt.setMargin(new Insets(5, 5, 5, 5));
    prompt.setFont(new Font("Monospaced", Font.PLAIN, BIG_FONT));
    prompt.setForeground(Color.green);
    prompt.setCaretColor(Color.green);

    setPrompt(false);
    setEmacsKeyMap(prompt, history);

    add(new JScrollPane(console), BorderLayout.CENTER);
    add(prompt, BorderLayout.SOUTH);

    final Environment env = new Environment();
    final PrintWriter out = new PrintWriter(new TextAreaStream(console, true), true);
    final Log log = new StandardLog(out, out);
    final View view = new PrintView(out, log);
    final Controller controller =
        new Controller() {
          public final void exit(boolean interact) {
            if (!interact) throw new ExitException();
            EventQueue.invokeLater(
                new Runnable() {
                  public final void run() {
                    log.info("exiting...");
                    postWindowClosingEvent(getFrame(Console.this));
                  }
                });
          }

          public final void ready() {
            EventQueue.invokeLater(
                new Runnable() {
                  public final void run() {
                    setPrompt(true);
                  }
                });
          }
        };

    final Repo repo = new Repo(env.getRepo());
    repo.init();
    doogal =
        new AsyncDoogal(
            log, new PromptDoogal(controller, new SyncDoogal(env, view, controller, repo)));

    prompt.addActionListener(
        new ActionListener() {
          public final void actionPerformed(ActionEvent ev) {
            final String s = prompt.getText();
            history.add(s);
            final Reader reader = new StringReader(s);
            prompt.setText("");
            setPrompt(false);
            try {
              Shellwords.parse(reader, doogal);
            } catch (final EvalException e) {
              log.error(e.getLocalizedMessage());
            } catch (final IOException e) {
              log.error(e.getLocalizedMessage());
            } catch (final ParseException e) {
              log.error(e.getLocalizedMessage());
            }
          }
        });

    printResource("motd.txt", out);
  }
  // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  private void initComponents() {
    final javax.swing.ButtonGroup acceptOrDeclineButtonGroup = new javax.swing.ButtonGroup();
    final javax.swing.JLabel explanationJLabel = new javax.swing.JLabel();

    setOpaque(false);
    explanationJLabel.setFont(Fonts.DialogFont);
    explanationJLabel.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.Explanation"));

    licenseAgreementJTextArea.setColumns(20);
    licenseAgreementJTextArea.setEditable(false);
    licenseAgreementJTextArea.setFont(Fonts.DialogTextEntryFont);
    licenseAgreementJTextArea.setRows(5);
    licenseAgreementJTextArea.setTabSize(4);
    licenseAgreementJTextArea.setFocusable(false);
    licenseAgreementJScrollPane.setViewportView(licenseAgreementJTextArea);

    acceptOrDeclineButtonGroup.add(acceptJRadioButton);
    acceptJRadioButton.setFont(Fonts.DialogFont);
    acceptJRadioButton.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.AcceptLicenseAgreement"));
    acceptJRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    acceptJRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
    acceptJRadioButton.setOpaque(false);
    acceptJRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            acceptJRadioButtonActionPerformed(evt);
          }
        });

    acceptOrDeclineButtonGroup.add(declineJRadioButton);
    declineJRadioButton.setFont(Fonts.DialogFont);
    declineJRadioButton.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.DeclineLicenseAgreement"));
    declineJRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    declineJRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
    declineJRadioButton.setOpaque(false);
    declineJRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            declineJRadioButtonActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                licenseAgreementJScrollPane,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                455,
                                Short.MAX_VALUE)
                            .addComponent(explanationJLabel)
                            .addComponent(acceptJRadioButton)
                            .addComponent(declineJRadioButton))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(100, 100, 100)
                    .addComponent(explanationJLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        licenseAgreementJScrollPane,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        214,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(19, 19, 19)
                    .addComponent(acceptJRadioButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(declineJRadioButton)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
  } // </editor-fold>//GEN-END:initComponents
  // initializes the internal component of the translator
  protected void jbInit() {
    this.getContentPane().setLayout(new GridBagLayout());

    loadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadButton_actionPerformed(e);
          }
        });
    loadButton.setMaximumSize(new Dimension(39, 39));
    loadButton.setMinimumSize(new Dimension(39, 39));
    loadButton.setPreferredSize(new Dimension(39, 39));
    loadButton.setSize(new Dimension(39, 39));
    loadButton.setToolTipText("Load Source File");
    loadButton.setIcon(loadIcon);

    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveButton_actionPerformed(e);
          }
        });
    saveButton.setMaximumSize(new Dimension(39, 39));
    saveButton.setMinimumSize(new Dimension(39, 39));
    saveButton.setPreferredSize(new Dimension(39, 39));
    saveButton.setSize(new Dimension(39, 39));
    saveButton.setToolTipText("Save Destination File");
    saveButton.setIcon(saveIcon);

    singleStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepButton_actionPerformed(e);
          }
        });
    singleStepButton.setMaximumSize(new Dimension(39, 39));
    singleStepButton.setMinimumSize(new Dimension(39, 39));
    singleStepButton.setPreferredSize(new Dimension(39, 39));
    singleStepButton.setSize(new Dimension(39, 39));
    singleStepButton.setToolTipText("Single Step");
    singleStepButton.setIcon(singleStepIcon);

    ffwdButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdButton_actionPerformed(e);
          }
        });
    ffwdButton.setMaximumSize(new Dimension(39, 39));
    ffwdButton.setMinimumSize(new Dimension(39, 39));
    ffwdButton.setPreferredSize(new Dimension(39, 39));
    ffwdButton.setSize(new Dimension(39, 39));
    ffwdButton.setToolTipText("Fast Forward");
    ffwdButton.setIcon(ffwdIcon);

    rewindButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindButton_actionPerformed(e);
          }
        });
    rewindButton.setMaximumSize(new Dimension(39, 39));
    rewindButton.setMinimumSize(new Dimension(39, 39));
    rewindButton.setPreferredSize(new Dimension(39, 39));
    rewindButton.setSize(new Dimension(39, 39));
    rewindButton.setToolTipText("Rewind");
    rewindButton.setIcon(rewindIcon);

    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopButton_actionPerformed(e);
          }
        });
    stopButton.setMaximumSize(new Dimension(39, 39));
    stopButton.setMinimumSize(new Dimension(39, 39));
    stopButton.setPreferredSize(new Dimension(39, 39));
    stopButton.setSize(new Dimension(39, 39));
    stopButton.setToolTipText("Stop");
    stopButton.setIcon(stopIcon);

    fullTranslationButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullTranslationButton_actionPerformed(e);
          }
        });
    fullTranslationButton.setMaximumSize(new Dimension(39, 39));
    fullTranslationButton.setMinimumSize(new Dimension(39, 39));
    fullTranslationButton.setPreferredSize(new Dimension(39, 39));
    fullTranslationButton.setSize(new Dimension(39, 39));
    fullTranslationButton.setToolTipText("Fast Translation");
    fullTranslationButton.setIcon(fullTranslationIcon);

    messageLbl.setFont(Utilities.statusLineFont);
    messageLbl.setLineWrap(true);
    messageLbl.setEditable(false);
    messageLbl.setCursor(null);
    messageLbl.setOpaque(false);
    messageLbl.setFocusable(false);
    messageLblPane.setBorder(BorderFactory.createLoweredBevelBorder());
    // messageLblPane.setBounds(new Rectangle(0, 672, TRANSLATOR_WIDTH - 8, 20));
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 2;
    this.getContentPane().add(messageLblPane, c);

    // arrowLabel.setBounds(new Rectangle(290, 324, 88, 71));
    arrowLabel.setIcon(arrowIcon);

    // source.setVisibleRows(31);
    // destination.setVisibleRows(31);
    // source.setBounds(new Rectangle(35,100,source.getWidth(),source.getHeight()));
    // destination.setBounds(new Rectangle(375,100,destination.getWidth(),destination.getHeight()));

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 1;
    this.getContentPane().add(source, c);

    c.fill = GridBagConstraints.NONE;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 1;
    c.gridy = 1;
    this.getContentPane().add(arrowLabel, c);

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 2;
    c.gridy = 1;
    this.getContentPane().add(destination, c);

    // Adding the tool bar to this container.
    toolBar.setFloatable(false);
    toolBar.setLocation(0, 0);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    arrangeToolBar();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    this.getContentPane().add(toolBar, c);
    toolBar.revalidate();
    toolBar.repaint();
    repaint();

    // Creating the menu bar
    arrangeMenu();
    setJMenuBar(menuBar);

    // initializing the window size and visibility
    setDefaultCloseOperation(3);
    setSize(new Dimension(TRANSLATOR_WIDTH, TRANSLATOR_HEIGHT));
    setVisible(true);
  }
  /** initiate panel */
  private void init() {

    txaHint = new JTextArea();
    txaHint.setBorder(null);
    txaHint.setFocusable(false);
    txaHint.setLineWrap(true);
    txaHint.setWrapStyleWord(true);
    txaHint.setOpaque(false);
    btnHint = new JButton("Hint >>");
    btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
    txtClassDir = new JTextField();
    butSelect = new JButton("Browse..");
    chkBoxIncludeClass = new JCheckBox("include .class file only");
    chkBoxArchiveType = new JCheckBox("Select for Service Group Archive");

    setBackButtonEnabled(true);
    setFinishButtonEnabled(false);
    setPageComplete(false);

    this.setLayout(new GridBagLayout());

    this.add(
        new JLabel("Class file location"),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.1,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 10, 0, 0),
            0,
            0));

    this.add(
        txtClassDir,
        new GridBagConstraints(
            1,
            0,
            GridBagConstraints.RELATIVE,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 1, 1, 1),
            0,
            0));

    txtClassDir.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            update();
          }
        });

    this.add(
        butSelect,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.1,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 1, 1, 10),
            0,
            0));

    butSelect.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = fileChooser.showOpenDialog(butSelect);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fileChooser.getSelectedFile();
              fileChooser.setCurrentDirectory(file);
              txtClassDir.setText(file.getAbsolutePath());
              setPageComplete(true);
              setNextButtonEnabled(true);
            } else {
              txtClassDir.setText("");
            }

            update();
          }
        });

    this.add(
        chkBoxIncludeClass,
        new GridBagConstraints(
            0,
            1,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 10, 1, 1),
            0,
            0));
    chkBoxIncludeClass.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            update();
          }
        });

    //             this.add(chkBoxArchiveType
    //                    , new GridBagConstraints(0, 2, GridBagConstraints.REMAINDER, 1, 0.0, 0.0
    //                    , GridBagConstraints.WEST  , GridBagConstraints.HORIZONTAL
    //                    , new Insets(5, 10, 1,1), 0, 0));
    //            chkBoxArchiveType .addActionListener(new ActionListener()  {
    //                public void actionPerformed(ActionEvent e) {
    //                    update();
    //                }
    //            });
    this.add(
        btnHint,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 10, 0, 10),
            0,
            0));
    btnHint.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (flag) {
              btnHint.setText("Hint >>");
              txaHint.setText("");
              flag = false;
            } else {
              btnHint.setText("Hint <<");
              txaHint.setText(hint);
              flag = true;
            }
            update();
          }
        });

    this.add(
        txaHint,
        new GridBagConstraints(
            0,
            3,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(5, 10, 10, 10),
            0,
            0));
  }
Exemple #13
0
  private JPanel getContentPanel(WizardData wzd) {

    JPanel contentPanel1 = new JPanel();

    welcomeTitle = new JLabel();

    contentPanel1.setLayout(new java.awt.BorderLayout());

    welcomeTitle.setFont(new java.awt.Font("MS Sans Serif", Font.BOLD, 11));
    welcomeTitle.setText("Please insert already existing language files!");
    contentPanel1.add(welcomeTitle, BorderLayout.NORTH);

    // ------------------------------------------------------------------------
    Container mainPanel = new JPanel();
    SpringLayout layout = new SpringLayout();
    mainPanel.setLayout(layout);

    JTextArea infoText = new JTextArea();
    infoText.setLineWrap(false);
    infoText.setEditable(false);
    infoText.setFocusable(false);
    infoText.setBackground(mainPanel.getBackground());
    infoText.append(TInfoText.runtime.getText("newwizard", "site2"));

    JDialog parent = null;
    if (wzd.getWizard() != null) {
      parent = wzd.getWizard().getDialog();
    }
    table = new LanguageManagerPanel(TGlobal.projects.getCurrentProject(), parent, true);

    rescanButton.addActionListener(this);
    baseButton.addActionListener(this);

    // Create and add the components.
    mainPanel.add(infoText);
    mainPanel.add(baseLabel);
    mainPanel.add(baseField);
    mainPanel.add(baseButton);
    mainPanel.add(rescanButton);
    mainPanel.add(table);

    // infoText
    layout.putConstraint(SpringLayout.WEST, infoText, 5, SpringLayout.WEST, mainPanel);
    layout.putConstraint(SpringLayout.NORTH, infoText, 5, SpringLayout.NORTH, mainPanel);

    // baseLabel -------------------------------------------------------------
    layout.putConstraint(SpringLayout.WEST, baseLabel, 0, SpringLayout.WEST, infoText);
    layout.putConstraint(SpringLayout.NORTH, baseLabel, 12, SpringLayout.SOUTH, infoText);

    // nameField
    layout.putConstraint(SpringLayout.WEST, baseField, 5, SpringLayout.EAST, baseLabel);
    layout.putConstraint(SpringLayout.NORTH, baseField, 10, SpringLayout.SOUTH, infoText);

    // baseButton
    layout.putConstraint(SpringLayout.WEST, baseButton, 5, SpringLayout.EAST, baseField);
    layout.putConstraint(SpringLayout.NORTH, baseButton, 7, SpringLayout.SOUTH, infoText);

    // rescanButton
    layout.putConstraint(SpringLayout.WEST, rescanButton, 5, SpringLayout.EAST, baseButton);
    layout.putConstraint(SpringLayout.NORTH, rescanButton, 7, SpringLayout.SOUTH, infoText);

    // table
    layout.putConstraint(SpringLayout.WEST, table, 5, SpringLayout.WEST, mainPanel);
    layout.putConstraint(SpringLayout.NORTH, table, 15, SpringLayout.SOUTH, baseField);

    // panel edges ------------------------------------------------------
    layout.putConstraint(SpringLayout.EAST, mainPanel, 5, SpringLayout.EAST, infoText);
    layout.putConstraint(SpringLayout.SOUTH, mainPanel, 5, SpringLayout.SOUTH, table);

    layout.layoutContainer(mainPanel);
    contentPanel1.add(mainPanel, BorderLayout.CENTER);

    return contentPanel1;
  }
  /**
   * Constructs a WorldFrame that displays the occupants of a world
   *
   * @param world the world to display
   */
  public WorldFrame(World<T> world) {
    this.world = world;
    count++;
    resources = ResourceBundle.getBundle(getClass().getName() + "Resources");

    try {
      System.setProperty("sun.awt.exception.handler", GUIExceptionHandler.class.getName());
    } catch (SecurityException ex) {
      // will fail in an applet
    }

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            count--;
            if (count == 0) System.exit(0);
          }
        });

    displayMap = new DisplayMap();
    String title = System.getProperty("info.gridworld.gui.frametitle");
    if (title == null) title = resources.getString("frame.title");
    setTitle(title);
    setLocation(25, 15);

    URL appIconUrl = getClass().getResource("GridWorld.gif");
    ImageIcon appIcon = new ImageIcon(appIconUrl);
    setIconImage(appIcon.getImage());

    makeMenus();

    JPanel content = new JPanel();
    content.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    content.setLayout(new BorderLayout());
    setContentPane(content);

    display = new GridPanel(displayMap, resources);

    KeyboardFocusManager.getCurrentKeyboardFocusManager()
        .addKeyEventDispatcher(
            new KeyEventDispatcher() {
              public boolean dispatchKeyEvent(KeyEvent event) {
                if (getFocusOwner() == null) return false;
                String text = KeyStroke.getKeyStrokeForEvent(event).toString();
                final String PRESSED = "pressed ";
                int n = text.indexOf(PRESSED);
                if (n < 0) return false;
                // filter out modifier keys; they are neither characters or actions
                if (event.getKeyChar() == KeyEvent.CHAR_UNDEFINED && !event.isActionKey())
                  return false;
                text = text.substring(0, n) + text.substring(n + PRESSED.length());
                boolean consumed = getWorld().keyPressed(text, display.getCurrentLocation());
                if (consumed) repaint();
                return consumed;
              }
            });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewport(new PseudoInfiniteViewport(scrollPane));
    scrollPane.setViewportView(display);
    content.add(scrollPane, BorderLayout.CENTER);

    gridClasses =
        new TreeSet<Class>(
            new Comparator<Class>() {
              public int compare(Class a, Class b) {
                return a.getName().compareTo(b.getName());
              }
            });
    for (String name : world.getGridClasses())
      try {
        gridClasses.add(Class.forName(name));
      } catch (Exception ex) {
        ex.printStackTrace();
      }

    Grid<T> gr = world.getGrid();
    gridClasses.add(gr.getClass());

    makeNewGridMenu();

    control = new GUIController<T>(this, display, displayMap, resources);
    content.add(control.controlPanel(), BorderLayout.SOUTH);

    messageArea = new JTextArea(2, 35);
    messageArea.setEditable(false);
    messageArea.setFocusable(false);
    messageArea.setBackground(new Color(0xFAFAD2));
    content.add(new JScrollPane(messageArea), BorderLayout.NORTH);

    pack();
    repaint(); // to show message
    display.setGrid(gr);
  }
Exemple #15
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
  public FilePanel(
      final ExternalToolConfigView view,
      final List<ExternalToolFileViewer> viewList,
      String fileHeader,
      String typeHeader,
      final String portPrefix,
      final String description,
      String addText) {
    super();
    this.view = view;
    this.setLayout(new BorderLayout());
    final JPanel fileEditPanel = new JPanel(new GridBagLayout());

    final GridBagConstraints fileConstraint = new GridBagConstraints();
    fileConstraint.insets = new Insets(5, 5, 5, 5);
    fileConstraint.anchor = GridBagConstraints.FIRST_LINE_START;
    fileConstraint.gridx = 0;
    fileConstraint.gridy = 0;
    fileConstraint.weightx = 0.1;
    fileConstraint.fill = GridBagConstraints.BOTH;

    final String[] elementLabels =
        new String[] {"Taverna port name", "Use port name for file", fileHeader, typeHeader};

    fileConstraint.gridx = 0;
    synchronized (viewList) {
      for (ExternalToolFileViewer outputView : viewList) {
        addFileViewer(viewList, this, fileEditPanel, outputView, elementLabels);
      }
    }
    JButton addFilePortButton =
        new DeselectingButton(
            addText,
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {

                int portNumber = 1;

                String name2 = portPrefix + portNumber++;
                boolean nameExists = true;
                while (nameExists == true) {
                  nameExists = view.portNameExists(name2);
                  if (nameExists) {
                    name2 = portPrefix + portNumber++;
                  }
                }

                ExternalToolFileViewer newViewer = new ExternalToolFileViewer(name2);
                synchronized (viewList) {
                  viewList.add(newViewer);
                  addFileViewer(viewList, FilePanel.this, fileEditPanel, newViewer, elementLabels);
                  fileEditPanel.revalidate();
                  fileEditPanel.repaint();
                }
              }
            });
    JTextArea descriptionText = new ReadOnlyTextArea(description);
    descriptionText.setEditable(false);
    descriptionText.setFocusable(false);
    descriptionText.setBorder(new EmptyBorder(5, 5, 10, 5));

    this.add(descriptionText, BorderLayout.NORTH);

    this.add(new JScrollPane(fileEditPanel), BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel(new BorderLayout());

    buttonPanel.add(addFilePortButton, BorderLayout.EAST);

    this.add(buttonPanel, BorderLayout.SOUTH);
  }