Example usage for org.eclipse.jface.dialogs IMessageProvider ERROR

List of usage examples for org.eclipse.jface.dialogs IMessageProvider ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IMessageProvider ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs IMessageProvider ERROR.

Click Source Link

Document

Constant for an error message (value 3).

Usage

From source file:msi.gama.gui.swt.dialogs.PickWorkspaceDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    setTitle("Choose a Workspace to store your models, settings, etc.");
    setMessage(strMsg);/*from www  .j  a  va 2 s.co  m*/

    try {
        Composite inner = new Composite(parent, SWT.NONE);
        GridLayout l = new GridLayout(5, false);
        // double[][] layout =
        // new double[][] {
        // { 5, LatticeConstants.PREFERRED, 5, 250, 5, LatticeConstants.PREFERRED, 5 },
        // { 5, LatticeConstants.PREFERRED, 5, LatticeConstants.PREFERRED, 40 } };
        inner.setLayout(l);
        inner.setLayoutData(
                new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_END | GridData.GRAB_HORIZONTAL));

        /* Label on the left */
        CLabel label = new CLabel(inner, SWT.NONE);
        label.setText("GAMA Models Workspace");
        label.setLayoutData(new GridData());

        /* Combo in the middle */
        workspacePathCombo = new Combo(inner, SWT.BORDER);
        workspacePathCombo.setLayoutData(new GridData());
        String wsRoot = getNode().get(keyWorkspaceRootDir, "");
        if (wsRoot == null || wsRoot.length() == 0) {
            wsRoot = getWorkspacePathSuggestion();
        }
        workspacePathCombo.setText(wsRoot);

        /* Checkbox below */
        rememberWorkspaceButton = new Button(inner, SWT.CHECK);
        rememberWorkspaceButton.setText("Remember workspace");
        rememberWorkspaceButton.setLayoutData(new GridData());
        rememberWorkspaceButton.setSelection(getNode().getBoolean(keyRememberWorkspace, false));

        String lastUsed = getNode().get(keyLastUsedWorkspaces, "");
        lastUsedWorkspaces = new ArrayList<String>();
        if (lastUsed != null) {
            String[] all = lastUsed.split(splitChar);
            for (String str : all) {
                lastUsedWorkspaces.add(str);
            }
        }
        for (String last : lastUsedWorkspaces) {
            workspacePathCombo.add(last);
        }

        /* Browse button on the right */
        Button browse = new Button(inner, SWT.PUSH);
        browse.setText("Browse...");
        browse.setLayoutData(new GridData());
        browse.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(final Event event) {
                DirectoryDialog dd = new DirectoryDialog(getParentShell());
                dd.setText("Select Workspace Root");
                dd.setMessage(strInfo);
                dd.setFilterPath(workspacePathCombo.getText());
                String pick = dd.open();
                if (pick == null) {
                    if (workspacePathCombo.getText().length() == 0) {
                        setMessage(strError, IMessageProvider.ERROR);
                    }
                } else {
                    setMessage(strMsg);
                    workspacePathCombo.setText(pick);
                }
            }
        });
        return inner;
    } catch (RuntimeException err) {
        err.printStackTrace();
        return null;
    }
}

From source file:msi.gama.gui.swt.dialogs.PickWorkspaceDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String str = workspacePathCombo.getText();
    // GuiUtils.debug("Directory to create " + str);
    if (str.length() == 0) {
        setMessage(strError, IMessageProvider.ERROR);
        return;//ww  w  . ja  v  a 2  s. com
    }

    String ret = checkWorkspaceDirectory(getParentShell(), str, true, true, cloning);
    if (ret != null) {
        setMessage(ret, IMessageProvider.ERROR);
        return;
    }
    // GuiUtils.debug("Directory to create (after check " + str);
    /* Save it so we can show it in combo later */
    lastUsedWorkspaces.remove(str);

    if (!lastUsedWorkspaces.contains(str)) {
        lastUsedWorkspaces.add(0, str);
    }

    /* Deal with the max history */
    if (lastUsedWorkspaces.size() > maxHistory) {
        List<String> remove = new ArrayList<String>();
        for (int i = maxHistory; i < lastUsedWorkspaces.size(); i++) {
            remove.add(lastUsedWorkspaces.get(i));
        }

        lastUsedWorkspaces.removeAll(remove);
    }

    /* Create a string concatenation of all our last used workspaces */
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < lastUsedWorkspaces.size(); i++) {
        buf.append(lastUsedWorkspaces.get(i));
        if (i != lastUsedWorkspaces.size() - 1) {
            buf.append(splitChar);
        }
    }

    /* Save them onto our preferences */
    getNode().putBoolean(keyRememberWorkspace, rememberWorkspaceButton.getSelection());
    getNode().put(keyLastUsedWorkspaces, buf.toString());
    try {
        getNode().flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }

    /* Now create it */
    boolean ok = checkAndCreateWorkspaceRoot(str);
    if (!ok) {
        // GuiUtils.debug("Problem creating " + str);
        setMessage("No workspace could be created at location " + str + ", please check the error log");
        return;
    }

    /* Here we set the location so that we can later fetch it again */
    setSelectedWorkspaceRootLocation(str);

    /* And on our preferences as well */
    // GuiUtils.debug("Writing " + str + " in the preferences");
    if (cloning) {
        String previousLocation = getNode().get(keyWorkspaceRootDir, "");
        File workspaceDirectory = new File(previousLocation);
        File targetDirectory = new File(str);
        try {
            copyFiles(workspaceDirectory, targetDirectory);
        } catch (Exception err) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
                    "There was an error cloning the workspace: " + err.getMessage());
            return;
        }
    }
    getNode().put(keyWorkspaceRootDir, str);
    try {
        getNode().flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }

    super.okPressed();
}

From source file:net.bhl.cdt.paxelerate.ui.commands.GeneratePassengersCommand.java

License:Open Source License

/**
 * This method runs the passenger generation command.
 *///w w w  .  j a  va2s  .com
@Override
protected final void doRun() {
    /* Create separate thread */

    Job job = new Job("Generate Passengers Thread") {
        @Override
        protected IStatus run(final IProgressMonitor monitor) {

            Log.add(this, "Passenger generation started...");

            if (cabin.getDoors().isEmpty()) {
                new Input(WindowType.WARNING,
                        "You can not continue without generating and activating at least one door!",
                        IMessageProvider.ERROR);
                Log.add(this, "Passenger generation aborted");
                return Status.CANCEL_STATUS;
            } else {

                Display.getDefault().syncExec(new Runnable() {
                    @Override
                    public void run() {
                        cabinview = ViewPartHelper.getCabinView();
                        cabinview.unsyncViewer();

                        cabin.getPassengers().clear();
                    }
                });

                for (TravelClass travelclass : cabin.getClasses()) {
                    generatePassengers(travelclass);
                }
                for (Door door : cabin.getDoors()) {
                    door.getWaitingPassengers().clear();
                }

                /* PUBLISH */
                Log.add(this, "Updating GUI...");
                Display.getDefault().syncExec(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            ViewPartHelper.getPropertyView().updateUI(cabin);
                        } catch (NullPointerException e) {
                            Log.add(this, "No property view is visible!");
                            e.printStackTrace();
                        }

                        try {
                            cabinview.syncViewer();
                            cabinview.setCabin(cabin);
                        } catch (NullPointerException e) {
                            Log.add(this, "Cabin View not visible!");
                            e.printStackTrace();
                        }

                        try {
                            new DrawCabinCommand(cabin).doRun();
                        } catch (NullPointerException e) {
                            Log.add(this, "Cabin View could not be refreshed");
                            e.printStackTrace();
                        }
                    }
                });
            }
            /* report finished */
            return Status.OK_STATUS;
        }
    };

    /* report job status to console */
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(final IJobChangeEvent event) {
            if (event.getResult().isOK()) {
                Log.add(this, "Passenger generation completed");
            } else {
                Log.add(this, "Passenger generation failed!");
            }
        }
    });

    /* Start the Job */
    job.schedule();
    try {
        /* schedule job after previous is finished */
        job.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        System.out.println("InterruptedException @ thread " + Thread.currentThread().getName());
        Thread.currentThread().interrupt();
    }
}

From source file:net.bhl.cdt.paxelerate.ui.commands.SimulateBoardingCommand.java

License:Open Source License

/**
 * This method runs the simulate boarding command.
 *///from w  ww.j  a va2 s .c  o  m
@Override
protected final void doRun() {

    // Create separate thread
    Job job = new Job("Simulation Thread") {
        /*
         * (non-Javadoc)
         * 
         * @see
         * org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
         * IProgressMonitor)
         */
        @Override
        protected IStatus run(final IProgressMonitor monitor) {

            Log.add(this, "Initializing new simulation run " + simulationLoop);

            CabinViewPart cabinViewPart = ViewPartHelper.getCabinView();

            /* reset simulation in case of previous existing objects. */
            SimulationHandler.reset();
            /* reset the passenger properties */
            for (Passenger passenger : cabin.getPassengers()) {
                passenger.setIsSeated(false);
                passenger.setBoardingTime(0);
            }
            /* resets seat properties */
            for (Seat seat : ModelHelper.getChildrenByClass(cabin, Seat.class)) {
                seat.setOccupied(false);
            }
            /* sorts passengers according to selected scheme */
            if (cabin.getSimulationSettings().isSortPassengerBetweenLoops()) {
                sortPassengers();
            }

            if (cabin.getPassengers().isEmpty()) {
                Input input = new Input(WindowType.GET_BOOLEAN,
                        "You did not create any passengers. Random passeners are now created.",
                        IMessageProvider.ERROR);
                if (input.getBooleanValue()) {
                    new GeneratePassengersCommand(cabin).doRun();
                    Log.add(this, "PAX created!");
                }
            }

            dimensions = new Vector2D(cabin.getXDimension(), cabin.getYDimension(),
                    cabin.getSimulationSettings().getScale());

            /* initiates a new simulation */
            new SimulationHandler(dimensions, cabin, simulationLoop);

            /* Show WIP simulation view */
            if (!cabin.getSimulationSettings().isSimulateWithoutUI()) {
                runAreaMapWindow();
            }

            // TODO: INSERT PAX LOCATION SUBMIT TO CABINVIEWPART
            // HERE

            /* checks if an agent is in freezing mode */
            while (!SimulationHandler.isSimulationDone()) {
                try {
                    if (agentSleepCheck()) {
                        return Status.CANCEL_STATUS;
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    System.out.println("InterruptedException @ thread " + Thread.currentThread().getName());
                    Thread.currentThread().interrupt();
                }
            }

            /* closes the simulation view after completion */
            if (!cabin.getSimulationSettings().isSimulateWithoutUI()) {
                simulationFrame.dispose();
            }

            /* saves results to results model element */
            SimulationResultLogger results = new SimulationResultLogger();

            results.getSimulationData(cabin, simulationLoop,
                    SimulationHandler.getMasterBoardingTime().getElapsedTime()
                            * cabin.getSimulationSettings().getSimulationSpeedFactor() / 1000,
                    SimulationHandler.getNumberWaymakingSkipped(),
                    SimulationHandler.getNumberWaymakingCompleted());

            /* data export */
            if (cabin.getSimulationSettings().isDataExport()) {
                try {
                    exportResultData();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            /*
             * display the agent path and cost map in the Cabin UI view
             */
            if (cabin.getSimulationSettings().isDisplayMap()) {
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        Image image = cabinViewPart
                                .submitObstacleMap(SimulationHandler.getAreamapHandler().getObstaclemap());
                        cabinViewPart.printObstacleMap(image);
                        cabinViewPart.submitAgents(SimulationHandler.getAgentList());
                    }
                });
            }

            /* Clear the cache! */
            cabinViewPart.clearCache();
            SimulationHandler.reset();

            // PUBLISH
            Log.add(this, "Updating GUI...");
            Display.getDefault().syncExec(new Runnable() {
                @Override
                public void run() {

                }
            });

            /* report finished */
            return Status.OK_STATUS;
        }

    };

    /* report job status to console */
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(final IJobChangeEvent event) {
            if (event.getResult().isOK()) {
                Log.add(this, "Simulation run completed");
            } else {
                Log.add(this, "Simulation run failed!");
            }
        }
    });

    /* Start the Job */
    job.schedule();
    try {
        /* schedule job after previous is finished */
        job.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        System.out.println("InterruptedException @ thread " + Thread.currentThread().getName());
        Thread.currentThread().interrupt();
    }
}

From source file:net.bioclipse.ui.dialogs.PickWorkspaceDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Pick Workspace");
    setMessage(_StrMsg);//from w ww  .j a  v  a 2 s.co m

    try {
        Composite inner = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        inner.setLayout(layout);
        inner.setLayoutData(
                new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_END | GridData.GRAB_HORIZONTAL));

        // label on left
        CLabel label = new CLabel(inner, SWT.NONE);
        label.setText("Workspace Root Path");

        // combo in middle
        _workspacePathCombo = new Combo(inner, SWT.BORDER);
        String wsRoot = _preferences.get(_KeyWorkspaceRootDir, "");
        if (wsRoot == null || wsRoot.length() == 0) {
            wsRoot = getWorkspacePathSuggestion();
        }
        _workspacePathCombo.setText(wsRoot == null ? "" : wsRoot);

        String lastUsed = _preferences.get(_KeyLastUsedWorkspaces, "");
        _lastUsedWorkspaces = new ArrayList<String>();
        if (lastUsed != null) {
            String[] all = lastUsed.split(_SplitChar);
            for (String str : all)
                _lastUsedWorkspaces.add(str);
        }
        for (String last : _lastUsedWorkspaces)
            _workspacePathCombo.add(last);

        // browse button on right
        Button browse = new Button(inner, SWT.PUSH);
        browse.setText("Browse...");
        browse.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                DirectoryDialog dd = new DirectoryDialog(getParentShell());
                dd.setText("Select Workspace Root");
                dd.setMessage(_StrInfo);
                dd.setFilterPath(_workspacePathCombo.getText());
                String pick = dd.open();
                if (pick == null && _workspacePathCombo.getText().length() == 0) {
                    setMessage(_StrError, IMessageProvider.ERROR);
                } else {
                    setMessage(_StrMsg);
                    _workspacePathCombo.setText(pick);
                }
            }

        });

        // checkbox below
        //            _RememberWorkspaceButton = new Button(inner, SWT.CHECK);
        //            _RememberWorkspaceButton.setText("Always start with default workspace");
        //            _RememberWorkspaceButton.setSelection(!_preferences.getBoolean(_KeyRememberWorkspace, false));
        new Label(inner, SWT.NONE);
        new Label(inner, SWT.NONE);

        return inner;
    } catch (Exception err) {
        err.printStackTrace();
        return null;
    }
}

From source file:net.bioclipse.ui.dialogs.PickWorkspaceDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String str = _workspacePathCombo.getText();

    if (str.length() == 0) {
        setMessage(_StrError, IMessageProvider.ERROR);
        return;//from  w  w w .  j  a  v a  2  s  . co m
    }

    String ret = checkWorkspaceDirectory(getParentShell(), str, true, true);
    if (ret != null) {
        setMessage(ret, IMessageProvider.ERROR);
        return;
    }

    // save it so we can show it in combo later
    _lastUsedWorkspaces.remove(str);

    if (!_lastUsedWorkspaces.contains(str)) {
        _lastUsedWorkspaces.add(0, str);
    }

    // deal with the max history
    if (_lastUsedWorkspaces.size() > _MaxHistory) {
        List<String> remove = new ArrayList<String>();
        for (int i = _MaxHistory; i < _lastUsedWorkspaces.size(); i++) {
            remove.add(_lastUsedWorkspaces.get(i));
        }

        _lastUsedWorkspaces.removeAll(remove);
    }

    String wsps = getWorkspacePathSuggestion();

    if (!_lastUsedWorkspaces.contains(wsps)) {
        _lastUsedWorkspaces.add(wsps);
    }

    // create a string concatenation of all our last used workspaces
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < _lastUsedWorkspaces.size(); i++) {
        buf.append(_lastUsedWorkspaces.get(i));
        if (i != _lastUsedWorkspaces.size() - 1) {
            buf.append(_SplitChar);
        }
    }

    // save them onto our preferences
    //        _preferences.putBoolean(_KeyRememberWorkspace, !_RememberWorkspaceButton.getSelection());
    _preferences.putBoolean(_KeyLastUsedWorkspaces, true);
    _preferences.put(_KeyLastUsedWorkspaces, buf.toString());

    // now create it 
    boolean ok = checkAndCreateWorkspaceRoot(str);
    if (!ok) {
        setMessage("The workspace could not be created, please check the error log");
        return;
    }

    // here we set the location so that we can later fetch it again        
    _selectedWorkspaceRootLocation = str;

    // and on our preferences as well
    _preferences.put(_KeyWorkspaceRootDir, str);

    try {
        _preferences.flush();
    } catch (BackingStoreException e) {
        LogUtils.handleException(e, logger, "net.bioclipse.ui");
    }
    super.okPressed();
}

From source file:net.enilink.rap.workbench.auth.LoginDialog.java

License:Open Source License

private void createTextoutputHandler(Composite composite, TextOutputCallback callback) {
    int messageType = callback.getMessageType();
    int dialogMessageType = IMessageProvider.NONE;
    switch (messageType) {
    case TextOutputCallback.INFORMATION:
        dialogMessageType = IMessageProvider.INFORMATION;
        break;// w ww .  j av  a2s . c  o  m
    case TextOutputCallback.WARNING:
        dialogMessageType = IMessageProvider.WARNING;
        break;
    case TextOutputCallback.ERROR:
        dialogMessageType = IMessageProvider.ERROR;
        break;
    }
    setMessage(callback.getMessage(), dialogMessageType);
}

From source file:net.geoprism.oda.driver.ui.editors.ConfigureSSHFormDialog.java

License:Open Source License

private void handleDelete() {
    try {/*from  w  w w. j a v a2s.  c  o  m*/
        SecureKeystoreManager.getInstance().delete();
    } catch (Exception e) {
        // Set the message
        this.setMessage(e.getMessage(), IMessageProvider.ERROR);
    }
}

From source file:net.geoprism.oda.driver.ui.editors.ConfigureSSHFormDialog.java

License:Open Source License

@Override
protected void okPressed() {
    this.setMessage(null);

    if (this.hasRequiredValues()) {
        try {// w w  w  . jav a2  s .  c  om
            String alias = this.alias.getText();

            // Validate the cer
            FileInputStream stream = new FileInputStream(this.location.getText());

            try {
                SecureKeystoreManager.getInstance().addCertificate(stream, alias);
            } finally {
                stream.close();
            }

            super.okPressed();
        } catch (DuplicateCertificateException e) {
            String message = GeoprismPlugin.getResourceString("wizard.ssh.label.duplicatealias"); //$NON-NLS-1$
            this.setMessage(message, IMessageProvider.ERROR);
        } catch (FileNotFoundException e) {
            String message = GeoprismPlugin.getResourceString("wizard.ssh.label.filenotfound"); //$NON-NLS-1$
            this.setMessage(message, IMessageProvider.ERROR);
        } catch (Exception e) {
            // Set the message
            this.setMessage(e.getMessage(), IMessageProvider.ERROR);
        }
    } else {
        String message = GeoprismPlugin.getResourceString("wizard.ssh.label.validation"); //$NON-NLS-1$
        this.setMessage(message, IMessageProvider.ERROR);
    }
}

From source file:net.geoprism.oda.driver.ui.profile.GeodashboardSelectionPageHelper.java

License:Open Source License

/**
 * This method should be called in the following occations: 1. The value of inputed URL, username is changed 2. When
 * the control is created.//  w  w  w.j  a  v a2s  . com
 */
private void updateTestButton() {
    // Geodashboard Url cannot be blank
    if (this.isBlank(this.url)) {
        setMessage(EMPTY_URL, IMessageProvider.ERROR);
        testButton.setEnabled(false);
    } else if (this.isBlank(this.userName)) {
        setMessage(EMPTY_USERNAME, IMessageProvider.ERROR);
        testButton.setEnabled(false);
    } else if (this.isBlank(this.password)) {
        setMessage(EMPTY_PASSWORD, IMessageProvider.ERROR);
        testButton.setEnabled(false);
    } else {
        setMessage(defaultMessage);

        if (!testButton.isEnabled()) {
            testButton.setEnabled(true);
        }
    }
}