private void onSelectDelete(final Object selectedPart) {

    if (selectedPart instanceof PartMP) {

      final MP selectedPartMp = ((PartMP) selectedPart).partMp;

      if (MessageDialog.openConfirm(
          _display.getActiveShell(),
          Messages.Dialog_OfflineArea_ConfirmDelete_Title,
          NLS.bind(
              Messages.Dialog_OfflineArea_ConfirmDeletePart_Message, selectedPartMp.getName()))) {

        deleteOfflineImages(selectedPartMp);
      }

    } else {

      if (MessageDialog.openConfirm(
          _display.getActiveShell(),
          Messages.Dialog_OfflineArea_ConfirmDelete_Title,
          Messages.Dialog_OfflineArea_ConfirmDeleteAll_Message)) {

        deleteOfflineImages(null);
      }
    }
  }
  /** {@inheritDoc} */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    Display current = Display.getCurrent();
    if (current == null) {
      current = Display.getDefault();
    }
    Shell shell = current.getActiveShell();
    if (shell != null) {

      CustomizePropertyViewWizard wizard = new CustomizePropertyViewWizard();
      WizardDialog wd =
          new WizardDialog(shell, wizard) {

            /** {@inheritDoc} */
            @Override
            protected void configureShell(Shell newShell) {
              super.configureShell(newShell);
              newShell.setText("Customize Property View");
            }
          };
      wd.create();
      // wd.getShell().setSize(640, 600);
      wd.open();
    } else {
      Activator.log.error("impossible to find a shell to open the message dialog", null);
    }

    return null;
  }
 public Playlist loadPlaylist() {
   Playlist newPlaylist = null;
   val shell = display.getActiveShell();
   val dialog = new FileChooser(shell, SWT.OPEN);
   val audioFileExtensions = new AudioFileReader().formatExtensions();
   val playlistFileExtensions = new PlaylistReader().formatExtensions();
   dialog.setFilterExtensions(
       new String[] {
         audioFileExtensions + ";" + playlistFileExtensions,
         audioFileExtensions,
         playlistFileExtensions
       });
   dialog.setFilterNames(
       new String[] {
         "All Supported Files",
         new AudioFileReader().completeFormatName(),
         new PlaylistReader().completeFormatName()
       });
   val selectedFileName = dialog.open();
   if (selectedFileName != null) {
     val selectedFile = new File(selectedFileName);
     if (new AudioFileReader().canHandle(selectedFile)) {
       newPlaylist = new AudioFileReader().read(selectedFile);
     } else if (new PlaylistReader().canHandle(selectedFile)) {
       newPlaylist = new PlaylistReader().read(selectedFile);
     }
   }
   return newPlaylist;
 }
Exemple #4
0
  /**
   * The launching point
   *
   * <p>In development, pass the following on the JVM command line:
   * <tt>-Djava.util.logging.config.file=config/logging.properties</tt>
   *
   * <p>On Mac, add the following (otherwise SWT won't work): <tt>-XstartOnFirstThread</tt>
   */
  public static void main(String... args) {
    long startTime = System.currentTimeMillis();

    initSystemProperties();
    Display display;

    try {
      // this defines the Window class and app name on the Mac
      Display.setAppName(Version.NAME);
      display = Display.getDefault();
      LOG.finer("SWT initialized after " + (System.currentTimeMillis() - startTime));
    } catch (UnsatisfiedLinkError e) {
      JOptionPane.showMessageDialog(
          null,
          "Failed to load native code. Probably you are using a binary built for wrong OS or CPU - try downloading both 32-bit and 64-bit binaries");
      return;
    }

    // initialize Labels instance
    Labels.initialize(Locale.getDefault());
    // initialize Config instance
    Config globalConfig = Config.getConfig();
    LOG.finer("Labels and Config initialized after " + (System.currentTimeMillis() - startTime));

    ComponentRegistry componentRegistry = new ComponentRegistry();
    LOG.finer("ComponentRegistry initialized after " + (System.currentTimeMillis() - startTime));

    processCommandLine(args, componentRegistry);

    // create the main window using dependency injection
    MainWindow mainWindow = componentRegistry.getMainWindow();
    LOG.fine("Startup time: " + (System.currentTimeMillis() - startTime));

    while (!mainWindow.isDisposed()) {
      try {
        if (!display.readAndDispatch()) display.sleep();
      } catch (Throwable e) {
        if (e instanceof SWTException && e.getCause() != null) e = e.getCause();

        // display a nice error message
        String localizedMessage = getLocalizedMessage(e);
        Shell parent = display.getActiveShell();
        showMessage(
            parent != null ? parent : mainWindow.getShell(),
            e instanceof UserErrorException ? SWT.ICON_WARNING : SWT.ICON_ERROR,
            Labels.getLabel(e instanceof UserErrorException ? "text.userError" : "text.error"),
            localizedMessage);
      }
    }

    // save config on exit
    globalConfig.store();

    // dispose the native objects
    display.dispose();
  }
 public void savePlaylist(final Playlist playlist) {
   if (!playlist.isEmpty()) {
     val shell = display.getActiveShell();
     val dialog = new FileChooser(shell, SWT.SAVE);
     dialog.setFilterExtensions(new String[] {new PlaylistWriter().formatExtensions()});
     dialog.setFilterNames(new String[] {new PlaylistWriter().completeFormatName()});
     val selectedFileName = dialog.open();
     if (selectedFileName != null) {
       val selectedFile = new File(selectedFileName);
       if (new PlaylistWriter().canHandle(selectedFile)) {
         new PlaylistWriter().write(selectedFile, playlist);
       }
     }
   }
 }
Exemple #6
0
  /**
   * Gets the shell to use.
   *
   * @return The Shell.
   */
  public static Shell getShell() {
    Display display = Display.getDefault();
    Shell shell = display.getActiveShell();
    if (shell != null) {
      return shell;
    }

    // should only be necessary for headed eclimd
    Shell[] shells = display.getShells();
    if (shells.length > 0) {
      return shells[0];
    }

    // hopefully shouldn't happen
    return null;
  }
  /**
   * Create contents of the form.
   *
   * @param managedForm
   */
  @Override
  protected void createFormContent(IManagedForm managedForm) {
    FormToolkit toolkit = managedForm.getToolkit();
    ScrolledForm form = managedForm.getForm();
    form.setText("Empty FormPage");
    Composite body = form.getBody();
    toolkit.decorateFormHeading(form.getForm());
    toolkit.paintBordersFor(body);
    managedForm.getForm().getBody().setLayout(new GridLayout(1, false));

    display = Display.getCurrent();
    shell = display.getActiveShell();

    createButtonPanel(body).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    createScrollingPreview(body).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    updateJob();
  }
  @Override
  public Object start(IApplicationContext applicationContext) throws Exception {
    // set the display name before the Display is
    // created to ensure the app name is used in any
    // platform menus, etc. See
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329456#c14
    IProduct product = Platform.getProduct();
    if (product != null && product.getName() != null) {
      Display.setAppName(product.getName());
    }
    Display display = getApplicationDisplay();
    Location instanceLocation = null;
    try {
      E4Workbench workbench = createE4Workbench(applicationContext, display);

      instanceLocation = (Location) workbench.getContext().get(E4Workbench.INSTANCE_LOCATION);
      Shell shell = display.getActiveShell();
      if (shell == null) {
        shell = new Shell();
        // place it off so it's not visible
        shell.setLocation(0, 10000);
      }
      if (!checkInstanceLocation(instanceLocation, shell, workbench.getContext())) return EXIT_OK;

      // Create and run the UI (if any)
      workbench.createAndRunUI(workbench.getApplication());

      saveModel();
      workbench.close();

      if (workbench.isRestart()) {
        return EXIT_RESTART;
      }

      return EXIT_OK;
    } finally {
      if (display != null) display.dispose();
      if (instanceLocation != null) instanceLocation.release();
    }
  }
  @SuppressWarnings("unchecked")
  protected void setUp() throws Exception {
    super.setUp();
    Display display = Display.getCurrent();
    shell = new Shell(display.getActiveShell());
    shell.setLayout(new FillLayout());

    SimpleFeatureType ft =
        DataUtilities.createType("type", "name:String,id:int"); // $NON-NLS-1$//$NON-NLS-2$
    feature1 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature1", 1}, "feature1"); // $NON-NLS-1$ //$NON-NLS-2$
    feature2 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature2", 2}, "feature2"); // $NON-NLS-1$ //$NON-NLS-2$
    feature3 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature3", 3}, "feature3"); // $NON-NLS-1$ //$NON-NLS-2$
    feature4 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature4", 4}, "feature4"); // $NON-NLS-1$ //$NON-NLS-2$

    features = FeatureCollections.newCollection();

    features.add(feature1);
    features.add(feature2);
    features.add(feature3);
    features.add(feature4);

    UiPlugin.getDefault().getPreferenceStore().setValue(FeatureTableControl.CACHING_WARNING, true);

    table =
        new FeatureTableControl(
            new StaticProvider<IProgressMonitor>(new NullProgressMonitor()), shell, features);
    shell.open();
    shell.redraw();

    while (Display.getCurrent().readAndDispatch()) ;
  }
 @Override
 public void run() {
   Display display = Display.getCurrent();
   Shell shell = display.getActiveShell();
   Cursor cursor = shell == null ? null : shell.getCursor();
   try {
     if (shell != null) {
       shell.setCursor(display.getSystemCursor(SWT.CURSOR_WAIT));
     }
     setEnabled(false);
     if (installButton != null) {
       installButton.setEnabled(false);
     }
     DiscoveryUi.install(discoveryViewer.getInstallableConnectors(), SoftwarePage.this);
   } finally {
     if (shell != null) {
       shell.setCursor(cursor);
     }
     setEnabled(true);
     if (installButton != null) {
       installButton.setEnabled(true);
     }
   }
 }
Exemple #11
0
 public <T extends Object> void revealElement(
     final T element, final EntryCall<? super T> entryCall, final IEditorPart editor) {
   final Runnable _function =
       () -> {
         try {
           Scene _scene = this.canvas.getScene();
           double _width = _scene.getWidth();
           boolean _equals = (_width == 0);
           if (_equals) {
             Scene _scene_1 = this.canvas.getScene();
             ReadOnlyDoubleProperty _widthProperty = _scene_1.widthProperty();
             final ChangeListener<Number> _function_1 =
                 new ChangeListener<Number>() {
                   @Override
                   public void changed(
                       final ObservableValue<? extends Number> p, final Number o, final Number n) {
                     Scene _scene = FXDiagramTab.this.canvas.getScene();
                     ReadOnlyDoubleProperty _widthProperty = _scene.widthProperty();
                     _widthProperty.removeListener(this);
                     FXDiagramTab.this.<T>revealElement(element, entryCall, editor);
                   }
                 };
             _widthProperty.addListener(_function_1);
           } else {
             Scene _scene_2 = this.canvas.getScene();
             double _height = _scene_2.getHeight();
             boolean _equals_1 = (_height == 0);
             if (_equals_1) {
               Scene _scene_3 = this.canvas.getScene();
               ReadOnlyDoubleProperty _heightProperty = _scene_3.heightProperty();
               final ChangeListener<Number> _function_2 =
                   new ChangeListener<Number>() {
                     @Override
                     public void changed(
                         final ObservableValue<? extends Number> p,
                         final Number o,
                         final Number n) {
                       Scene _scene = FXDiagramTab.this.canvas.getScene();
                       ReadOnlyDoubleProperty _heightProperty = _scene.heightProperty();
                       _heightProperty.removeListener(this);
                       FXDiagramTab.this.<T>revealElement(element, entryCall, editor);
                     }
                   };
               _heightProperty.addListener(_function_2);
             } else {
               this.<T>doRevealElement(element, entryCall, editor);
             }
           }
         } catch (final Throwable _t) {
           if (_t instanceof Exception) {
             final Exception exc = (Exception) _t;
             exc.printStackTrace();
             Display _current = Display.getCurrent();
             Shell _activeShell = _current.getActiveShell();
             StringConcatenation _builder = new StringConcatenation();
             _builder.append("Error showing element in FXDiagram:");
             _builder.newLine();
             String _message = exc.getMessage();
             _builder.append(_message, "");
             _builder.newLineIfNotEmpty();
             _builder.append("See log for details.");
             _builder.newLine();
             MessageDialog.openError(_activeShell, "Error", _builder.toString());
           } else {
             throw Exceptions.sneakyThrow(_t);
           }
         }
       };
   Platform.runLater(_function);
 }