Beispiel #1
0
 public void run(final IToolRunnableControllerAdapter tools, final IProgressMonitor monitor)
     throws InterruptedException, CoreException {
   final AtomicInteger width = new AtomicInteger(-1);
   UIAccess.getDisplay()
       .syncExec(
           new Runnable() {
             public void run() {
               final TextConsoleViewer outputViewer = getOutputViewer();
               if (UIAccess.isOkToUse(outputViewer)) {
                 final GC gc = new GC(Display.getCurrent());
                 gc.setFont(outputViewer.getTextWidget().getFont());
                 final FontMetrics fontMetrics = gc.getFontMetrics();
                 final int charWidth = fontMetrics.getAverageCharWidth();
                 final int clientWidth = outputViewer.getTextWidget().getClientArea().width;
                 width.set(clientWidth / charWidth);
                 gc.dispose();
               }
             }
           });
   int setWidth = width.get();
   if (setWidth >= 0) {
     if (setWidth < 10) {
       setWidth = 10;
     }
     tools.submitToConsole(
         "options(width = " + setWidth + ")", monitor); // $NON-NLS-1$ //$NON-NLS-2$
   }
 }
Beispiel #2
0
 @Override
 public void revealEndOfDocument() {
   final Display display = UIAccess.getDisplay();
   display.asyncExec(
       new Runnable() {
         public void run() {
           final StyledText textWidget = getTextWidget();
           if (!UIAccess.isOkToUse(textWidget)) {
             return;
           }
           final AbstractDocument document = (AbstractDocument) getDocument();
           final long timestamp = document.getModificationStamp();
           final int lineCount = textWidget.getLineCount();
           final int lineToShow =
               ((lineCount > 1
                       && textWidget.getCharCount() == textWidget.getOffsetAtLine(lineCount - 1))
                   ? (lineCount - 1)
                   : (lineCount));
           final int visiblePixel = textWidget.getClientArea().height;
           final int linePixel = textWidget.getLineHeight();
           final int topPixel = (linePixel * (lineToShow - 1)) - visiblePixel + 2;
           if (topPixel + linePixel > 0) {
             if (topPixel < 0) {
               textWidget.setTopPixel(topPixel + linePixel);
             } else {
               final int[] move =
                   new int[] {
                     topPixel,
                     topPixel + linePixel - 2,
                     topPixel + linePixel - 1,
                     topPixel + linePixel
                   };
               textWidget.setTopPixel(move[0]);
               final int[] state = new int[] {1};
               display.timerExec(
                   75,
                   new Runnable() {
                     public void run() {
                       int i = state[0];
                       if (!UIAccess.isOkToUse(textWidget)
                           || timestamp
                               != ((IDocumentExtension4) getDocument()).getModificationStamp()
                           || move[i - 1] != textWidget.getTopPixel()) {
                         return;
                       }
                       textWidget.setTopPixel(move[i++]);
                       if (i < move.length) {
                         state[0] = i;
                         display.timerExec(25, this);
                       }
                     }
                   });
             }
           }
         }
       });
 }
 public EclipseRGraphicFactory() {
   fDefaultDisplay = UIAccess.getDisplay();
   fFontManager = new FontManager(fDefaultDisplay);
   fColorManager = new ColorManager(fDefaultDisplay);
   fDefaultDisplay.asyncExec(
       new Runnable() {
         public void run() {
           fDefaultDisplay.disposeExec(
               new Runnable() {
                 public void run() {
                   fFontManager.dispose();
                   fColorManager.dispose();
                 }
               });
         }
       });
 }
Beispiel #4
0
 public IStatus handle(
     final String id,
     final IToolRunnableControllerAdapter tools,
     final Map<String, Object> data,
     final IProgressMonitor monitor) {
   final String message;
   {
     String s =
         ToolEventHandlerUtil.getCheckedData(data, LOGIN_MESSAGE_DATA_KEY, String.class, false);
     if (s == null) {
       final IProgressInfo progressInfo = tools.getController().getProgressInfo();
       s = NLS.bind("Select file (in {0}):", progressInfo.getLabel());
     }
     message = s;
   }
   final Boolean newFile =
       ToolEventHandlerUtil.getCheckedData(
           data, "newResource", Boolean.class, true); // $NON-NLS-1$
   final ToolProcess tool = tools.getController().getProcess();
   final AtomicReference<IFileStore> file = new AtomicReference<IFileStore>();
   final Runnable runnable =
       new Runnable() {
         public void run() {
           final SelectFileDialog dialog =
               new SelectFileDialog(
                   UIAccess.getActiveWorkbenchShell(true), tool, message, newFile.booleanValue());
           dialog.setBlockOnOpen(true);
           if (dialog.open() == Dialog.OK) {
             file.set(dialog.getResource());
           }
         }
       };
   UIAccess.getDisplay().syncExec(runnable);
   if (file.get() == null) {
     return Status.CANCEL_STATUS;
   }
   data.put("filename", file.get().toURI().toString()); // $NON-NLS-1$
   return Status.OK_STATUS;
 }
Beispiel #5
0
  protected void execOpenFile(final HttpServletRequest req, final HttpServletResponse resp)
      throws IOException {
    final String path = req.getParameter("path"); // $NON-NLS-1$

    if (path == null) {
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    try {
      final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new URI(path));
      UIAccess.getDisplay()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  openExtern(fileStore);
                }
              });
    } catch (final URISyntaxException e) {
      resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      return;
    }
  }