ProgressMonitor with UI

Eclipse 2010. 8. 11. 18:03

IRunnableWithProgress runnable = new IRunnableWithProgress()
{

 public void run(IProgressMonitor progressMonitor)
 {

  ...
  progressMonitor.beginTask("Generating DDL(s)", count);

  ...

  }

  progressMonitor.done();
 }
};

progressMonitor.run(false, true, runnable); <- fork should be false

* void org.eclipse.jface.dialogs.ProgressMonitorDialog.run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException

If fork is set to false, the runnable will run in the UI thread and it is the runnable's responsibility to call Display.readAndDispatch() to ensure UI responsiveness.

Posted by zennken
public static String getCellString4Clipboard(Grid aGrid)
{
StringBuffer result = new StringBuffer();
int prevRow, curRow; // For new-line inserting
int i, size;
Point[] selCells = aGrid.getCellSelection();
size = selCells.length;
// For the first selected cell
i = 0;
result.append(aGrid.getItem(selCells[i].y).getText(selCells[i].x));
prevRow = selCells[i].y;
// Remains
for(i = 1; i < size; i++)
{
curRow = selCells[i].y;
if (prevRow != curRow)
result.append(System.getProperty("line.separator"));
else 
result.append("\t");

result.append(aGrid.getItem(selCells[i].y).getText(selCells[i].x));

prevRow = curRow;
}
return result.toString();
}
Posted by zennken
From: http://www.cpuug.org/index.php?topic=132.0

#!/bin/sh
#=====================================================
#
# newdf - An improved human readable display of the HP-UX
# display filesystems command.
#
# Version 1.1
# Author: Scott Buffington
#
# Change History:
# Scott Buffington - 10/30/2006 - Created
# Scott Buffington - 03/18/2008 - Fixed Linewrap issue.
#
# License: GPL, http://www.gnu.org/copyleft/gpl.html
#
#=====================================================

awkscript="/tmp/newdf.$$"

trap "rm -f $awkscript" EXIT

cat << 'EOF' > $awkscript
function showunit(size)
{ mb = size / 1024; prettymb=(int(mb * 100)) / 100;
  gb = mb / 1024; prettygb=(int(gb * 100)) / 100;

  if ( substr(size,1,1) !~ "[0-9]" ||
       substr(size,2,1) !~ "[0-9]" ) { return size }
  else if ( mb < 1) { return size "K" }
  else if ( gb < 1) { return prettymb "M" }
  else              { return prettygb "G" }
}

BEGIN {
  printf "%-27s %8s %8s %8s %8s  %-s\n",
        "Filesystem", "Size", "Used", "Avail", "Capacity", "Mounted"
}

!/Filesystem/ {

  size=showunit($2);
  used=showunit($3);
  avail=showunit($4);

  printf "%-27s %8s %8s %8s %8s  %-s\n",
        $1, size, used, avail, $5, $6
}
EOF

df -Pk | grep -v "libc_psr.so.1" | sed -e :a -e '$!N;s/\n / /;ta' -e 'P;D' | awk -f $awkscript

Posted by zennken

zennken

달력