Пример #1
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    Dialog dialog = new LicenseDialog(HandlerUtil.getActiveShell(event));
    dialog.open();

    return null;
  }
  public void widgetSelected(SelectionEvent e) {
    Object source = e.getSource();

    if (source == newSiteButton) {
      final Shell shell = getShell();
      Dialog dlg =
          new FTPPropertyDialogProvider()
              .createPropertyDialog(
                  new IShellProvider() {

                    public Shell getShell() {
                      return shell;
                    }
                  });
      if (dlg instanceof IPropertyDialog) {
        ((IPropertyDialog) dlg)
            .setPropertySource(
                CoreIOPlugin.getConnectionPointManager().getType(IBaseFTPConnectionPoint.TYPE_FTP));
      }
      int ret = dlg.open();

      if (ret == Window.OK) {
        populateTable();

        if (dlg instanceof IPropertyDialog) {
          checkItem((IConnectionPoint) ((IPropertyDialog) dlg).getPropertySource());
        }
      }
    } else if (source == syncOnFinish) {
      setSynchronize(syncOnFinish.getSelection());
    }
  }
Пример #3
0
 /*
  * Called when the user selects the action to localize this dialog.
  * This will bring up a dialog that can be used to localize this dialog.
  */
 protected void localizationPressed() {
   Dialog dialog =
       new LocalizeDialog(
           getShell(),
           TranslatableNLS.bind(Messages.LocalizeDialog_Title_DialogPart, getShell().getText()),
           languageSet,
           Activator.getDefault().getMenuTextSet());
   dialog.open();
 }
    @Override
    public void run() {
      Dialog dialog =
          newConfirmationDialog(
              "Terminate selected environments?",
              "Are you sure you want to terminate the selected AWS Elastic Beanstalk environments?");
      if (dialog.open() != 0) return;

      Job terminateEnvironmentsJob =
          new Job("Terminating Environments") {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
              String endpoint =
                  RegionUtils.getCurrentRegion()
                      .getServiceEndpoints()
                      .get(ServiceAbbreviations.BEANSTALK);
              AWSElasticBeanstalk beanstalk =
                  AwsToolkitCore.getClientFactory().getElasticBeanstalkClientByEndpoint(endpoint);

              List<Exception> errors = new ArrayList<Exception>();
              for (EnvironmentDescription env : environments) {
                try {
                  beanstalk.terminateEnvironment(
                      new TerminateEnvironmentRequest().withEnvironmentId(env.getEnvironmentId()));
                } catch (Exception e) {
                  errors.add(e);
                }
              }

              IStatus status = Status.OK_STATUS;
              if (errors.size() > 0) {
                status =
                    new MultiStatus(
                        AwsToolkitCore.PLUGIN_ID, 0, "Unable to terminate environments", null);
                for (Exception error : errors) {
                  ((MultiStatus) status)
                      .add(
                          new Status(
                              Status.ERROR,
                              AwsToolkitCore.PLUGIN_ID,
                              "Unable to terminate environment",
                              error));
                }
              }

              ContentProviderRegistry.refreshAllContentProviders();

              return status;
            }
          };

      terminateEnvironmentsJob.schedule();
    }
    public void run() {
      Dialog dialog =
          new Dialog(display.getActiveShell()) {
            protected void createButtonsForButtonBar(Composite parent) {
              createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
              createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
            }

            protected Control createDialogArea(Composite parent) {
              Control control = super.createDialogArea(parent);
              // TODO how to display longer message inside Dialog?
              control.getShell().setText("Confirm");
              return control;
            }
          };

      returnValue = dialog.open();
    }
Пример #6
0
 /**
  * The provided {@link Dialog} is opened and the result is returned via the provided {@link
  * ECPDialogExecutor}. This method searches for a DialogWrapper which will wrap the code in order
  * to allow opening JFace dialogs in RAP.
  *
  * @param dialog the JFace Dialog to open
  * @param callBack the {@link ECPDialogExecutor} called to handle the result
  */
 public static void openDialog(Dialog dialog, ECPDialogExecutor callBack) {
   DialogWrapper wrapper = null;
   final IConfigurationElement[] controls =
       Platform.getExtensionRegistry()
           .getConfigurationElementsFor(
               "org.eclipse.emf.ecp.edit.swt.dialogWrapper"); //$NON-NLS-1$
   for (final IConfigurationElement e : controls) {
     try {
       wrapper = (DialogWrapper) e.createExecutableExtension("class"); // $NON-NLS-1$
       break;
     } catch (final CoreException e1) {
       Activator.logException(e1);
     }
   }
   if (wrapper == null) {
     callBack.handleResult(dialog.open());
     return;
   }
   wrapper.openDialog(dialog, callBack);
 }
Пример #7
0
  public void open(Shell parentShell, final int selectionType) {

    resourcesList = new ArrayList<String>();

    String[] retrieveSavedJars = OmsBoxPlugin.getDefault().retrieveSavedJars();
    for (String jarPath : retrieveSavedJars) {
      resourcesList.add(jarPath);
    }

    dialog =
        new Dialog(parentShell) {

          @Override
          protected void configureShell(Shell shell) {
            super.configureShell(shell);
            shell.setText(""); // $NON-NLS-1$
          }

          @Override
          protected Point getInitialSize() {
            return new Point(640, 450);
          }

          @Override
          protected Control createDialogArea(Composite parent) {
            Composite parentPanel = (Composite) super.createDialogArea(parent);

            final TabFolder tabFolder = new TabFolder(parentPanel, SWT.BORDER);
            GridData tabFolderGD = new GridData(SWT.FILL, SWT.FILL, true, true);
            tabFolder.setLayoutData(tabFolderGD);

            TabItem librariesTabItem = new TabItem(tabFolder, SWT.NULL);
            librariesTabItem.setText("Modules Libraries ");
            Composite librariesPanel = new Composite(tabFolder, SWT.NONE);
            librariesPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            librariesPanel.setLayout(new GridLayout(2, true));
            createTableViewer(librariesPanel);
            createAddRemoveButtons(librariesPanel);
            librariesTabItem.setControl(librariesPanel);

            TabItem grassTabItem = new TabItem(tabFolder, SWT.NULL);
            grassTabItem.setText("Grass settings");
            Composite grassPanel = new Composite(tabFolder, SWT.NONE);
            grassPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            grassPanel.setLayout(new GridLayout(1, false));
            grassTabItem.setControl(grassPanel);

            createGrassPanel(grassPanel);

            return parentPanel;
          }

          @Override
          protected void buttonPressed(int buttonId) {
            if (buttonId == OK) {
              OmsBoxPlugin.getDefault().saveJars(resourcesList);
              cancelPressed = false;
            } else {
              cancelPressed = true;
            }
            super.buttonPressed(buttonId);
          }
        };
    dialog.setBlockOnOpen(true);
    dialog.open();
  }
  /** @generated */
  protected void performDirectEditRequest(Request request) {
    final Request theRequest = request;
    if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
      directEditionMode = getDirectEditionType();
    }
    switch (directEditionMode) {
      case IDirectEdition.NO_DIRECT_EDITION:
        // no direct edition mode => does nothing
        return;
      case IDirectEdition.EXTENDED_DIRECT_EDITOR:
        updateExtendedEditorConfiguration();
        if (configuration == null || configuration.getLanguage() == null) {
          performDefaultDirectEditorEdit(theRequest);
        } else {
          configuration.preEditAction(resolveSemanticElement());
          Dialog dialog = null;
          if (configuration instanceof IPopupEditorConfiguration) {
            IPopupEditorHelper helper =
                ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
            helper.showEditor();
            return;
          } else if (configuration instanceof IAdvancedEditorConfiguration) {
            dialog =
                ((IAdvancedEditorConfiguration) configuration)
                    .createDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        resolveSemanticElement(),
                        configuration.getTextToEdit(resolveSemanticElement()));
          } else if (configuration instanceof IDirectEditorConfiguration) {
            dialog =
                new ExtendedDirectEditionDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    resolveSemanticElement(),
                    ((IDirectEditorConfiguration) configuration)
                        .getTextToEdit(resolveSemanticElement()),
                    (IDirectEditorConfiguration) configuration);
          } else {
            return;
          }
          final Dialog finalDialog = dialog;
          if (Window.OK == dialog.open()) {
            TransactionalEditingDomain domain = getEditingDomain();
            RecordingCommand command =
                new RecordingCommand(domain, "Edit Label") {

                  @Override
                  protected void doExecute() {
                    configuration.postEditAction(
                        resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
                  }
                };
            domain.getCommandStack().execute(command);
          }
        }
        break;
      case IDirectEdition.DEFAULT_DIRECT_EDITOR:
        // initialize the direct edit manager
        try {
          getEditingDomain()
              .runExclusive(
                  new Runnable() {

                    public void run() {
                      if (isActive() && isEditable()) {
                        if (theRequest
                                .getExtendedData()
                                .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR)
                            instanceof Character) {
                          Character initialChar =
                              (Character)
                                  theRequest
                                      .getExtendedData()
                                      .get(
                                          RequestConstants
                                              .REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
                          performDirectEdit(initialChar.charValue());
                        } else if ((theRequest instanceof DirectEditRequest)
                            && (getEditText().equals(getLabelText()))) {
                          DirectEditRequest editRequest = (DirectEditRequest) theRequest;
                          performDirectEdit(editRequest.getLocation());
                        } else {
                          performDirectEdit();
                        }
                      }
                    }
                  });
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        break;
      default:
        break;
    }
  }
Пример #9
0
  /** @generated */
  protected void performDirectEditRequest(Request request) {
    final Request theRequest = request;
    if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
      directEditionMode = getDirectEditionType();
    }
    switch (directEditionMode) {
      case IDirectEdition.NO_DIRECT_EDITION:
        // no direct edition mode => does nothing
        return;
      case IDirectEdition.EXTENDED_DIRECT_EDITOR:
        updateExtendedEditorConfiguration();
        if (configuration == null || configuration.getLanguage() == null) {
          // Create default edit manager
          setManager(
              new MultilineLabelDirectEditManager(
                  this,
                  MultilineLabelDirectEditManager.getTextCellEditorClass(this),
                  UMLEditPartFactory.getTextCellEditorLocator(this)));
          performDefaultDirectEditorEdit(theRequest);
        } else {
          configuration.preEditAction(resolveSemanticElement());
          Dialog dialog = null;
          if (configuration instanceof ICustomDirectEditorConfiguration) {
            setManager(
                ((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
            initializeDirectEditManager(theRequest);
            return;
          } else if (configuration instanceof IPopupEditorConfiguration) {
            IPopupEditorHelper helper =
                ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
            helper.showEditor();
            return;
          } else if (configuration instanceof IAdvancedEditorConfiguration) {
            dialog =
                ((IAdvancedEditorConfiguration) configuration)
                    .createDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        resolveSemanticElement(),
                        configuration.getTextToEdit(resolveSemanticElement()));
          } else if (configuration instanceof IDirectEditorConfiguration) {
            dialog =
                new ExtendedDirectEditionDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    resolveSemanticElement(),
                    ((IDirectEditorConfiguration) configuration)
                        .getTextToEdit(resolveSemanticElement()),
                    (IDirectEditorConfiguration) configuration);
          } else {
            return;
          }
          final Dialog finalDialog = dialog;
          if (Window.OK == dialog.open()) {
            TransactionalEditingDomain domain = getEditingDomain();
            RecordingCommand command =
                new RecordingCommand(domain, "Edit Label") {

                  @Override
                  protected void doExecute() {
                    configuration.postEditAction(
                        resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
                  }
                };
            domain.getCommandStack().execute(command);
          }
        }
        break;
      case IDirectEdition.DEFAULT_DIRECT_EDITOR:
        initializeDirectEditManager(theRequest);
        break;
      default:
        break;
    }
  }
Пример #10
0
  /**
   * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   * @param event
   * @return
   * @throws ExecutionException
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {

    Theme theme = null;
    int dialogResult = -1;

    // Get current selection
    ISelection selection = HandlerUtil.getCurrentSelection(event);

    // Get selected file from selection
    if (selection instanceof IStructuredSelection) {

      // Get executed command ID
      String commandID = event.getCommand().getId();
      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

      if (THEME_DEFINE_COMMAND_ID.equals(commandID)) {

        // Get theme initialise with slected elements
        theme = cssHelper.defineCSSStyleSheetFilesAsTheme((IStructuredSelection) selection);
        // Open a specific dialog to define theme according to selection
        Dialog dialog = new CSSThemeCreationDialog(shell, theme);
        dialogResult = dialog.open();

      } else if (THEME_EDIT_COMMAND_ID.equals(commandID)) {
        IPath workspaceThemesFilePath = cssHelper.getThemeWorkspacePreferenceFilePath();

        WorkspaceThemes workspaceThemes = null;
        if (workspaceThemesFilePath.toFile().exists()) {
          ResourceSet resourceSet = new ResourceSetImpl();
          Resource resource =
              resourceSet.getResource(
                  URI.createFileURI(workspaceThemesFilePath.toOSString()), true);
          workspaceThemes =
              (WorkspaceThemes)
                  EcoreUtil.getObjectByType(
                      resource.getContents(), StylesheetsPackage.Literals.WORKSPACE_THEMES);
        }

        // Open a specific dialog to edit existing theme according to selection
        if (workspaceThemes != null && !workspaceThemes.getThemes().isEmpty()) {

          CSSThemeEditionDialog dialog =
              new CSSThemeEditionDialog(shell, workspaceThemes, (IStructuredSelection) selection);
          dialogResult = dialog.open();

          theme = dialog.getEditedTheme();
        } else {
          MessageDialog.openWarning(
              shell,
              Messages.getString("CSSFileHandler.edition.warning.title"),
              Messages.getString("CSSFileHandler.edition.warning.message"));
        }
      }

      // Save and reload themes list only if user has validated
      if (dialogResult == Window.OK) {

        if (THEME_DEFINE_COMMAND_ID.equals(commandID)) {
          cssHelper.saveNewThemeWorkspacePreference(theme);
        } else if (THEME_EDIT_COMMAND_ID.equals(commandID)) {
          cssHelper.saveWorkspaceThemesPreferenceResource(theme);
        }

        ThemeManager.instance.reloadThemes();
      }
    }

    return null;
  }
  public void importFile(File file) {
    try {
      QifFile qifFile = new QifFile(file, QifDateFormat.DetermineFromFileAndSystem);

      if (!(account instanceof CurrencyAccount)) {
        // TODO: process error properly
        if (QIFPlugin.DEBUG) System.out.println("account is not a currency account");
        throw new QifImportException("selected account is not a currency account");
      }

      CurrencyAccount currencyAccount = (CurrencyAccount) account;

      /*
       * Create a transaction to be used to import the entries.  This allows the entries to
       * be more efficiently written to the back-end datastore and it also groups
       * the entire import as a single change for undo/redo purposes.
       */
      TransactionManager transactionManager = new TransactionManager(session.getDataManager());
      Session sessionInTransaction = transactionManager.getSession();
      CurrencyAccount accountInTransaction =
          transactionManager.getCopyInTransaction(currencyAccount);

      /*
       * Check that this QIF file is of a form that has entries only, no account information.  This is the
       * form that is down-loaded from a banking site.
       */
      if (!qifFile.accountList.isEmpty()) {
        throw new QifImportException(
            "QIF file contains information not typical of a bank download.  It looks like the file was exported from an accounting program.");
      }

      if (!qifFile.invstTransactions.isEmpty()) {
        throw new QifImportException(
            "This QIF file has investement transactions.  This is not supported for bank imports.");
      }

      /*
       * Import transactions that have no account information.
       */
      if (!qifFile.transactions.isEmpty()) {
        // TODO: This should come from the account????
        Currency currency = sessionInTransaction.getDefaultCurrency();

        int transactionCount = 0;

        MatchingEntryFinder matchFinder =
            new MatchingEntryFinder() {
              @Override
              protected boolean alreadyMatched(Entry entry) {
                return entry.getPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor())
                    != null;
              }
            };

        //						ImportMatcher matcher = new
        // ImportMatcher(accountInTransaction.getExtension(PatternMatcherAccountInfo.getPropertySet(), true));

        Collection<EntryData> importedEntries = new ArrayList<EntryData>();

        for (QifTransaction qifTransaction : qifFile.transactions) {

          if (!qifTransaction.getSplits().isEmpty()) {
            throw new RuntimeException(
                "QIF file contains information not typical of a bank download.  It looks like the file was exported from an accounting program.");
          }

          if (qifTransaction.getCategory() != null) {
            throw new RuntimeException(
                "When transactions are listed in the QIF file with no account information (downloaded from bank), there must not be any category information.");
          }

          Date date = convertDate(qifTransaction.getDate());
          long amount = adjustAmount(qifTransaction.getAmount(), currency);

          String uniqueId = Long.toString(date.getTime()) + '~' + amount;

          Entry match =
              matchFinder.findMatch(currencyAccount, amount, date, qifTransaction.getCheckNumber());
          if (match != null) {
            Entry entryInTrans = transactionManager.getCopyInTransaction(match);
            entryInTrans.setValuta(date);
            entryInTrans.setCheck(qifTransaction.getCheckNumber());
            entryInTrans.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(), uniqueId);
          } else {
            EntryData entryData = new EntryData();
            entryData.amount = amount;
            entryData.check = qifTransaction.getCheckNumber();
            //							entryData.valueDate = date;
            entryData.clearedDate = date;
            entryData.setMemo(qifTransaction.getMemo());
            entryData.setPayee(qifTransaction.getPayee());

            //								Entry entry = matcher.process(entryData, sessionInTransaction);
            //								entry.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(),
            // uniqueId);

            importedEntries.add(entryData);
          }

          /*
          do just the above.  The following is obsolete.
          		Then remove the duplicate autoMatch method.


          							// Create a new transaction
          							Transaction transaction = sessionInTransaction.createTransaction();

          							// Add the first entry for this transaction and set the account
          							QIFEntry firstEntry = transaction.createEntry().getExtension(QIFEntryInfo.getPropertySet(), true);
          							firstEntry.setAccount(accountInTransaction);

          							transaction.setDate(date);
          							firstEntry.setAmount(amount);
          							firstEntry.setReconcilingState(qifTransaction.getStatus());
          							firstEntry.setCheck(qifTransaction.getCheckNumber());
          							firstEntry.setMemo(qifTransaction.getPayee());

          							// Add the second entry for this transaction
          							Entry secondEntry = transaction.createEntry();

          							secondEntry.setAmount(-amount);

          							firstEntry.setMemo(qifTransaction.getMemo());

          							String address = null;
          							for (String line : qifTransaction.getAddressLines()) {
          								if (address == null) {
          									address = line;
          								} else {
          									address = address + '\n' + line;
          								}
          							}
          							firstEntry.setAddress(address);

          							if (secondEntry.getAccount() instanceof IncomeExpenseAccount) {
          								// If this entry is for a multi-currency account,
          								// set the currency to be the same as the currency for this
          								// bank account.
          								if (((IncomeExpenseAccount)secondEntry.getAccount()).isMultiCurrency()) {
          									secondEntry.setIncomeExpenseCurrency(currency);
          								}
          							}
          							*/

          transactionCount++;
        }

        PatternMatcherAccount matcherAccount =
            account.getExtension(PatternMatcherAccountInfo.getPropertySet(), true);

        Dialog dialog =
            new PatternMatchingDialog(window.getShell(), matcherAccount, importedEntries);
        if (dialog.open() == Dialog.OK) {
          ImportMatcher matcher =
              new ImportMatcher(
                  accountInTransaction.getExtension(
                      PatternMatcherAccountInfo.getPropertySet(), true));

          for (net.sf.jmoney.importer.matcher.EntryData entryData : importedEntries) {
            Entry entry = matcher.process(entryData, sessionInTransaction);
            //								entry.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(),
            // uniqueId);
          }
        } else {
          return;
        }

        /*
         * All entries have been imported and all the properties
         * have been set and should be in a valid state, so we
         * can now commit the imported entries to the datastore.
         */
        String transactionDescription = String.format("Import {0}", file.getName());
        transactionManager.commit(transactionDescription);

        if (transactionCount != 0) {
          StringBuffer combined = new StringBuffer();
          combined.append(file.getName());
          combined.append(" was successfully imported. ");
          combined.append(transactionCount).append(" transactions were imported.");
          MessageDialog.openInformation(
              window.getShell(), "QIF file imported", combined.toString());
        } else {
          throw new QifImportException("No transactions were found within the given date range.");
        }
      }
    } catch (IOException e) {
      MessageDialog.openError(
          window.getShell(), "Unable to read QIF file", e.getLocalizedMessage());
    } catch (InvalidQifFileException e) {
      MessageDialog.openError(
          window.getShell(), "Unable to import QIF file", e.getLocalizedMessage());
    } catch (QifImportException e) {
      MessageDialog.openError(
          window.getShell(), "Unable to import QIF file", e.getLocalizedMessage());
    } catch (AmbiguousDateException e) {
      MessageDialog.openError(
          window.getShell(),
          "QIF file has an ambiguous date format that cannot be guessed from your locale.",
          e.getLocalizedMessage());
    }
  }