Example #1
0
 public void initResources() {
   final java.lang.Class clazz = org.eclipse.swt.examples.paint.PaintExample.class;
   if (resourceBundle != null) {
     try {
       for (int i = 0; i < tools.length; ++i) {
         org.eclipse.swt.examples.paint.Tool tool = tools[i];
         java.lang.String id = tool.group + '.' + tool.name;
         java.io.InputStream sourceStream =
             clazz.getResourceAsStream(getResourceString(id + ".image"));
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(sourceStream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         tool.image = new org.eclipse.swt.graphics.Image(null, source, mask);
         try {
           sourceStream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
       return;
     } catch (java.lang.Throwable t) {
     }
   }
   java.lang.String error =
       resourceBundle != null
           ? getResourceString("error.CouldNotLoadResources")
           : "Unable to load resources";
   freeResources();
   throw new java.lang.RuntimeException(error);
 }
Example #2
0
 public void freeResources() {
   for (int i = 0; i < tools.length; ++i) {
     org.eclipse.swt.examples.paint.Tool tool = tools[i];
     final org.eclipse.swt.graphics.Image image = tool.image;
     if (image != null) {
       image.dispose();
     }
     tool.image = null;
   }
 }
Example #3
0
 private void initActions() {
   for (int i = 0; i < tools.length; ++i) {
     final org.eclipse.swt.examples.paint.Tool tool = tools[i];
     java.lang.String group = tool.group;
     if (group.equals("tool")) {
       tool.action =
           new java.lang.Runnable() {
             public void run() {
               setPaintTool(tool.id);
             }
           };
     } else {
       if (group.equals("fill")) {
         tool.action =
             new java.lang.Runnable() {
               public void run() {
                 setFillType(tool.id);
               }
             };
       } else {
         if (group.equals("linestyle")) {
           tool.action =
               new java.lang.Runnable() {
                 public void run() {
                   setLineStyle(tool.id);
                 }
               };
         } else {
           if (group.equals("options")) {
             tool.action =
                 new java.lang.Runnable() {
                   public void run() {
                     org.eclipse.swt.widgets.FontDialog fontDialog =
                         new org.eclipse.swt.widgets.FontDialog(
                             paintSurface.getShell(), SWT.PRIMARY_MODAL);
                     org.eclipse.swt.graphics.FontData[] fontDatum =
                         toolSettings.commonFont.getFontData();
                     if (fontDatum != null && fontDatum.length > 0) {
                       fontDialog.setFontList(fontDatum);
                     }
                     fontDialog.setText(getResourceString("options.Font.dialog.title"));
                     paintSurface.hideRubberband();
                     org.eclipse.swt.graphics.FontData fontData = fontDialog.open();
                     paintSurface.showRubberband();
                     if (fontData != null) {
                       try {
                         org.eclipse.swt.graphics.Font font =
                             new org.eclipse.swt.graphics.Font(
                                 mainComposite.getDisplay(), fontData);
                         toolSettings.commonFont = font;
                         updateToolSettings();
                       } catch (org.eclipse.swt.SWTException ex) {
                       }
                     }
                   }
                 };
           }
         }
       }
     }
   }
 }