Search in sources :

Example 1 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Display method test_ConstructorLorg_eclipse_swt_graphics_DeviceData.

@Test
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceData() {
    Display disp;
    disp = new Display(null);
    disp.dispose();
    disp = new Display(new DeviceData());
    disp.dispose();
}
Also used : DeviceData(org.eclipse.swt.graphics.DeviceData) Display(org.eclipse.swt.widgets.Display) Test(org.junit.Test)

Example 2 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project pentaho-kettle by pentaho.

the class Sleak method refreshDifference.

void refreshDifference() {
    Display display = canvas.getDisplay();
    DeviceData info = display.getDeviceData();
    if (!info.tracking) {
        Shell shell = canvas.getShell();
        MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        dialog.setText(shell.getText());
        dialog.setMessage("Warning: Device is not tracking resource allocation");
        dialog.open();
    }
    Object[] newObjects = info.objects;
    Error[] newErrors = info.errors;
    Object[] diffObjects = new Object[newObjects.length];
    Error[] diffErrors = new Error[newErrors.length];
    int count = 0;
    for (int i = 0; i < newObjects.length; i++) {
        int index = 0;
        while (index < oldObjects.length) {
            if (newObjects[i] == oldObjects[index]) {
                break;
            }
            index++;
        }
        if (index == oldObjects.length) {
            diffObjects[count] = newObjects[i];
            diffErrors[count] = newErrors[i];
            count++;
        }
    }
    objects = new Object[count];
    errors = new Error[count];
    System.arraycopy(diffObjects, 0, objects, 0, count);
    System.arraycopy(diffErrors, 0, errors, 0, count);
    list.removeAll();
    text.setText("");
    canvas.redraw();
    for (int i = 0; i < objects.length; i++) {
        list.add(objects[i].toString());
    }
    refreshLabel();
    layout();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DeviceData(org.eclipse.swt.graphics.DeviceData) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project eclipse.platform.swt by eclipse.

the class Bug221240_AWTJVMCrash method main.

public static void main(String[] args) {
    DeviceData data = new DeviceData();
    data.debug = true;
    display = new Display(data);
    Device.DEBUG = true;
    if (args.length > 0) {
        url = args[0];
    }
    System.setProperty("sun.awt.xembedserver", "true");
    SwingUtilities.invokeLater(() -> new Bug221240_AWTJVMCrash().setVisible(true));
    while (true) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : DeviceData(org.eclipse.swt.graphics.DeviceData) Display(org.eclipse.swt.widgets.Display)

Example 4 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_graphics_DeviceData method test_Constructor.

@Test
public void test_Constructor() {
    DeviceData data = new DeviceData();
    data.debug = true;
    data.tracking = true;
}
Also used : DeviceData(org.eclipse.swt.graphics.DeviceData) Test(org.junit.Test)

Example 5 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project pentaho-kettle by pentaho.

the class Spoon method main.

/**
 * This is the main procedure for Spoon.
 *
 * @param a
 *     Arguments are available in the "Get System Info" step.
 */
public static void main(String[] a) throws KettleException {
    boolean doConsoleRedirect = !Boolean.getBoolean("Spoon.Console.Redirect.Disabled");
    if (doConsoleRedirect) {
        try {
            Path parent = Paths.get(System.getProperty("user.dir") + File.separator + "logs");
            Files.createDirectories(parent);
            Files.deleteIfExists(Paths.get(parent.toString(), "spoon.log"));
            Path path = Files.createFile(Paths.get(parent.toString(), "spoon.log"));
            System.setProperty("LOG_PATH", path.toString());
            final FileOutputStream fos = new FileOutputStream(path.toFile());
            System.setOut(new PrintStream(new TeeOutputStream(originalSystemOut, fos)));
            System.setErr(new PrintStream(new TeeOutputStream(originalSystemErr, fos)));
            KettleLogStore.OriginalSystemOut = System.out;
            KettleLogStore.OriginalSystemErr = System.err;
        } catch (Throwable ignored) {
        // ignored
        }
    }
    ExecutorService executor = Executors.newCachedThreadPool();
    Future<KettleException> pluginRegistryFuture = executor.submit(new Callable<KettleException>() {

        @Override
        public KettleException call() throws Exception {
            registerUIPluginObjectTypes();
            KettleClientEnvironment.getInstance().setClient(KettleClientEnvironment.ClientType.SPOON);
            try {
                KettleEnvironment.init();
            } catch (KettleException e) {
                return e;
            }
            return null;
        }
    });
    try {
        OsHelper.setAppName();
        // Bootstrap Kettle
        // 
        Display display;
        if (System.getProperties().containsKey("SLEAK")) {
            DeviceData data = new DeviceData();
            data.tracking = true;
            display = new Display(data);
            Sleak sleak = new Sleak();
            Shell sleakShell = new Shell(display);
            sleakShell.setText("S-Leak");
            org.eclipse.swt.graphics.Point size = sleakShell.getSize();
            sleakShell.setSize(size.x / 2, size.y / 2);
            sleak.create(sleakShell);
            sleakShell.open();
        } else {
            display = new Display();
        }
        // Note: this needs to be done before the look and feel is set
        OsHelper.initOsHandlers(display);
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        // The core plugin types don't know about UI classes. Add them in now
        // before the PluginRegistry is inited.
        splash = new Splash(display);
        List<String> args = new ArrayList<>(Arrays.asList(a));
        CommandLineOption[] commandLineOptions = getCommandLineArgs(args);
        KettleException registryException = pluginRegistryFuture.get();
        if (registryException != null) {
            throw registryException;
        }
        PropsUI.init(display, Props.TYPE_PROPERTIES_SPOON);
        KettleLogStore.init(PropsUI.getInstance().getMaxNrLinesInLog(), PropsUI.getInstance().getMaxLogLineTimeoutMinutes());
        initLogging(commandLineOptions);
        // remember...
        staticSpoon = new Spoon();
        staticSpoon.commandLineOptions = commandLineOptions;
        // pull the startup perspective id from the command line options and hand it to Spoon
        String pId;
        StringBuilder perspectiveIdBuff = Spoon.getCommandLineOption(commandLineOptions, "perspective").getArgument();
        pId = perspectiveIdBuff.toString();
        if (!Utils.isEmpty(pId)) {
            Spoon.staticSpoon.startupPerspective = pId;
        }
        SpoonFactory.setSpoonInstance(staticSpoon);
        staticSpoon.setDestroy(true);
        GUIFactory.setThreadDialogs(new ThreadGuiResources());
        staticSpoon.setArguments(args.toArray(new String[args.size()]));
        staticSpoon.start();
    } catch (Throwable t) {
        // avoid calls to Messages i18n method getString() in this block
        // We do this to (hopefully) also catch Out of Memory Exceptions
        // 
        t.printStackTrace();
        if (staticSpoon != null) {
            log.logError("Fatal error : " + Const.NVL(t.toString(), Const.NVL(t.getMessage(), "Unknown error")));
            log.logError(Const.getStackTracker(t));
        }
    }
    // Kill all remaining things in this VM!
    System.exit(0);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TeeOutputStream(org.apache.commons.io.output.TeeOutputStream) ArrayList(java.util.ArrayList) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) CommandLineOption(org.pentaho.di.pan.CommandLineOption) Shell(org.eclipse.swt.widgets.Shell) DeviceData(org.eclipse.swt.graphics.DeviceData) Path(java.nio.file.Path) PrintStream(java.io.PrintStream) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) ThreadGuiResources(org.pentaho.di.ui.util.ThreadGuiResources) FileOutputStream(java.io.FileOutputStream) ExecutorService(java.util.concurrent.ExecutorService) Splash(org.pentaho.di.ui.core.dialog.Splash) Display(org.eclipse.swt.widgets.Display)

Aggregations

DeviceData (org.eclipse.swt.graphics.DeviceData)7 Display (org.eclipse.swt.widgets.Display)5 Point (org.eclipse.swt.graphics.Point)3 Shell (org.eclipse.swt.widgets.Shell)3 MessageBox (org.eclipse.swt.widgets.MessageBox)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 MalformedURLException (java.net.MalformedURLException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleFileException (org.pentaho.di.core.exception.KettleFileException)1 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)1