Package net.sourceforge.syncyoursecrets.gui.rcp

Examples of net.sourceforge.syncyoursecrets.gui.rcp.View


    logger.debug("entering execute");

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    // get the content provider and fill it with an empty list
    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    try {
      contentProvider.createNew();
    } catch (ParserConfigurationException e) {
View Full Code Here


  public Object execute(ExecutionEvent event) throws ExecutionException {
    logger.debug("entering execute");
    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);
    TableViewer viewer = view.getViewer();

    // Get the selection
    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    ISelection selection = viewer.getSelection();
    if (selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      if (obj != null) {
        logger.debug("Removing 1 Object");
        contentProvider.removeEntry(obj);
      }

    } else {
      // error handling: Unexpected case no IStructuredSelection
      String msg = "Selected Element is not an instance of IStructuredSelection";

      MessageDialog.showUnexpectedErrorMessage(msg, logger, null);
      throw new ExecutionException(msg);
    }
    view.selectEntry();
    logger.debug("exiting execute");
    return null;
  }
View Full Code Here

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    // File standard dialog
    FileDialog fileDialog = new FileDialog(shell);
    fileDialog.setText("Select File");
    // Open Dialog and save result of selection
    String selected = fileDialog.open();

    if (selected == null) {
      logger.info("File selection aborted");
      return null;
    }
    File file = new File(selected);

    logger.debug("File selected " + file);

    PasswordInputDialog passwordDialog = new PasswordInputDialog(shell,
        "Password for " + file.getName(), "Enter password ", "",
        new DummyInputValidator());
    passwordDialog.open();
    String password = passwordDialog.getValue();

    logger.debug("Password entered, length is" + password.length());

    if (file.isFile() && file.canRead()) {
      PWListContentProvider contentProvider = (PWListContentProvider) view
          .getContentProvider();
      try {
        contentProvider.loadEncryptedFile(password, file);
      } catch (Exception e) {

        String msg = "Cannot open file"
            + "Failed to load XML from file "
            + file.getAbsolutePath();

        MessageDialog.showExpectedErrorMessage(msg, logger, e);

        throw new ExecutionException(msg, e);
      }
    } else {
      // error handling: File not readable
      String msg = "Cannot read file " + file.getAbsolutePath()
          + "\n File is not readable";

      MessageDialog.showExpectedErrorMessage(msg, logger);
      throw new ExecutionException(msg);
    }

    view.refresh();
    view.selectEntry();

    logger.debug("exiting execute");
    return null;
  }
View Full Code Here

    logger.debug("entering execute");

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    try {

      contentProvider.save();
      MessageDialog.showInfoMessage("File successfully saved",
View Full Code Here

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    // File standard dialog
    FileDialog fileDialog = new FileDialog(shell);
    // Set the text
    fileDialog.setText("Select file to merge");
    // Open Dialog and save result of selection
    String selected = fileDialog.open();

    if (selected == null) {
      logger.info("File selection aborted");
      return null;
    }

    File file = new File(selected);

    logger.debug("File selected for merge: " + file);

    PasswordInputDialog passwordDialog = new PasswordInputDialog(shell,
        "Password for " + file.getName(), "Enter password ", "",
        new DummyInputValidator());
    passwordDialog.open();
    String password = passwordDialog.getValue();
    logger.debug("Password entered, length is " + password.length());

    if (file.isFile() && file.canRead()) {
      PWListContentProvider contentProvider = (PWListContentProvider) view
          .getContentProvider();
      try {
        contentProvider.mergeWithFile(password, file);
      } catch (Exception e) {

        String msg = "Cannot merge file"
            + "Failed to load XML from file "
            + file.getAbsolutePath();

        MessageDialog.showExpectedErrorMessage(msg, logger, e);

        throw new ExecutionException(msg, e);
      }
    } else {
      // error handling: File not readable
      String msg = "Cannot read file " + file.getAbsolutePath()
          + "\n File is not readable";

      MessageDialog.showExpectedErrorMessage(msg, logger);
      throw new ExecutionException(msg);

    }

    view.refresh();
    view.selectEntry();
    logger.debug("exiting execute");
    return null;
  }
View Full Code Here

   *      ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    logger.debug("entering execute");

    View view = SingletonHolder.getView();
    IWorkbenchPage page = view.getSite().getPage();

    // View view = (View) page.findView(View.ID);
    TableViewer viewer = view.getViewer();

    // Get the selection

    Object obj = view.getSelectedObject();
    // Open an editor for the current selection
    try {
      if (obj != null) {
        if (obj instanceof PWEntry) {
          logger.debug("Selected PWEntry");
          PWEntry pwEntry = (PWEntry) obj;
          IEditorInput input = new PWEditorInput(view, pwEntry);

          reuseEditor(page, viewer, input, PWEntryEditor.ID);

        } else if (obj instanceof PWTable) {
          logger.debug("Selected PWTable");
          PWTable pwTable = (PWTable) obj;
          PWTableInput input = new PWTableInput(view, pwTable);

          reuseEditor(page, viewer, input, PWTableEditor.ID);

        } else {
          // error handling: Unknown object in selection table
          String msg = "Selected Element must be one of PWEntry, PWTable";

          MessageDialog.showUnexpectedErrorMessage(msg, logger);
          throw new ExecutionException(msg);
        }
      } else {
        closeAllEditors(page);
      }
    } catch (PartInitException e) {
      String msg = "Calling editor failed";

      MessageDialog.showUnexpectedErrorMessage(msg, logger, e);

      throw new ExecutionException(msg, e);
    }
    view.refresh();

    logger.debug("exiting execute");
    return null;
  }
View Full Code Here

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    // File standard dialog
    FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
    // Set the text
    fileDialog.setText("Save as...");
    // Open Dialog and save result of selection
    String selected = fileDialog.open();

    if (selected == null) {
      logger.info("File selection aborted");
      return null;
    }

    File file = new File(selected);
    logger.debug("File selected " + file.getAbsolutePath());

    // if the file exists, check for writeability
    if (!file.exists() || (file.exists() && file.canWrite())) {
      logger.debug("File is writable");
      // enter password for the 1st time
      PasswordInputDialog passwordDialog = new PasswordInputDialog(shell,
          "Password for " + file.getName(), "Enter password ", "",
          new DummyInputValidator());
      passwordDialog.open();
      String password1 = passwordDialog.getValue();
      logger.debug("Entered password for the 1st time, length is "
          + password1.length());

      // Re-enter password. Reusing the same dialog here is quicker to
      // implement than using a dialog with two password fields.
      passwordDialog = new PasswordInputDialog(shell, "Password for "
          + file.getName(), "Re-Enter password ", "",
          new DummyInputValidator());
      passwordDialog.open();
      String password2 = passwordDialog.getValue();

      logger.debug("Entered password for the 1st time, length is "
          + password1.length());
      if (password1.equals(password2)) {
        logger.info("Entered passwords match, OK");
        String password = password1;
        PWListContentProvider contentProvider = (PWListContentProvider) view
            .getContentProvider();
        try {
          contentProvider.saveEncryptedFile(password, file);
          MessageDialog.showInfoMessage("Successfully saved to "
              + file.getAbsolutePath(), "File saved", logger);
View Full Code Here

   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);
    TableViewer viewer = view.getViewer();

    // Get the selection
    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    ISelection selection = viewer.getSelection();
    if (selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      if (obj != null) {
View Full Code Here

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    // File standard dialog
    FileDialog fileDialog = new FileDialog(shell);
    fileDialog.setText("Select File");
    // Open Dialog and save result of selection
    String selected = fileDialog.open();

    File file = new File(selected);
    PasswordInputDialog passwordDialog = new PasswordInputDialog(shell,
        "Password for " + file.getName(), "Enter password ", "",
        new DummyInputValidator());
    passwordDialog.open();
    String password = passwordDialog.getValue();

    if (file.isFile() && file.canRead()) {
      PWListContentProvider contentProvider = (PWListContentProvider) view
          .getContentProvider();
      try {
        contentProvider.loadEncryptedFile(password, file);
      } catch (Exception e) {
        MessageDialog.openError(shell, "Cannot open file",
View Full Code Here

    Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);

    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    try {
      contentProvider.save();

    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of net.sourceforge.syncyoursecrets.gui.rcp.View

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.