예제 #1
0
 void createStyledText() {
   text =
       new org.eclipse.swt.custom.StyledText(
           shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   org.eclipse.swt.layout.GridData spec = new org.eclipse.swt.layout.GridData();
   spec.horizontalAlignment = GridData.FILL;
   spec.grabExcessHorizontalSpace = true;
   spec.verticalAlignment = GridData.FILL;
   spec.grabExcessVerticalSpace = true;
   text.setLayoutData(spec);
   text.addLineStyleListener(lineStyler);
   text.setEditable(false);
   org.eclipse.swt.graphics.Color bg = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
   text.setBackground(bg);
 }
예제 #2
0
 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);
 }