コード例 #1
0
ファイル: JavaViewer.java プロジェクト: mbigigns/SWTGuitar
 void open(java.lang.String name) {
   final java.lang.String textString;
   if (name == null || name.length() == 0) {
     return;
   }
   java.io.File file = new java.io.File(name);
   if (!file.exists()) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   try {
     java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath());
     try {
       java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
       char[] readBuffer = new char[2048];
       java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length());
       int n;
       while ((n = in.read(readBuffer)) > 0) {
         buffer.append(readBuffer, 0, (-n));
       }
       textString = buffer.toString();
       stream.close();
     } catch (java.io.IOException e) {
       java.lang.String message =
           MessageFormat.format(
               resources.getString("Err_file_io"), new java.lang.String[] {file.getName()});
       displayError(message);
       return;
     }
   } catch (java.io.FileNotFoundException e) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_not_found"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   org.eclipse.swt.widgets.Display display = text.getDisplay();
   display.asyncExec(
       new java.lang.Runnable() {
         public void run() {
           text.setText(textString);
         }
       });
   lineStyler.parseBlockComments(textString);
 }
コード例 #2
0
 protected java.lang.String getProperty(java.lang.String name)
     throws java.util.MissingResourceException {
   if (props == null) {
     throw new java.util.MissingResourceException(name, name, name);
   } else {
     return props.getString(name);
   }
 }
コード例 #3
0
ファイル: JavaViewer.java プロジェクト: mbigigns/SWTGuitar
 void createMenuBar() {
   org.eclipse.swt.widgets.Menu bar = new org.eclipse.swt.widgets.Menu(shell, SWT.BAR);
   shell.setMenuBar(bar);
   org.eclipse.swt.widgets.MenuItem fileItem =
       new org.eclipse.swt.widgets.MenuItem(bar, SWT.CASCADE);
   fileItem.setText(resources.getString("File_menuitem"));
   fileItem.setMenu(createFileMenu());
 }
コード例 #4
0
 static java.lang.String getResourceString(java.lang.String key) {
   try {
     return resourceBundle.getString(key);
   } catch (java.util.MissingResourceException e) {
     return key;
   } catch (java.lang.NullPointerException e) {
     return "!" + key + "!";
   }
 }
コード例 #5
0
ファイル: JavaViewer.java プロジェクト: mbigigns/SWTGuitar
 void createShell(org.eclipse.swt.widgets.Display display) {
   shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setText(resources.getString("Window_title"));
   org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout();
   layout.numColumns = 1;
   shell.setLayout(layout);
   shell.addShellListener(
       new org.eclipse.swt.events.ShellAdapter() {
         public void shellClosed(org.eclipse.swt.events.ShellEvent e) {
           lineStyler.disposeColors();
           text.removeLineStyleListener(lineStyler);
         }
       });
 }
コード例 #6
0
ファイル: JavaViewer.java プロジェクト: mbigigns/SWTGuitar
 org.eclipse.swt.widgets.Menu createFileMenu() {
   org.eclipse.swt.widgets.Menu bar = shell.getMenuBar();
   org.eclipse.swt.widgets.Menu menu = new org.eclipse.swt.widgets.Menu(bar);
   org.eclipse.swt.widgets.MenuItem item;
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Open_menuitem"));
   item.setAccelerator(SWT.MOD1 + 'O');
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
           openFile();
         }
       });
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Exit_menuitem"));
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
           menuFileExit();
         }
       });
   return menu;
 }
コード例 #7
0
  /**
   * 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 FormEditor.
   */
  private void initComponents() { // GEN-BEGIN:initComponents
    jPanel1 = new javax.swing.JPanel();
    removeButton = new javax.swing.JButton();
    clearButton = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    historyList = new javax.swing.JList();
    setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints1;
    setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));

    jPanel1.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints2;

    removeButton.setToolTipText(
        java.util.ResourceBundle.getBundle("org/netbeans/modules/jarpackager/Bundle")
            .getString("CTL_RemoveButtonTip"));
    removeButton.setText(
        java.util.ResourceBundle.getBundle("org/netbeans/modules/jarpackager/Bundle")
            .getString("CTL_RemoveButton"));
    removeButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeButtonActionPerformed(evt);
          }
        });

    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.gridx = 1;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.gridwidth = 0;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints2.insets = new java.awt.Insets(5, 0, 0, 8);
    jPanel1.add(removeButton, gridBagConstraints2);

    clearButton.setToolTipText(
        java.util.ResourceBundle.getBundle("org/netbeans/modules/jarpackager/Bundle")
            .getString("CTL_ClearButtonTip"));
    clearButton.setText(
        java.util.ResourceBundle.getBundle("org/netbeans/modules/jarpackager/Bundle")
            .getString("CTL_ClearButton"));
    clearButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            clearButtonActionPerformed(evt);
          }
        });

    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.gridx = 1;
    gridBagConstraints2.gridy = 1;
    gridBagConstraints2.gridwidth = 0;
    gridBagConstraints2.gridheight = 0;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints2.insets = new java.awt.Insets(8, 0, 8, 8);
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
    jPanel1.add(clearButton, gridBagConstraints2);

    historyList.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            historyListValueChanged(evt);
          }
        });

    jScrollPane1.setViewportView(historyList);

    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.gridx = 0;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.gridheight = 0;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints2.insets = new java.awt.Insets(5, 8, 8, 8);
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    jPanel1.add(jScrollPane1, gridBagConstraints2);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.weightx = 1.0;
    gridBagConstraints1.weighty = 1.0;
    add(jPanel1, gridBagConstraints1);
  } // GEN-END:initComponents