コード例 #1
0
  public void setActive(boolean b) {
    // the function is called 3 times when leaving this perspective this odd
    // logic is here so it doesn't reload the data when leaving this perspective
    if (b) {
      if (!this.isActive) {
        System.out.println("create eclResults setActive");
        if (System.getProperties().getProperty("resultsFile") != null
            && !System.getProperties().getProperty("resultsFile").equals("")) {
          String xmlFile = System.getProperties().getProperty("resultsFile");
          ArrayList<String> resultFiles = parseData("resultsFile");
          for (int i = 0; i < resultFiles.size(); i++) {
            openResultsXML(resultFiles.get(i));
          }
          // openResultsXML(xmlFile);
          System.getProperties().setProperty("resultsFile", "");
        }
        int len = folder.getItemCount();
        folder.setSelection(len - 1);
        this.isActive = true;
      } else {
        this.isActive = false;
      }

    } else {
      System.out.println("create eclResults setActive -- deactivate");
    }
  }
コード例 #2
0
  public ArrayList parseData(String propName) {
    ArrayList<String> files = new ArrayList();
    String saltData = "";
    try {
      if (System.getProperty(propName) != null) {
        saltData = System.getProperty(propName);
      }
      StringTokenizer fileTokens = new StringTokenizer(saltData, ",");
      while (fileTokens.hasMoreElements()) {
        String file = fileTokens.nextToken();

        if (file != null && !file.equals("null") && !file.equals("")) {
          System.out.println("Built tab from list" + file);

          files.add(file);
        }
      }
      saltData = "";
    } catch (Exception e) {
      System.out.println("Failed to open files ");
    }
    // just incase it was a signle node
    if (saltData != null && !saltData.equals("null") && !saltData.equals("")) {
      System.out.println("Built tab from single " + saltData);
      files.add(saltData);
    }
    System.setProperty(propName, "");
    return files;
  }
コード例 #3
0
  public void openProfiles_old() {
    String saltData = "";
    try {
      if (System.getProperty("saltData") != null) {
        saltData = System.getProperty("saltData");
      }
      StringTokenizer fileTokens = new StringTokenizer(saltData, ",");
      while (fileTokens.hasMoreElements()) {
        String file = fileTokens.nextToken();

        if (file != null && !file.equals("null") && !file.equals("")) {
          System.out.println("Built tab from list" + file);
          buildProfileTab(file);
        }
      }
      saltData = "";
    } catch (Exception e) {
      System.out.println("Failed to open files ");
    }
    // just incase it was a signle node
    if (saltData != null && !saltData.equals("null") && !saltData.equals("")) {
      System.out.println("Built tab from single " + saltData);
      buildProfileTab(saltData);
    }
    System.setProperty("saltData", "");
  }
コード例 #4
0
  /*
   * EnumFormatEtc([in] dwDirection, [out] ppenumFormatetc)
   * Ownership of ppenumFormatetc transfers from callee to caller so reference count on ppenumFormatetc
   * must be incremented before returning.  Caller is responsible for releasing ppenumFormatetc.
   */
  private int EnumFormatEtc(int dwDirection, long /*int*/ ppenumFormatetc) {
    // only allow getting of data - SetData is not currently supported
    if (dwDirection == COM.DATADIR_SET) return COM.E_NOTIMPL;

    // what types have been registered?
    TransferData[] allowedDataTypes = new TransferData[0];
    for (int i = 0; i < transferAgents.length; i++) {
      Transfer transferAgent = transferAgents[i];
      if (transferAgent != null) {
        TransferData[] formats = transferAgent.getSupportedTypes();
        TransferData[] newAllowedDataTypes =
            new TransferData[allowedDataTypes.length + formats.length];
        System.arraycopy(allowedDataTypes, 0, newAllowedDataTypes, 0, allowedDataTypes.length);
        System.arraycopy(formats, 0, newAllowedDataTypes, allowedDataTypes.length, formats.length);
        allowedDataTypes = newAllowedDataTypes;
      }
    }

    OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC();
    enumFORMATETC.AddRef();

    FORMATETC[] formats = new FORMATETC[allowedDataTypes.length];
    for (int i = 0; i < formats.length; i++) {
      formats[i] = allowedDataTypes[i].formatetc;
    }
    enumFORMATETC.setFormats(formats);

    OS.MoveMemory(ppenumFormatetc, new long /*int*/[] {enumFORMATETC.getAddress()}, OS.PTR_SIZEOF);
    return COM.S_OK;
  }
コード例 #5
0
 void createItem(TabItem item, int index) {
   long /*int*/ list = OS.gtk_container_get_children(handle);
   int itemCount = 0;
   if (list != 0) {
     itemCount = OS.g_list_length(list);
     OS.g_list_free(list);
   }
   if (!(0 <= index && index <= itemCount)) error(SWT.ERROR_INVALID_RANGE);
   if (itemCount == items.length) {
     TabItem[] newItems = new TabItem[items.length + 4];
     System.arraycopy(items, 0, newItems, 0, items.length);
     items = newItems;
   }
   long /*int*/ boxHandle = gtk_box_new(OS.GTK_ORIENTATION_HORIZONTAL, false, 0);
   if (boxHandle == 0) error(SWT.ERROR_NO_HANDLES);
   long /*int*/ labelHandle = OS.gtk_label_new_with_mnemonic(null);
   if (labelHandle == 0) error(SWT.ERROR_NO_HANDLES);
   long /*int*/ imageHandle = OS.gtk_image_new();
   if (imageHandle == 0) error(SWT.ERROR_NO_HANDLES);
   OS.gtk_container_add(boxHandle, imageHandle);
   OS.gtk_container_add(boxHandle, labelHandle);
   long /*int*/ pageHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0);
   if (pageHandle == 0) error(SWT.ERROR_NO_HANDLES);
   if (OS.GTK3) {
     OS.gtk_widget_override_background_color(pageHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
     long /*int*/ region = OS.gdk_region_new();
     OS.gtk_widget_input_shape_combine_region(pageHandle, region);
     OS.gdk_region_destroy(region);
   }
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_insert_page(handle, pageHandle, boxHandle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_widget_show(boxHandle);
   OS.gtk_widget_show(labelHandle);
   OS.gtk_widget_show(pageHandle);
   item.state |= HANDLE;
   item.handle = boxHandle;
   item.labelHandle = labelHandle;
   item.imageHandle = imageHandle;
   item.pageHandle = pageHandle;
   System.arraycopy(items, index, items, index + 1, itemCount++ - index);
   items[index] = item;
   if ((state & FOREGROUND) != 0) {
     item.setForegroundColor(getForegroundColor());
   }
   if ((state & FONT) != 0) {
     item.setFontDescription(getFontDescription());
   }
   if (itemCount == 1) {
     OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
     OS.gtk_notebook_set_current_page(handle, 0);
     OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
     Event event = new Event();
     event.item = items[0];
     sendSelectionEvent(SWT.Selection, event, false);
     // the widget could be destroyed at this point
   }
 }
コード例 #6
0
ファイル: IME.java プロジェクト: rbatterman/eclipseWorkspace
 /**
  * Returns the styles for the ranges.
  *
  * <p>The ranges array contains start and end pairs. Each pair refers to the corresponding style
  * in the styles array. For example, the pair that starts at ranges[n] and ends at ranges[n+1]
  * uses the style at styles[n/2].
  *
  * @return the ranges for the styles
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @see IME#getRanges
  */
 public TextStyle[] getStyles() {
   checkWidget();
   if (styles == null) return new TextStyle[0];
   TextStyle[] result = new TextStyle[styles.length];
   System.arraycopy(styles, 0, result, 0, styles.length);
   return result;
 }
コード例 #7
0
  public void openUrl(String url) {
    String os = System.getProperty("os.name");
    Runtime runtime = Runtime.getRuntime();
    try {
      // Block for Windows Platform
      if (os.startsWith("Windows")) {
        String cmd = "rundll32 url.dll,FileProtocolHandler " + url;
        Process p = runtime.exec(cmd);

        // Block for Mac OS
      } else if (os.startsWith("Mac OS")) {
        Class fileMgr = Class.forName("com.apple.eio.FileManager");
        Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
        openURL.invoke(null, new Object[] {url});

        // Block for UNIX Platform
      } else {
        String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"};
        String browser = null;
        for (int count = 0; count < browsers.length && browser == null; count++)
          if (runtime.exec(new String[] {"which", browsers[count]}).waitFor() == 0)
            browser = browsers[count];

        if (browser == null) throw new Exception("Could not find web browser");
        else runtime.exec(new String[] {browser, url});
      }
    } catch (Exception x) {
      System.err.println("Exception occurd while invoking Browser!");
      x.printStackTrace();
    }
  }
コード例 #8
0
 Rectangle[] getRectangles(int linkIndex) {
   int lineCount = layout.getLineCount();
   Rectangle[] rects = new Rectangle[lineCount];
   int[] lineOffsets = layout.getLineOffsets();
   Point point = offsets[linkIndex];
   int lineStart = 1;
   while (point.x > lineOffsets[lineStart]) lineStart++;
   int lineEnd = 1;
   while (point.y > lineOffsets[lineEnd]) lineEnd++;
   int index = 0;
   if (lineStart == lineEnd) {
     rects[index++] = layout.getBounds(point.x, point.y);
   } else {
     rects[index++] = layout.getBounds(point.x, lineOffsets[lineStart] - 1);
     rects[index++] = layout.getBounds(lineOffsets[lineEnd - 1], point.y);
     if (lineEnd - lineStart > 1) {
       for (int i = lineStart; i < lineEnd - 1; i++) {
         rects[index++] = layout.getLineBounds(i);
       }
     }
   }
   if (rects.length != index) {
     Rectangle[] tmp = new Rectangle[index];
     System.arraycopy(rects, 0, tmp, 0, index);
     rects = tmp;
   }
   return rects;
 }
コード例 #9
0
 /**
  * Unload the given image's data into the given byte stream using the given compression strategy.
  * Answer the number of bytes written. Method modified to use the passed data if it is not null.
  */
 int unloadData(ImageData image, byte[] data, OutputStream out, int comp) {
   int totalSize = 0;
   try {
     if (comp == 0) return unloadDataNoCompression(image, data, out);
     int bpl = (image.width * image.depth + 7) / 8;
     int bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
     int imageBpl = image.bytesPerLine;
     // Compression can actually take twice as much space, in worst case
     byte[] buf = new byte[bmpBpl * 2];
     int srcOffset = imageBpl * (image.height - 1); // Start at last line
     if (data == null) data = image.data;
     totalSize = 0;
     byte[] buf2 = new byte[32768];
     int buf2Offset = 0;
     for (int y = image.height - 1; y >= 0; y--) {
       int lineSize = compress(comp, data, srcOffset, bpl, buf, y == 0);
       if (buf2Offset + lineSize > buf2.length) {
         out.write(buf2, 0, buf2Offset);
         buf2Offset = 0;
       }
       System.arraycopy(buf, 0, buf2, buf2Offset, lineSize);
       buf2Offset += lineSize;
       totalSize += lineSize;
       srcOffset -= imageBpl;
     }
     if (buf2Offset > 0) out.write(buf2, 0, buf2Offset);
   } catch (IOException e) {
     SWT.error(SWT.ERROR_IO, e);
   }
   return totalSize;
 }
コード例 #10
0
 void destroyItem(TabItem item) {
   int index = 0;
   int itemCount = getItemCount();
   while (index < itemCount) {
     if (items[index] == item) break;
     index++;
   }
   if (index == itemCount) error(SWT.ERROR_ITEM_NOT_REMOVED);
   int oldIndex = OS.gtk_notebook_get_current_page(handle);
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_remove_page(handle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   System.arraycopy(items, index + 1, items, index, --itemCount - index);
   items[itemCount] = null;
   if (index == oldIndex) {
     int newIndex = OS.gtk_notebook_get_current_page(handle);
     if (newIndex != -1) {
       Control control = items[newIndex].getControl();
       if (control != null && !control.isDisposed()) {
         control.setBounds(getClientArea());
         control.setVisible(true);
       }
       Event event = new Event();
       event.item = items[newIndex];
       sendSelectionEvent(SWT.Selection, event, true);
       // the widget could be destroyed at this point
     }
   }
 }
コード例 #11
0
 /**
  * Returns an array of <code>TabItem</code>s which are the items in the receiver.
  *
  * <p>Note: This is not the actual structure used by the receiver to maintain its list of items,
  * so modifying the array will not affect the receiver.
  *
  * @return the items in the receiver
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public TabItem[] getItems() {
   checkWidget();
   int count = getItemCount();
   TabItem[] result = new TabItem[count];
   System.arraycopy(items, 0, result, 0, count);
   return result;
 }
コード例 #12
0
 /**
  * We have just read the Comment extension identifier from the input stream. Read in the rest of
  * the comment and return it. GIF comment blocks are variable size.
  */
 byte[] readCommentExtension() {
   try {
     byte[] comment = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldComment = comment;
       comment = new byte[oldComment.length + size];
       System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
       System.arraycopy(block, 0, comment, oldComment.length, size);
       size = inputStream.read();
     }
     return comment;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
コード例 #13
0
 static char[] mbcsToWcs(String codePage, byte[] buffer) {
   char[] chars = new char[buffer.length];
   int charCount =
       OS.MultiByteToWideChar(
           OS.CP_ACP, OS.MB_PRECOMPOSED, buffer, buffer.length, chars, chars.length);
   if (charCount == chars.length) return chars;
   char[] result = new char[charCount];
   System.arraycopy(chars, 0, result, 0, charCount);
   return result;
 }
コード例 #14
0
ファイル: Device.java プロジェクト: andreyvit/yoursway-swt
 void new_Object(Object object) {
   synchronized (trackingLock) {
     for (int i = 0; i < objects.length; i++) {
       if (objects[i] == null) {
         objects[i] = object;
         errors[i] = new Error();
         return;
       }
     }
     Object[] newObjects = new Object[objects.length + 128];
     System.arraycopy(objects, 0, newObjects, 0, objects.length);
     newObjects[objects.length] = object;
     objects = newObjects;
     Error[] newErrors = new Error[errors.length + 128];
     System.arraycopy(errors, 0, newErrors, 0, errors.length);
     newErrors[errors.length] = new Error();
     errors = newErrors;
   }
 }
コード例 #15
0
 private void exitMenuItemWidgetSelected(SelectionEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
   getShell().dispose();
   System.exit(1);
 }
コード例 #16
0
 /**
  * We have just read the Application extension identifier from the input stream. Read in the rest
  * of the extension, look for and store 'number of repeats', and return the data.
  */
 byte[] readApplicationExtension() {
   try {
     // Read block data.
     int blockSize = inputStream.read();
     byte[] blockData = new byte[blockSize];
     inputStream.read(blockData);
     // Read application data.
     byte[] data = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldData = data;
       data = new byte[oldData.length + size];
       System.arraycopy(oldData, 0, data, 0, oldData.length);
       System.arraycopy(block, 0, data, oldData.length, size);
       size = inputStream.read();
     }
     // Look for the NETSCAPE 'repeat count' field for an animated GIF.
     boolean netscape =
         blockSize > 7
             && blockData[0] == 'N'
             && blockData[1] == 'E'
             && blockData[2] == 'T'
             && blockData[3] == 'S'
             && blockData[4] == 'C'
             && blockData[5] == 'A'
             && blockData[6] == 'P'
             && blockData[7] == 'E';
     boolean authentic =
         blockSize > 10 && blockData[8] == '2' && blockData[9] == '.' && blockData[10] == '0';
     if (netscape && authentic && data[0] == 01) { // $NON-NLS-1$ //$NON-NLS-2$
       repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8);
       loader.repeatCount = repeatCount;
     }
     return data;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
コード例 #17
0
ファイル: FindTool.java プロジェクト: URMC/i2b2
  public List getCategories() {
    List concepts = null;
    try {
      //		GetReturnType request = new GetReturnType();
      //		request.setType("limited");

      GetCategoriesType request = new GetCategoriesType();
      request.setType("core");
      request.setHiddens(false);
      request.setSynonyms(false);

      OntologyResponseMessage msg = new OntologyResponseMessage();
      StatusType procStatus = null;
      while (procStatus == null || !procStatus.getType().equals("DONE")) {
        String response = OntServiceDriver.getCategories(request, "FIND");
        procStatus = msg.processResult(response);
        //				if  other error codes
        //				TABLE_ACCESS_DENIED and USER_INVALID, DATABASE ERROR
        if (procStatus.getType().equals("ERROR")) {
          System.setProperty("errorMessage", procStatus.getValue());
          return concepts;
        }
        procStatus.setType("DONE");
      }
      ConceptsType allConcepts = msg.doReadConcepts();
      if (allConcepts != null) concepts = allConcepts.getConcept();

    } catch (AxisFault e) {
      log.error(e.getMessage());
      System.setProperty("errorMessage", "Ontology cell unavailable");
    } catch (I2B2Exception e) {
      log.error(e.getMessage());
      System.setProperty("errorMessage", e.getMessage());
    } catch (Exception e) {
      log.error(e.getMessage());
      System.setProperty("errorMessage", "Remote server unavailable");
    }

    return concepts;
  }
コード例 #18
0
ファイル: Path.java プロジェクト: andreyvit/yoursway-swt
 /**
  * Returns a device independent representation of the receiver.
  *
  * @return the PathData for the receiver
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
  *     </ul>
  *
  * @see PathData
  */
 public PathData getPathData() {
   if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
   int count = handle.elementCount();
   int pointCount = 0, typeCount = 0;
   byte[] types = new byte[count];
   float[] pointArray = new float[count * 6];
   int points = OS.malloc(3 * NSPoint.sizeof);
   if (points == 0) SWT.error(SWT.ERROR_NO_HANDLES);
   NSPoint pt = new NSPoint();
   for (int i = 0; i < count; i++) {
     int element = handle.elementAtIndex_associatedPoints_(i, points);
     switch (element) {
       case OS.NSMoveToBezierPathElement:
         types[typeCount++] = SWT.PATH_MOVE_TO;
         OS.memmove(pt, points, NSPoint.sizeof);
         pointArray[pointCount++] = (int) pt.x;
         pointArray[pointCount++] = (int) pt.y;
         break;
       case OS.NSLineToBezierPathElement:
         types[typeCount++] = SWT.PATH_LINE_TO;
         OS.memmove(pt, points, NSPoint.sizeof);
         pointArray[pointCount++] = (int) pt.x;
         pointArray[pointCount++] = (int) pt.y;
         break;
       case OS.NSCurveToBezierPathElement:
         types[typeCount++] = SWT.PATH_CUBIC_TO;
         OS.memmove(pt, points, NSPoint.sizeof);
         pointArray[pointCount++] = (int) pt.x;
         pointArray[pointCount++] = (int) pt.y;
         OS.memmove(pt, points + NSPoint.sizeof, NSPoint.sizeof);
         pointArray[pointCount++] = (int) pt.x;
         pointArray[pointCount++] = (int) pt.y;
         OS.memmove(pt, points + NSPoint.sizeof + NSPoint.sizeof, NSPoint.sizeof);
         pointArray[pointCount++] = (int) pt.x;
         pointArray[pointCount++] = (int) pt.y;
         break;
       case OS.NSClosePathBezierPathElement:
         types[typeCount++] = SWT.PATH_CLOSE;
         break;
     }
   }
   OS.free(points);
   if (pointCount != pointArray.length) {
     float[] temp = new float[pointCount];
     System.arraycopy(pointArray, 0, temp, 0, pointCount);
     pointArray = temp;
   }
   PathData data = new PathData();
   data.types = types;
   data.points = pointArray;
   return data;
 }
コード例 #19
0
 static synchronized void loadLibrary() {
   if (loaded) return;
   loaded = true;
   /*
    * Note that the jawt library is loaded explicitly
    * because it cannot be found by the library loader.
    * All exceptions are caught because the library may
    * have been loaded already.
    */
   try {
     System.loadLibrary("jawt");
   } catch (Throwable e) {
   }
   Library.loadLibrary("swt-awt");
 }
コード例 #20
0
 /**
  * We have just read the PlainText extension identifier from the input stream. Read in the plain
  * text info and text, and return the text. GIF plain text blocks are variable size.
  */
 byte[] readPlainTextExtension() {
   try {
     // Read size of block = 0x0C.
     inputStream.read();
     // Read the text information (x, y, width, height, colors).
     byte[] info = new byte[12];
     inputStream.read(info);
     // Read the text.
     byte[] text = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldText = text;
       text = new byte[oldText.length + size];
       System.arraycopy(oldText, 0, text, 0, oldText.length);
       System.arraycopy(block, 0, text, oldText.length, size);
       size = inputStream.read();
     }
     return text;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
コード例 #21
0
 /*public*/ void setTabItemList(ToolItem[] tabList) {
   checkWidget();
   if (tabList != null) {
     for (int i = 0; i < tabList.length; i++) {
       ToolItem item = tabList[i];
       if (item == null) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.parent != this) error(SWT.ERROR_INVALID_PARENT);
     }
     ToolItem[] newList = new ToolItem[tabList.length];
     System.arraycopy(tabList, 0, newList, 0, tabList.length);
     tabList = newList;
   }
   this.tabItemList = tabList;
 }
コード例 #22
0
 @Override
 Widget[] computeTabList() {
   ToolItem[] items = _getItems();
   if (tabItemList == null) {
     int i = 0;
     while (i < items.length && items[i].control == null) i++;
     if (i == items.length) return super.computeTabList();
   }
   Widget result[] = {};
   if (!isTabGroup() || !isEnabled() || !isVisible()) return result;
   ToolItem[] list = tabList != null ? _getTabItemList() : items;
   for (int i = 0; i < list.length; i++) {
     ToolItem child = list[i];
     Widget[] childList = child.computeTabList();
     if (childList.length != 0) {
       Widget[] newResult = new Widget[result.length + childList.length];
       System.arraycopy(result, 0, newResult, 0, result.length);
       System.arraycopy(childList, 0, newResult, result.length, childList.length);
       result = newResult;
     }
   }
   if (result.length == 0) result = new Widget[] {this};
   return result;
 }
コード例 #23
0
 static String getProfilePath() {
   String baseDir;
   /* Use the character encoding for the default locale */
   TCHAR buffer = new TCHAR(0, OS.MAX_PATH);
   if (OS.SHGetFolderPath(0, OS.CSIDL_APPDATA, 0, OS.SHGFP_TYPE_CURRENT, buffer) == OS.S_OK) {
     baseDir = buffer.toString(0, buffer.strlen());
   } else {
     baseDir = System.getProperty("user.home"); // $NON-NLS-1$
   }
   return baseDir
       + Mozilla.SEPARATOR_OS
       + "Mozilla"
       + Mozilla.SEPARATOR_OS
       + "eclipse"; //$NON-NLS-1$ //$NON-NLS-2$
 }
コード例 #24
0
  private String buildFileDialog() {

    // file field
    FileDialog fd = new FileDialog(parentShell, SWT.SAVE);

    fd.setText("Open");
    fd.setFilterPath("C:/");
    String[] filterExt = {"*.xml", "*.csv", "*.*"};
    fd.setFilterExtensions(filterExt);
    String selected = fd.open();
    if (!(fd.getFileName()).equalsIgnoreCase("")) {
      return fd.getFilterPath() + System.getProperty("file.separator") + fd.getFileName();
    } else {
      return "";
    }
  }
コード例 #25
0
 /**
  * Returns an array of listeners who will be notified when a drag and drop operation is in
  * progress, by sending it one of the messages defined in the <code>DragSourceListener</code>
  * interface.
  *
  * @return the listeners who will be notified when a drag and drop operation is in progress
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @see DragSourceListener
  * @see #addDragListener
  * @see #removeDragListener
  * @see DragSourceEvent
  * @since 3.4
  */
 public DragSourceListener[] getDragListeners() {
   Listener[] listeners = getListeners(DND.DragStart);
   int length = listeners.length;
   DragSourceListener[] dragListeners = new DragSourceListener[length];
   int count = 0;
   for (int i = 0; i < length; i++) {
     Listener listener = listeners[i];
     if (listener instanceof DNDListener) {
       dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener();
       count++;
     }
   }
   if (count == length) return dragListeners;
   DragSourceListener[] result = new DragSourceListener[count];
   System.arraycopy(dragListeners, 0, result, 0, count);
   return result;
 }
コード例 #26
0
 static byte[] wcsToMbcs(String codePage, String string, boolean terminate) {
   int byteCount;
   char[] chars = new char[string.length()];
   string.getChars(0, chars.length, chars, 0);
   byte[] bytes = new byte[byteCount = chars.length * 2 + (terminate ? 1 : 0)];
   byteCount =
       OS.WideCharToMultiByte(OS.CP_ACP, 0, chars, chars.length, bytes, byteCount, null, null);
   if (terminate) {
     byteCount++;
   } else {
     if (bytes.length != byteCount) {
       byte[] result = new byte[byteCount];
       System.arraycopy(bytes, 0, result, 0, byteCount);
       bytes = result;
     }
   }
   return bytes;
 }
コード例 #27
0
 private String[] splitString(String text) {
   String[] lines = new String[1];
   int start = 0, pos;
   do {
     pos = text.indexOf('\n', start);
     if (pos == -1) {
       lines[lines.length - 1] = text.substring(start);
     } else {
       boolean crlf = (pos > 0) && (text.charAt(pos - 1) == '\r');
       lines[lines.length - 1] = text.substring(start, pos - (crlf ? 1 : 0));
       start = pos + 1;
       String[] newLines = new String[lines.length + 1];
       System.arraycopy(lines, 0, newLines, 0, lines.length);
       lines = newLines;
     }
   } while (pos != -1);
   return lines;
 }
コード例 #28
0
 /**
  * Prepare the given image's data for unloading into a byte stream using no compression strategy.
  * Answer the number of bytes written. Method modified to use the passed data if it is not null.
  */
 int unloadDataNoCompression(ImageData image, byte[] data, OutputStream out) {
   int bmpBpl = 0;
   try {
     int bpl = (image.width * image.depth + 7) / 8;
     bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
     int linesPerBuf = 32678 / bmpBpl;
     byte[] buf = new byte[linesPerBuf * bmpBpl];
     if (data == null) data = image.data;
     int imageBpl = image.bytesPerLine;
     int dataIndex = imageBpl * (image.height - 1); // Start at last line
     if (image.depth == 16) {
       for (int y = 0; y < image.height; y += linesPerBuf) {
         int count = image.height - y;
         if (linesPerBuf < count) count = linesPerBuf;
         int bufOffset = 0;
         for (int i = 0; i < count; i++) {
           for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
             buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
             buf[bufOffset + wIndex] = data[dataIndex + wIndex];
           }
           bufOffset += bmpBpl;
           dataIndex -= imageBpl;
         }
         out.write(buf, 0, bufOffset);
       }
     } else {
       for (int y = 0; y < image.height; y += linesPerBuf) {
         int tmp = image.height - y;
         int count = tmp < linesPerBuf ? tmp : linesPerBuf;
         int bufOffset = 0;
         for (int i = 0; i < count; i++) {
           System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
           bufOffset += bmpBpl;
           dataIndex -= imageBpl;
         }
         out.write(buf, 0, bufOffset);
       }
     }
   } catch (IOException e) {
     SWT.error(SWT.ERROR_IO, e);
   }
   return bmpBpl * image.height;
 }
コード例 #29
0
 public static boolean test() {
   int fail = 0;
   String url;
   String pluginPath = System.getProperty("PLUGIN_PATH");
   if (verbose) System.out.println("PLUGIN_PATH <" + pluginPath + ">");
   if (pluginPath == null)
     url = Browser5.class.getClassLoader().getResource("browser5.html").toString();
   else url = pluginPath + "/data/browser5.html";
   String[] urls = {url};
   for (int i = 0; i < urls.length; i++) {
     // TEST1 TEMPORARILY NOT RUN FOR MOZILLA
     if (!isMozilla) {
       boolean result = test1(urls[i]);
       if (verbose) System.out.print(result ? "." : "E");
       if (!result) fail++;
     }
   }
   return fail == 0;
 }
コード例 #30
0
ファイル: Dialog.java プロジェクト: abego/java2script
 static void addDialog(Dialog dialog) {
   if (activeDialogs == null) {
     activeDialogs = new Dialog[3];
   }
   int length = activeDialogs.length;
   for (int i = 0; i < length; i++) {
     if (activeDialogs[i] == dialog) {
       return;
     }
   }
   for (int i = 0; i < length; i++) {
     if (activeDialogs[i] == null) {
       activeDialogs[i] = dialog;
       return;
     }
   }
   Dialog[] newActiveDialogs = new Dialog[length + 3];
   System.arraycopy(activeDialogs, 0, newActiveDialogs, 0, length);
   activeDialogs[length] = dialog;
 }