/** Creates the error area component. */
 private void initErrorArea() {
   SimpleAttributeSet attribs = new SimpleAttributeSet();
   StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);
   StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily());
   StyleConstants.setForeground(attribs, Color.RED);
   errorPane.setParagraphAttributes(attribs, true);
   errorPane.setPreferredSize(new Dimension(100, 50));
   errorPane.setMinimumSize(new Dimension(100, 50));
   errorPane.setOpaque(false);
 }
  public HelpUI(Frame parent, String title) {
    sidebar = new Sidebar();
    sidebar.setBorder(new EmptyBorder(10, 10, 10, 10));
    infoView = new JTextPane();
    Dimension d1 = sidebar.getPreferredSize();
    infoView.setPreferredSize(new Dimension(d1.width * 3, d1.height - 5));
    infoView.setEditable(false);

    MouseAdapter ma =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent me) {
            SidebarOption sopt = (SidebarOption) me.getComponent();
            if (sel != null) {
              sel.setSelected(false);
              sel.repaint();
            }
            sel = sopt;
            sel.setSelected(true);
            sel.repaint();
            renderInfo();
          }
        };

    general = new SidebarOption("General Info", HELP_GENERAL_LOC);
    general.addMouseListener(ma);
    sidebar.add(general);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    artifact = new SidebarOption("Artifacts", HELP_ARTIFACTS_LOC);
    artifact.addMouseListener(ma);
    sidebar.add(artifact);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    net = new SidebarOption("Networking", HELP_NET_LOC);
    net.addMouseListener(ma);
    sidebar.add(net);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    gpl = new SidebarOption("License", HELP_GPL_LOC);
    gpl.addMouseListener(ma);
    sidebar.add(gpl);

    general.setSelected(true);
    sel = general;

    sidebar.add(Box.createVerticalGlue());

    add(BorderLayout.WEST, sidebar);
    add(BorderLayout.CENTER, new JScrollPane(infoView));
    setResizable(false);
    pack();
    setLocationRelativeTo(parent);
    setTitle(title);

    renderInfo();
  }
예제 #3
0
 private void initGUI() {
   try {
     BorderLayout thisLayout = new BorderLayout();
     this.setLayout(thisLayout);
     this.setPreferredSize(new java.awt.Dimension(691, 416));
     {
       tiltePnl = new JPanel();
       BorderLayout tiltePnlLayout = new BorderLayout();
       tiltePnl.setLayout(tiltePnlLayout);
       this.add(tiltePnl, BorderLayout.NORTH);
       tiltePnl.setPreferredSize(new java.awt.Dimension(691, 51));
       {
         titleTxt = new JTextPane();
         tiltePnl.add(titleTxt, BorderLayout.WEST);
         titleTxt.setText("Welche Art von Event moechten Sie besuchen?");
         titleTxt.setPreferredSize(new java.awt.Dimension(626, 58));
         titleTxt.setBackground(new java.awt.Color(212, 208, 200));
         titleTxt.setEditable(false);
         titleTxt.setOpaque(false);
         titleTxt.setFont(new java.awt.Font("Segoe UI", 0, 18));
       }
     }
     {
       contentPnl = new JPanel();
       this.add(contentPnl, BorderLayout.CENTER);
       GridBagLayout contentPnlLayout = new GridBagLayout();
       contentPnlLayout.rowWeights = new double[] {0.0, 0.0, 0.1};
       contentPnlLayout.rowHeights = new int[] {20, 300, 7};
       contentPnlLayout.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.1};
       contentPnlLayout.columnWidths = new int[] {30, 200, 200, 200, 7};
       contentPnl.setLayout(contentPnlLayout);
       contentPnl.setPreferredSize(new java.awt.Dimension(691, 365));
       {
         kindOfEventList = new LikeSelectionList();
         contentPnl.add(
             kindOfEventList,
             new GridBagConstraints(
                 1,
                 1,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.NORTH,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #4
0
 private boolean updateTextPane3270Size() {
   final FontMetrics fontMetricsMonospaced = textPane3270.getFontMetrics(monospacedFont);
   int w = s3270.getScreen().getWidth();
   int h = s3270.getScreen().getHeight();
   if (w != currentWidth || h != currentHeight) {
     textPane3270.setPreferredSize(
         new Dimension(
             (w + 2) * fontMetricsMonospaced.charWidth(' '),
             (h + 2) * fontMetricsMonospaced.getHeight()));
     currentWidth = w;
     currentHeight = h;
     return true;
   }
   return false;
 }
예제 #5
0
  private void initializeGUIComponents() {
    topLevelContainer = new JPanel();
    topLevelContainer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    topLevelContainer.setLayout(new BoxLayout(topLevelContainer, BoxLayout.Y_AXIS));
    setContentPane(topLevelContainer);

    JPanel formPanel = new JPanel();
    JPanel errorPanel = new JPanel();
    JPanel userAgreementNoticePanel = new JPanel();
    JPanel userAgreementPanel = new JPanel();
    JPanel alreadyRegisteredPanel = new JPanel();
    JPanel buttonsPanel = new JPanel();
    topLevelContainer.add(formPanel);
    topLevelContainer.add(errorPanel);
    topLevelContainer.add(Box.createVerticalGlue());
    topLevelContainer.add(userAgreementNoticePanel);
    topLevelContainer.add(userAgreementPanel);
    topLevelContainer.add(alreadyRegisteredPanel);
    topLevelContainer.add(buttonsPanel);

    formPanel.setLayout(new BorderLayout());
    JPanel formLabels = new JPanel(new GridLayout(11, 1));
    formLabels.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    JPanel formFields = new JPanel(new GridLayout(11, 1));
    formPanel.add(formLabels, BorderLayout.LINE_START);
    formPanel.add(formFields, BorderLayout.CENTER);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;

    formLabels.add(new JLabel("First Name"));
    firstNameField = new JTextField();
    JPanel firstNameFieldPanel = new JPanel(new GridBagLayout());
    firstNameFieldPanel.add(firstNameField, constraints);
    formFields.add(firstNameFieldPanel);

    formLabels.add(new JLabel("Last Name"));
    lastNameField = new JTextField();
    JPanel lastNameFieldPanel = new JPanel(new GridBagLayout());
    lastNameFieldPanel.add(lastNameField, constraints);
    formFields.add(lastNameFieldPanel);

    formLabels.add(new JLabel("Email Address"));
    emailAddressField = new JTextField();
    JPanel emailAddressFieldPanel = new JPanel(new GridBagLayout());
    emailAddressFieldPanel.add(emailAddressField, constraints);
    formFields.add(emailAddressFieldPanel);

    formLabels.add(new JLabel(""));
    femaleRadioButton = new JRadioButton("Female");
    formFields.add(femaleRadioButton);

    formLabels.add(new JLabel("Sex"));
    maleRadioButton = new JRadioButton("Male");
    formFields.add(maleRadioButton);

    formLabels.add(new JLabel("Country"));
    countryComboBox = new DisableableComboBox();
    JPanel countryComboBoxPanel = new JPanel(new GridBagLayout());
    countryComboBoxPanel.add(countryComboBox, constraints);
    formFields.add(countryComboBoxPanel);

    formLabels.add(new JLabel("Birthday (Optional)"));
    JPanel birthdayPanel = new JPanel(new GridLayout(1, 3, 10, 0));
    formFields.add(birthdayPanel);
    birthdayYearComboBox = new JComboBox();
    birthdayMonthComboBox = new JComboBox();
    birthdayDayComboBox = new JComboBox();
    JPanel birthdayYearComboBoxPanel = new JPanel(new GridBagLayout());
    JPanel birthdayMonthComboBoxPanel = new JPanel(new GridBagLayout());
    JPanel birthdayDayComboBoxPanel = new JPanel(new GridBagLayout());
    birthdayYearComboBoxPanel.add(birthdayYearComboBox, constraints);
    birthdayMonthComboBoxPanel.add(birthdayMonthComboBox, constraints);
    birthdayDayComboBoxPanel.add(birthdayDayComboBox, constraints);
    birthdayPanel.add(birthdayYearComboBoxPanel);
    birthdayPanel.add(birthdayMonthComboBoxPanel);
    birthdayPanel.add(birthdayDayComboBoxPanel);

    formLabels.add(new JLabel("Password"));
    JPanel passwordFieldPanel = new JPanel(new GridBagLayout());
    passwordField = new JPasswordField();
    passwordFieldPanel.add(passwordField, constraints);
    formFields.add(passwordFieldPanel);

    formLabels.add(new JLabel("Password Confirmation"));
    JPanel passwordConfirmFieldPanel = new JPanel(new GridBagLayout());
    passwordConfirmField = new JPasswordField();
    passwordConfirmFieldPanel.add(passwordConfirmField, constraints);
    formFields.add(passwordConfirmFieldPanel);

    formLabels.add(new JLabel("Profile Picture"));
    JPanel filePanel = new JPanel();
    filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.X_AXIS));
    imageFromFileRadioButton = new JRadioButton("Image from file");
    filePanel.add(imageFromFileRadioButton);
    fileSelector = new FileSelector(filePanel);
    filePanel.add(fileSelector);
    formFields.add(filePanel);

    formLabels.add(new JLabel(""));
    noProfilePictureRadioButton = new JRadioButton("No profile picture");
    formFields.add(noProfilePictureRadioButton);

    setMaxHeightToPreferredHeight(formPanel);

    errorPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5));
    errorLabel = new JLabel("Error message");
    errorLabel.setForeground(Color.RED);
    errorPanel.add(errorLabel);
    setMaxHeightToPreferredHeight(errorPanel);

    userAgreementNoticePanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5));
    userAgreementNoticePanel.add(
        new JLabel("By clicking 'Create Account', you agree to the user agreement below:"));
    setMaxHeightToPreferredHeight(userAgreementNoticePanel);

    userAgreementPanel.setLayout(new BorderLayout());
    JScrollPane userAgreementScrollPane = new JScrollPane();
    userAgreementTextPane = new JTextPane();
    userAgreementTextPane.setContentType("text/html");
    userAgreementTextPane.setText("<b>This</b> is some test text!!!");
    userAgreementTextPane.setPreferredSize(
        new Dimension(userAgreementTextPane.getPreferredSize().width, 150));
    userAgreementScrollPane.setViewportView(userAgreementTextPane);
    userAgreementPanel.add(userAgreementScrollPane, BorderLayout.CENTER);
    setMaxHeightToPreferredHeight(userAgreementPanel);

    alreadyRegisteredPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5));
    alreadyRegisteredPanel.add(new JLabel("Already registered?"));
    setMaxHeightToPreferredHeight(alreadyRegisteredPanel);

    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
    loginButton = new JButton("Login");
    cancelButton = new JButton("Cancel");
    createAccountButton = new JButton("Create Account");
    buttonsPanel.add(loginButton);
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(cancelButton);
    buttonsPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonsPanel.add(createAccountButton);
    setMaxHeightToPreferredHeight(buttonsPanel);

    ButtonGroup sexButtonGroup = new ButtonGroup();
    sexButtonGroup.add(maleRadioButton);
    sexButtonGroup.add(femaleRadioButton);

    ButtonGroup profilePictureButtonGroup = new ButtonGroup();
    profilePictureButtonGroup.add(imageFromFileRadioButton);
    profilePictureButtonGroup.add(noProfilePictureRadioButton);
  }
예제 #6
0
  public ViewPane(GameSessionViewer gsv) {
    _gameSessionViewer = gsv;

    this.setLayout(_layout);

    GridBagConstraints cons = new GridBagConstraints();
    cons.insets = new Insets(5, 5, 5, 5);
    cons.weightx = 0.5;
    cons.gridy = 0;
    cons.gridheight = 5;
    cons.weighty = 0.95;
    cons.fill = GridBagConstraints.BOTH;
    _packetTableModel = new PacketTableModel();
    _packetTable = new JTable(_packetTableModel);
    _packetTable.addMouseListener(new PacketTableMouseListener());
    _packetTable.setDefaultRenderer(Object.class, new PacketTableRenderer(_packetTableModel));
    _packetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _packetTable.getSelectionModel().addListSelectionListener(new PacketSelectionListener());
    _packetTable.getColumnModel().getColumn(0).setMaxWidth(35);
    _packetTable.getColumnModel().getColumn(1).setMaxWidth(50);
    _packetTable.getColumnModel().getColumn(2).setMaxWidth(90);
    _packetTable.getColumnModel().getColumn(3).setMaxWidth(45);
    JScrollPane scrollPane = new JScrollPane(_packetTable);
    this.add(scrollPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    // cons.anchor = GridBagConstraints.NORTH;
    cons.weightx = 0.5;
    cons.weighty = 0.5;
    cons.gridx = 1;
    cons.gridy = 1;
    cons.gridheight = 1;
    _hexDumpArea = new JTextPane();
    _hexDumpArea.setPreferredSize(new Dimension(100, 317));
    // _hexDumpArea.setDoubleBuffered(true);
    _hexStyledDoc = (DefaultStyledDocument) _hexDumpArea.getStyledDocument();
    addStylesToHexDump(_hexStyledDoc);
    // Font font = new Font("Monospaced", Font.PLAIN, 12);
    // _hexDumpArea.setFont(font);
    // _hexDumpArea.setRows(18);
    // _hexDumpArea.setColumns(20);
    JScrollPane hexDumpScrollPane =
        new JScrollPane(
            _hexDumpArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    this.add(hexDumpScrollPane, cons);

    JPanel smallPane = new JPanel();
    smallPane.setLayout(_layout);
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.05;
    cons.weighty = 0.1;
    cons.gridx = 0;
    cons.gridy = 2;
    cons.gridheight = 1;
    JLabel label = new JLabel("Format:");
    _packetFormat = new JTextField();
    _packetFormat.setEditable(false);
    cons.anchor = GridBagConstraints.WEST;
    smallPane.add(label, cons);
    cons.gridx = 1;
    cons.weightx = 0.95;
    cons.fill = GridBagConstraints.HORIZONTAL;
    smallPane.add(_packetFormat, cons);
    cons.weightx = 0.5;
    this.add(smallPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 0.5;
    cons.weighty = 0.4;
    cons.gridx = 1;
    cons.gridy = 4;
    cons.gridheight = 1;
    _packetViewTableModel = new PacketViewTableModel(null);
    _packetViewTable = new JXTreeTable(_packetViewTableModel);
    _packetViewTable.setSelectionModel(new DefaultListSelectionModel());
    _packetViewTable
        .getSelectionModel()
        .addListSelectionListener(new PartSelectionListener(_packetViewTable));
    _packetViewTable.setDefaultRenderer(Object.class, new IconTableRenderer());
    _packetViewTable.addMouseListener(new JTableButtonMouseListener(_packetViewTable));
    _packetViewTable.setTreeCellRenderer(new PacketViewTreeRenderer());
    JScrollPane packetViewScrollPane = new JScrollPane(_packetViewTable);
    this.add(packetViewScrollPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTH;
    cons.gridx = 1;
    cons.gridy = 0;
    cons.weighty = 0.1;
    cons.gridwidth = 1;
    _detailsPanel = new SessionDetailPanel(_gameSessionViewer.getSession());
    this.add(_detailsPanel, cons);

    this.displaySession();
  }
예제 #7
0
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout1);
    this.setModal(true);
    this.setResizable(true);
    this.setTitle("API Account Settings");
    btnOK.setText("OK");
    btnOK.addActionListener(new DialogAccount_btnOK_actionAdapter(this));

    jPanelUNCredential.setDebugGraphicsOptions(0);
    jPanelUNCredential.setLayout(borderLayout2);
    jPanelTokenCredential.setLayout(borderLayout3);
    jPanel1.setLayout(borderLayout5);
    jPanelUNCHolder.setLayout(borderLayout6);
    jPanelTCHolder.setLayout(borderLayout7);
    jPanelAPIAccount.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(3);
    jLabel1.setPreferredSize(new Dimension(80, 15));
    jLabel1.setText("DeveloperID:");
    jLabel3.setPreferredSize(new Dimension(80, 15));
    jLabel3.setText("Certificate:");
    gridLayout2.setColumns(1);
    gridLayout2.setRows(2);
    jLabel6.setText("Paste your token text or ");
    jPanel10.setLayout(borderLayout4);
    jLabel7.setText("        ");
    jLabel8.setToolTipText("");
    jLabel8.setText("        ");
    txtDeveloperID.setPreferredSize(new Dimension(120, 21));
    txtDeveloperID.setSelectionStart(10);
    txtDeveloperID.setText("");
    txtDeveloperID.addActionListener(new DialogAccount_txtDeveloperID_actionAdapter(this));
    txtCertificate.setPreferredSize(new Dimension(120, 21));
    txtCertificate.setText("");
    jPanelBottom.setLayout(borderLayout8);
    jPanel13.setLayout(gridLayout3);
    gridLayout3.setColumns(1);
    gridLayout3.setRows(3);
    jLabel9.setPreferredSize(new Dimension(90, 15));
    jLabel9.setText("API Server URL:");
    jLabel10.setPreferredSize(new Dimension(90, 15));
    jLabel10.setText("EPS Server URL:");
    txtApiServerUrl.setPreferredSize(new Dimension(280, 21));
    txtApiServerUrl.setText("");
    txtEpsServerUrl.setPreferredSize(new Dimension(280, 21));
    txtEpsServerUrl.setText("http://msa-e1.ebay.com/ws/eBayISAPI.dll?EpsBasicApp");
    txtEpsServerUrl.setColumns(0);
    jPanel16.setLayout(borderLayout9);
    jLabel2.setPreferredSize(new Dimension(80, 15));
    jLabel2.setText("ApplicationID:");
    txtApplicationID.setPreferredSize(new Dimension(120, 21));
    txtApplicationID.setRequestFocusEnabled(true);
    txtApplicationID.setText("");
    txtTokenData.setPreferredSize(new Dimension(50, 200));
    txtSigninUrl.setPreferredSize(new Dimension(280, 21));
    txtSigninUrl.setText("http://my.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn");
    jLabel11.setPreferredSize(new Dimension(90, 15));
    jLabel11.setText("Sign-In URL:");
    jPanel13.setBorder(BorderFactory.createEtchedBorder());
    jScrollPane1.setPreferredSize(new Dimension(54, 40));
    btnCancel.setToolTipText("");
    btnCancel.setText("Cancel");
    btnCancel.addActionListener(new DialogAccount_btnCancel_actionAdapter(this));
    jPanelChoices.setLayout(borderLayout10);
    btnFetchToken.setText("Generate a New Token");
    btnFetchToken.addActionListener(new DialogAccount_btnFetchToken_actionAdapter(this));
    jPanel10.setPreferredSize(new Dimension(102, 40));
    jPanel16.setPreferredSize(new Dimension(400, 480));
    jPanelTokenCredential.setBorder(BorderFactory.createEtchedBorder());
    jPanelApiCredentials.setBorder(BorderFactory.createEtchedBorder());
    jPanelAppId.add(jLabel2, null);
    jPanelAppId.add(txtApplicationID, null);
    this.getContentPane().add(jPanelBottom, BorderLayout.SOUTH);
    jPanel10.add(jLabel7, BorderLayout.WEST);
    jPanel10.add(jLabel8, BorderLayout.EAST);
    jPanel10.add(jScrollPane1, BorderLayout.CENTER);
    jPanel16.add(jPanel13, BorderLayout.SOUTH);
    jScrollPane1.getViewport().add(txtTokenData, null);
    jPanelTokenCredential.add(jPanel11, BorderLayout.NORTH);
    jPanel11.add(jLabel6, null);
    jPanel11.add(btnFetchToken, null);
    jPanelTokenCredential.add(jPanel10, BorderLayout.CENTER);
    jPanelTCHolder.add(jPanelTokenCredential, BorderLayout.CENTER);
    this.getContentPane().add(jPanel16, BorderLayout.CENTER);
    jPanelDevId.add(jLabel1, null);
    jPanelDevId.add(txtDeveloperID, null);
    jPanelAPIAccount.add(jPanelDevId, null);
    jPanelCertificate.add(jLabel3, null);
    jPanelCertificate.add(txtCertificate, null);
    jPanel16.add(jPanelChoices, BorderLayout.CENTER);
    jPanelChoices.add(jPanelUNCHolder, BorderLayout.NORTH);
    jPanelAPIAccount.add(jPanelAppId, null);
    jPanelAPIAccount.add(jPanelCertificate, null);
    jPanelUNCHolder.add(jPanelUNCredential, BorderLayout.CENTER);
    jPanel16.add(jPanelApiCredentials, BorderLayout.NORTH);
    jPanelApiCredentials.add(jPanelAPIAccount, null);
    jPanelUNCredential.add(jPanel1, BorderLayout.SOUTH);
    jPanelChoices.add(jPanelTCHolder, BorderLayout.CENTER);
    jPanelBottom.add(jPanel12, BorderLayout.SOUTH);
    jPanel12.add(btnOK, null);
    jPanel12.add(btnCancel, null);
    jPanelApiServer.add(jLabel9, null);
    jPanelApiServer.add(txtApiServerUrl, null);
    jPanel13.add(jPanelEpsServer, null);
    jPanel13.add(jPanelApiServer, null);
    jPanelEpsServer.add(jLabel10, null);
    jPanelEpsServer.add(txtEpsServerUrl, null);
    jPanel13.add(jPanelSignInUrl, null);
    jPanelSignInUrl.add(jLabel11, null);
    jPanelSignInUrl.add(txtSigninUrl, null);
  }
  /* (non-Javadoc)
   * @see edu.ku.brc.ui.forms.formatters.DataObjFieldFormatPanelBuilder#buildUI()
   */
  protected void buildUI() {
    CellConstraints cc = new CellConstraints();

    JLabel currentFieldsLbl = createI18NLabel("DOF_DISPLAY_FORMAT");
    formatEditor = new JTextPane();
    // to make sure the component shrinks with the dialog
    formatEditor.setMinimumSize(new Dimension(200, 50));
    formatEditor.setPreferredSize(new Dimension(350, 100));

    formatEditor
        .getDocument()
        .addDocumentListener(
            new DocumentAdaptor() {
              @Override
              public void changed(DocumentEvent e) {
                updateUIEnabled();
              }
            });

    PanelBuilder addFieldPB = new PanelBuilder(new FormLayout("p,2px,p,f:p:g,r:m", "p,2px,p"));
    sepText = createTextField(4);
    addFieldBtn = createButton(getResourceString("DOF_ADD_FIELD"));
    sepLbl = createI18NFormLabel("DOF_SEP_TXT");

    addFieldPB.add(sepLbl, cc.xy(1, 1));
    addFieldPB.add(sepText, cc.xy(3, 1));
    addFieldPB.add(addFieldBtn, cc.xy(5, 1));

    sepText.setDocument(new FilteredDoc());

    addFieldBtn.setEnabled(false);
    sepLbl.setEnabled(false);
    sepText.setEnabled(false);

    // For when it is standalone
    if (AppPreferences.hasRemotePrefs()) {
      sepText.setText(AppPreferences.getRemote().get("DOF_SEP", ", "));

    } else {
      sepText.setText(", ");
    }

    PanelBuilder pb =
        new PanelBuilder(
            new FormLayout(
                "f:d:g",
                "10px,"
                    + // empty space on top of panel
                    "p,f:p:g,"
                    + // Label & format text editor
                    "2px,p,"
                    + // separator & add field
                    "10px,p,"
                    + // separator & label
                    "f:250px:g," // list box for available fields
                ),
            this);

    // layout components on main panel
    int y = 2; // leave first row blank

    pb.add(currentFieldsLbl, cc.xy(1, y));
    y += 1;
    pb.add(UIHelper.createScrollPane(formatEditor), cc.xy(1, y));
    y += 2;

    pb.add(addFieldPB.getPanel(), cc.xy(1, y));
    y += 2;

    JLabel availableFieldsLbl = createI18NFormLabel("DOF_AVAILABLE_FIELDS", SwingConstants.LEFT);
    pb.add(availableFieldsLbl, cc.xy(1, y));
    y += 1;

    // create field tree that will be re-used in all instances of single switch formatter editing
    // panel
    availableFieldsComp =
        new AvailableFieldsComponent(
            tableInfo, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache);

    pb.add(UIHelper.createScrollPane(availableFieldsComp.getTree()), cc.xy(1, y));
    y += 2;

    availableFieldsComp
        .getTree()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              @Override
              public void valueChanged(TreeSelectionEvent e) {
                boolean enable = availableFieldsComp.getTree().getSelectionCount() > 0;
                addFieldBtn.setEnabled(enable);
                sepText.setEnabled(enable);
                sepLbl.setEnabled(enable);
              }
            });

    this.mainPanelBuilder = pb;

    fillWithObjFormatter(formatContainer.getSelectedFormatter());

    addFormatTextListeners();

    // must be called after list of available fields has been created
    addFieldListeners();
  }
예제 #9
0
파일: APropos.java 프로젝트: sipi/memento
    @Override
    public void actionPerformed(ActionEvent e) {

      licence_text =
          new String(
              "This program is free software: you can redistribute it and/or modify\n"
                  + "it under the terms of the GNU General Public License as published by\n"
                  + "the Free Software Foundation, either version 3 of the License, or\n"
                  + "(at your option) any later version.\n"
                  + "\n"
                  + "This program is distributed in the hope that it will be useful,\n"
                  + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                  + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
                  + "GNU General Public License for more details.\n"
                  + "\n"
                  + "You should have received a copy of the GNU General Public License\n"
                  + "along with this program.  If not, see <http://www.gnu.org/licenses/>.\n"
                  + "\n\n\n");

      try {
        InputStream ips = new FileInputStream(getClass().getResource("COPYING").getPath());
        InputStreamReader ipsr = new InputStreamReader(ips);
        BufferedReader br = new BufferedReader(ipsr);

        String line;
        while ((line = br.readLine()) != null) {
          licence_text += line + '\n';
        }
        br.close();
      } catch (Exception e1) {
      }

      Dimension dimension = new Dimension(600, 400);

      JDialog licence = new JDialog(memento, "Licence");

      JTextPane text_pane = new JTextPane();
      text_pane.setEditable(false);
      text_pane.setPreferredSize(dimension);
      text_pane.setSize(dimension);

      StyledDocument doc = text_pane.getStyledDocument();

      Style justified =
          doc.addStyle(
              "justified",
              StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE));
      StyleConstants.setAlignment(justified, StyleConstants.ALIGN_JUSTIFIED);

      try {
        doc.insertString(0, licence_text, justified);
      } catch (BadLocationException ble) {
        System.err.println("Couldn't insert initial text into text pane.");
      }
      Style logicalStyle = doc.getLogicalStyle(0);
      doc.setParagraphAttributes(0, licence_text.length(), justified, false);
      doc.setLogicalStyle(0, logicalStyle);

      JScrollPane paneScrollPane = new JScrollPane(text_pane);
      paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
      paneScrollPane.setPreferredSize(dimension);
      paneScrollPane.setMinimumSize(dimension);

      JPanel pan = new JPanel();
      LayoutManager layout = new BorderLayout();
      pan.setLayout(layout);

      pan.add(new JScrollPane(paneScrollPane), BorderLayout.CENTER);
      JButton close = new JButton("Fermer");
      close.addActionListener(new ButtonCloseActionListener(licence));
      JPanel button_panel = new JPanel();
      FlowLayout button_panel_layout = new FlowLayout(FlowLayout.RIGHT, 20, 20);
      button_panel.setLayout(button_panel_layout);

      button_panel.add(close);
      pan.add(button_panel, BorderLayout.SOUTH);

      licence.add(pan);

      licence.pack();
      licence.setLocationRelativeTo(memento);
      licence.setVisible(true);
    }
예제 #10
0
 private void initGUI() {
   try {
     BorderLayout thisLayout = new BorderLayout();
     this.setLayout(thisLayout);
     this.setPreferredSize(new java.awt.Dimension(691, 416));
     {
       tiltePnl = new JPanel();
       BorderLayout tiltePnlLayout = new BorderLayout();
       tiltePnl.setLayout(tiltePnlLayout);
       this.add(tiltePnl, BorderLayout.NORTH);
       tiltePnl.setPreferredSize(new java.awt.Dimension(691, 51));
       {
         titleTxt = new JTextPane();
         tiltePnl.add(titleTxt, BorderLayout.WEST);
         titleTxt.setText("In welchem Zeitraum soll das Event statt finden?");
         titleTxt.setPreferredSize(new java.awt.Dimension(626, 58));
         titleTxt.setBackground(new java.awt.Color(212, 208, 200));
         titleTxt.setEditable(false);
         titleTxt.setOpaque(false);
         titleTxt.setFont(new java.awt.Font("Segoe UI", 0, 18));
       }
     }
     {
       contentPnl = new JPanel();
       this.add(contentPnl, BorderLayout.CENTER);
       GridBagLayout contentPnlLayout = new GridBagLayout();
       contentPnlLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1};
       contentPnlLayout.rowHeights = new int[] {20, 50, 50, 50, 50, 50, 50, 5};
       contentPnlLayout.columnWeights = new double[] {0.0, 0.0, 0.2};
       contentPnlLayout.columnWidths = new int[] {30, 400, 5};
       contentPnl.setLayout(contentPnlLayout);
       contentPnl.setPreferredSize(new java.awt.Dimension(635, 277));
       {
         summerbreakBtn = new JRadioButton();
         contentPnl.add(
             summerbreakBtn,
             new GridBagConstraints(
                 1,
                 4,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         summerbreakBtn.setText("Sommerferien");
         getTimeRangeGroup().add(summerbreakBtn);
       }
       {
         autumbreakBtn = new JRadioButton();
         contentPnl.add(
             autumbreakBtn,
             new GridBagConstraints(
                 1,
                 1,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getWinterbreakBtn(),
             new GridBagConstraints(
                 1,
                 2,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getEasterbreak(),
             new GridBagConstraints(
                 1,
                 3,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getMiscTimeRange(),
             new GridBagConstraints(
                 1,
                 5,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getMiscTimeRangePnl(),
             new GridBagConstraints(
                 1,
                 6,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.CENTER,
                 GridBagConstraints.BOTH,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         autumbreakBtn.setText("Herbstferien");
         getTimeRangeGroup().add(autumbreakBtn);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #11
0
  public void show() {
    final String aboutText = Tools.getLabel(messages.getString("guiMenuAbout"));

    JTextPane aboutPane = new JTextPane();
    aboutPane.setBackground(new Color(0, 0, 0, 0));
    aboutPane.setBorder(BorderFactory.createEmptyBorder());
    aboutPane.setContentType("text/html");
    aboutPane.setEditable(false);
    aboutPane.setOpaque(false);

    aboutPane.setText(
        String.format(
            "<html>"
                + "<p>LanguageTool %s (%s)<br>"
                + "Copyright (C) 2005-2014 the LanguageTool community and Daniel Naber<br>"
                + "This software is licensed under the GNU Lesser General Public License.<br>"
                + "<a href=\"http://www.languagetool.org\">http://www.languagetool.org</a></p>"
                + "<p>Maintainers of the language modules:</p><br>"
                + "</html>",
            JLanguageTool.VERSION, JLanguageTool.BUILD_DATE));

    aboutPane.addHyperlinkListener(
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (Exception ex) {
                  Tools.showError(ex);
                }
              }
            }
          }
        });

    JTextPane maintainersPane = new JTextPane();
    maintainersPane.setBackground(new Color(0, 0, 0, 0));
    maintainersPane.setBorder(BorderFactory.createEmptyBorder());
    maintainersPane.setContentType("text/html");
    maintainersPane.setEditable(false);
    maintainersPane.setOpaque(false);

    maintainersPane.setText(getMaintainers());

    int maxHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2;
    if (maintainersPane.getPreferredSize().height > maxHeight) {
      maintainersPane.setPreferredSize(
          new Dimension(maintainersPane.getPreferredSize().width, maxHeight));
    }

    JScrollPane scrollPane = new JScrollPane(maintainersPane);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(aboutPane);
    panel.add(scrollPane);

    JOptionPane.showMessageDialog(parent, panel, aboutText, JOptionPane.INFORMATION_MESSAGE);
  }
예제 #12
0
  // Experience suggests that one should avoid using weights when using the
  // GridBagLayout. I find that nonzero weights can cause layout bugs that are
  // hard to track down. [Jon Aquino]
  void jbInit() throws Exception {
    _descriptionTextArea.setOpaque(false);
    get_okCancelPanel()
        .addActionListener(
            new java.awt.event.ActionListener() {
              public void actionPerformed(ActionEvent e) {
                okCancelPanel_actionPerformed(e);
              }
            });
    this.addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentShown(ComponentEvent e) {
            this_componentShown(e);
          }
        });

    // _outerMainPanel.setLayout(new GridBagLayout());
    // _outerMainPanel.setAlignmentX((float) 0.7);
    _outerMainPanel.setLayout(new BorderLayout());
    this.setResizable(true);
    this.getContentPane().setLayout(new BorderLayout());
    _imagePanel.setBorder(BorderFactory.createEtchedBorder());
    _imagePanel.setLayout(new GridBagLayout());
    _mainPanel.setLayout(new BorderLayout());
    try {
      _descriptionTextArea.setPreferredSize(new Dimension(100, 100));
      _descriptionTextArea.setOpaque(false);
      _descriptionTextArea.setEnabled(false);
      _descriptionTextArea.setEditable(false);
      _descriptionTextArea.setContentType("text/html");
    } catch (RuntimeException e1) {
      // Problemas para instanciar el kit text/html en el Plugin
      logger.error("jbInit()", e1);
      if (logger.isDebugEnabled()) {
        logger.debug(
            "jbInit() - La clase a instanciar para html es:"
                + _descriptionTextArea.getEditorKitForContentType("text/html"));
      }
    }

    documentExtendedForm = new DocumentExtendedForm();
    documentExtendedForm.initialize(this);
    setDescription();
    _imagePanel.add(
        _descriptionTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(10, 10, 10, 10),
            0,
            0));

    _imagePanel.add(
        _infoFeatures,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(10, 10, 10, 10),
            0,
            0));
    _imagePanel.add(
        _strutPanel,
        new GridBagConstraints(
            0,
            20,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    _outerMainPanel.add(_mainPanel, BorderLayout.CENTER);
    _outerMainPanel.add(_imagePanel, BorderLayout.WEST);

    _descriptionTextArea.setFont(_imageLabel.getFont());
    _descriptionTextArea.setDisabledTextColor(_imageLabel.getForeground());
    if (features.size() > 1) _infoFeatures.add(getFeaturesComboBox(), null);
    this.setContentPane(getContentPanel()); // Generated
    _strutPanel.add(getZoomFeatureButton(), null); // Generated
    _strutPanel.add(getFlashFeatureButton(), null); // Generated
  }
 private void jbInit() throws Exception {
   this.getContentPane().setLayout(gridBagLayout2);
   bottomPanel.setLayout(gridBagLayout1);
   messagePanel.setBorder(BorderFactory.createLoweredBevelBorder());
   replaceButton.setToolTipText("Save the new trace replacing the old trace.");
   replaceButton.setText("Replace old trace");
   replaceButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           replaceOldTrace();
         }
       });
   buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder());
   discardButton.setToolTipText("Discard the new trace");
   discardButton.setText("Discard new trace");
   discardButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           DoneReplayDialog.this.setVisible(false);
         }
       });
   saveButton.setToolTipText("Save the new trace in a file.");
   saveButton.setText("Save as new file");
   saveButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           saveNewToFile();
         }
       });
   this.setModal(true);
   this.setTitle("Replay Complete");
   jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   jScrollPane1.setMinimumSize(new Dimension(200, 200));
   jScrollPane1.setPreferredSize(new Dimension(200, 200));
   jTextPane.setMinimumSize(new Dimension(25, 80));
   jTextPane.setPreferredSize(new Dimension(40, 80));
   tracePanel.setLayout(borderLayout1);
   commentPanel.setLayout(borderLayout3);
   jPanel6.setLayout(borderLayout2);
   jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   jScrollPane2.setMinimumSize(new Dimension(200, 100));
   jScrollPane2.setPreferredSize(new Dimension(200, 100));
   jLabel1.setText("Comment");
   jLabel2.setText("Traces (Old is Yellow, New is Pink)");
   tracePanel.setBorder(BorderFactory.createEtchedBorder());
   bottomPanel.setBorder(BorderFactory.createEtchedBorder());
   commentPanel.setBorder(BorderFactory.createEtchedBorder());
   this.getContentPane()
       .add(
           bottomPanel,
           new GridBagConstraints(
               0,
               3,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.HORIZONTAL,
               new Insets(0, 5, 5, 5),
               0,
               0));
   buttonPanel.add(saveButton, null);
   buttonPanel.add(replaceButton, null);
   buttonPanel.add(discardButton, null);
   bottomPanel.add(
       messagePanel,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
   messagePanel.add(messageLabel, null);
   this.getContentPane()
       .add(
           tracePanel,
           new GridBagConstraints(
               0,
               2,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.BOTH,
               new Insets(0, 0, 0, 0),
               0,
               0));
   tracePanel.add(jScrollPane1, BorderLayout.CENTER);
   tracePanel.add(jLabel2, BorderLayout.NORTH);
   this.getContentPane()
       .add(
           commentPanel,
           new GridBagConstraints(
               0,
               1,
               1,
               1,
               1.0,
               1.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.BOTH,
               new Insets(0, 5, 5, 5),
               0,
               0));
   commentPanel.add(jPanel6, BorderLayout.CENTER);
   jPanel6.add(jScrollPane2, BorderLayout.CENTER);
   commentPanel.add(jLabel1, BorderLayout.NORTH);
   jScrollPane2.getViewport().add(commentPane, null);
   jScrollPane1.getViewport().add(jTextPane, null);
   bottomPanel.add(
       buttonPanel,
       new GridBagConstraints(
           0,
           1,
           2,
           2,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
예제 #14
0
  public Scripter() {
    setTitle("Runedev Script Editor");
    setVisible(true);
    setBackground(new Color(245, 245, 245));
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(final WindowEvent e) {
            // BotGUI.scripter = null;
          }
        });
    setResizable(false);
    final File icon = new File(GlobalConfiguration.Paths.getIconDirectory() + "/edit.png");
    setIconImage(GlobalConfiguration.getImageFile(icon));

    document = new HighLightedDocument();
    jSeparator1 = new JPopupMenu.Separator();

    textPane = new JTextPane(document);
    textPane.setCaretPosition(0);
    textPane.setMargin(new Insets(5, 5, 5, 5));
    textPane.setPreferredSize(new Dimension(minSize));
    final JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(minSize));

    final JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.add(scrollPane, BorderLayout.CENTER);
    setContentPane(contentPane);

    final JMenuBar menuBar = new JMenuBar();

    final JMenu fileMenu = new JMenu("File");
    final JMenuItem newScript = new JMenuItem("New");
    newScript.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
    newScript.setIcon(new ImageIcon(GlobalConfiguration.Paths.getIconDirectory() + "/pencil.png"));
    fileMenu.add(newScript);

    final JMenuItem openScript = new JMenuItem("Open");
    openScript.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
    final Image Open =
        (Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.Paths.Resources.PLAY));
    openScript.setIcon(new ImageIcon(Open));
    fileMenu.add(openScript);

    final JMenuItem saveScript = new JMenuItem("Save");
    saveScript.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
    final Image Save =
        (Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.Paths.Resources.SAVE));
    saveScript.setIcon(new ImageIcon(Save));
    fileMenu.add(saveScript);
    menuBar.add(fileMenu);

    final JMenu editMenu = new JMenu("Edit");
    final JMenuItem cut = new JMenuItem("Cut");
    cut.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
    final Image Cut =
        (Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.Paths.Resources.CUT));
    cut.setIcon(new javax.swing.ImageIcon(Cut));
    editMenu.add(cut);

    final JMenuItem copy = new JMenuItem("Copy");
    copy.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
    final Image Copy =
        (Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.Paths.Resources.COPY));
    copy.setIcon(new javax.swing.ImageIcon(Copy));
    editMenu.add(copy);

    final JMenuItem paste = new JMenuItem("Paste");
    paste.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
    final Image Paste =
        (Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.Paths.Resources.PASTE));
    paste.setIcon(new javax.swing.ImageIcon(Paste));
    editMenu.add(paste);
    editMenu.add(jSeparator1);

    final JMenuItem selectAll = new JMenuItem("Select All");
    selectAll.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
    editMenu.add(selectAll);
    menuBar.add(editMenu);

    final JMenu infoMenu = new JMenu("Info");
    final JMenuItem troubleshooting = new JMenuItem("Troubleshooting");
    troubleshooting.setIcon(
        new ImageIcon(GlobalConfiguration.Paths.getIconDirectory() + "/web.png"));
    infoMenu.add(troubleshooting);

    final JMenuItem about = new JMenuItem("about");
    about.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_F1, java.awt.event.InputEvent.CTRL_MASK));
    about.setIcon(new ImageIcon(GlobalConfiguration.Paths.getIconDirectory() + "/gui.png"));
    infoMenu.add(about);
    menuBar.add(infoMenu);

    class newClick implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        if (JOptionPane.showConfirmDialog(
                contentPane,
                "You really want to start a new script? \n"
                    + "All un-saved work on this script will be lost.")
            == 0) {
          try {
            document.remove(0, document.getLength());
            document.insertString(document.getLength(), defaultLayout, getStyle("text"));
          } catch (final BadLocationException e1) {
          }
        }
      }
    }

    class openClick implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        final JFileChooser fc = new JFileChooser(file);
        fc.setCurrentDirectory(new File("./scripts/"));
        fc.addChoosableFileFilter(new JavaFilter());
        if (fc.showOpenDialog(contentPane) == JFileChooser.APPROVE_OPTION) {
          file = fc.getSelectedFile();
          try {
            document.remove(0, document.getLength());
            final BufferedReader in = new BufferedReader(new FileReader(file));
            String line = null;
            while ((line = in.readLine()) != null) {
              if (document.getLength() != 0) {
                document.insertString(document.getLength(), "\n", getStyle("text"));
              }
              document.insertString(document.getLength(), line, getStyle("text"));
            }
          } catch (final Exception ee) {
          }
        }
      }
    }

    class saveClick implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        final JFileChooser fc = new JFileChooser(file);
        fc.setCurrentDirectory(new File("./scripts/"));
        fc.addChoosableFileFilter(new JavaFilter());
        if (fc.showSaveDialog(contentPane) == JFileChooser.APPROVE_OPTION) {
          try {
            file = fc.getSelectedFile();
            final BufferedWriter out = new BufferedWriter(new FileWriter(file));
            out.write(document.getText(0, document.getLength()));

            out.close();
          } catch (final Exception ee) {
          }
        }
      }
    }

    class Cut implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        textPane.cut();
      }
    }

    class Copy implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        textPane.copy();
      }
    }

    class Paste implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        textPane.paste();
      }
    }

    class SelectAll implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        textPane.selectAll();
      }
    }

    class tsClick implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        openURL("http://forum.runedev.info/viewtopic.php?f=40&t=2629");
      }

      public void openURL(final String url) {
        final OperatingSystem os = GlobalConfiguration.getCurrentOperatingSystem();
        try {
          if (os == OperatingSystem.MAC) {
            final Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
            final Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
            openURL.invoke(null, url);
          } else if (os == OperatingSystem.WINDOWS) {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
          } else {
              /* assume Unix or Linux */
            final String[] browsers = {
              "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"
            };
            String browser = null;
            for (int count = 0; (count < browsers.length) && (browser == null); count++) {
              if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor()
                  == 0) {
                browser = browsers[count];
              }
            }
            if (browser == null) {
              throw new Exception("Could not find web browser");
            } else {
              Runtime.getRuntime().exec(new String[] {browser, url});
            }
          }
        } catch (final Exception e) {
        }
      }
    }

    class aboutClick implements ActionListener {

      public void actionPerformed(final ActionEvent e) {
        JOptionPane.showMessageDialog(
            contentPane,
            new String[] {
              "A Script Editor Made for RuneDev.",
              "\nThis Editor was designed by Sorcermus\n"
                  + "for the RuneDev gaming client\n"
                  + "For more information, \nvisit; "
                  + GlobalConfiguration.Paths.URLs.SITE
            },
            "\n" + "About this editor, and the game client",
            JOptionPane.INFORMATION_MESSAGE);
      }
    }

    newScript.addActionListener(new newClick());
    openScript.addActionListener(new openClick());
    saveScript.addActionListener(new saveClick());
    cut.addActionListener(new Cut());
    copy.addActionListener(new Copy());
    paste.addActionListener(new Paste());
    selectAll.addActionListener(new SelectAll());
    troubleshooting.addActionListener(new tsClick());
    about.addActionListener(new aboutClick());

    setJMenuBar(menuBar);

    final JTextArea lines = new JTextArea("");
    lines.setSelectionEnd(document.getLength());
    lines.setFont(new Font("Monospaced", Font.PLAIN, 12));
    lines.setBackground(new Color(210, 210, 210));
    lines.setEditable(false);
    lines.setMargin(new Insets(5, 2, 5, 2));

    document.addDocumentListener(
        new DocumentListener() {

          public void changedUpdate(final DocumentEvent de) {
            lines.setText(getText());
          }

          public String getText() {
            final int caretPosition = document.getEndPosition().getOffset();
            final Element root = document.getDefaultRootElement();
            String text = "1" + System.getProperty("line.separator");
            for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
              text += i + System.getProperty("line.separator");
            }
            return text;
          }

          public void insertUpdate(final DocumentEvent de) {
            lines.setText(getText());
          }

          public void removeUpdate(final DocumentEvent de) {
            lines.setText(getText());
          }
        });

    scrollPane.setRowHeaderView(lines);

    colorer = new Colorer();
    colorer.start();

    initStyles(12);

    documentReader = new DocumentReader(document);

    initDocument();

    pack();
    setVisible(true);
  }
예제 #15
0
    public DocumentPanel() {
      super(new BorderLayout());

      JLabel lblDocument = new JLabel("Document: " + document.getTitle());
      lblDocument.setBorder(new EtchedBorder());

      textPane = new JTextPane(document);
      textPane.setEditable(false);
      textPane.setMargin(new Insets(5, 20, 5, 5));
      textPane.setMaximumSize(new Dimension(364, 1000000000));
      textPane.setPreferredSize(new Dimension(364, 400));
      textPane.setMinimumSize(new Dimension(364, 10));
      textPane.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              int length = document.getLength();
              int offset = e.getDot();

              if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1);

              Paragraph p = lockManager.getParFromOffset(offset);
              int pOffset = p.getOffset();

              lblCursor.setText(
                  "Document Length="
                      + String.valueOf(length)
                      + ", CaretOffset="
                      + String.valueOf(offset)
                      + ", Paragraph="
                      + p.toString()
                      + ", Offset in Paragraph="
                      + String.valueOf(offset - p.getOffset()));
            }
          });
      Box box = new Box(BoxLayout.X_AXIS);
      box.add(textPane);
      box.add(Box.createGlue());
      box.setBackground(Color.WHITE);
      box.setOpaque(true);
      box.setPreferredSize(new Dimension(600, 10000));

      lblCursor = new JLabel("Cursor");
      lblCursor.setBorder(new EtchedBorder());

      JPanel boxText = new JPanel(new BorderLayout());
      boxText.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxText.add(lblDocument, BorderLayout.NORTH);
      boxText.add(new JScrollPane(box), BorderLayout.CENTER);
      boxText.add(lblCursor, BorderLayout.SOUTH);

      JLabel lblPars = new JLabel("Paragraphs: ");
      lblPars.setBorder(new EtchedBorder());

      parList = new JList();
      parList.setPreferredSize(new Dimension(100, 300));
      parList.setEnabled(false);

      JPanel boxPars = new JPanel(new BorderLayout());
      boxPars.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxPars.add(lblPars, BorderLayout.NORTH);
      boxPars.add(new JScrollPane(parList), BorderLayout.CENTER);

      add(boxText, BorderLayout.CENTER);
      add(boxPars, BorderLayout.EAST);
    }