Package net.sourceforge.syncyoursecrets.gui.rcp

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


    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();

    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.mergeWithFile(password, file);
      } catch (Exception e) {
        MessageDialog.openError(shell, "Cannot open file",
View Full Code Here


  public Object execute(ExecutionEvent event) throws ExecutionException {
    // Get the view; we need almost all of these, so refactoring makes
    // little sense
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);
    TableViewer viewer = view.getViewer();
    // Get the selection
    ISelection selection = viewer.getSelection();
    if (selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      // Open an editor for the current selection
      if (obj != null) {
        if (obj instanceof PWEntry) {

          try {
            PWEntry pwEntry = (PWEntry) obj;
            PWEditorInput input = new PWEditorInput(view, pwEntry);
            IEditorReference[] editorReferences = page
                .getEditorReferences();

            PWEntryEditor editor = null;
            for (IEditorReference ref : editorReferences) {
              if (ref.getEditor(true) instanceof PWEntryEditor) {
                editor = (PWEntryEditor) ref.getEditor(true);
              }
            }
            if (editor != null) {
              page.reuseEditor(editor, input);
              viewer.setSelection(viewer.getSelection());
            } else {
              page.openEditor(input, PWEntryEditor.ID);
            }
          } catch (PartInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ExecutionException("Calling editor failed "
                + e);
          }
          view.refresh();

        }
      }
    }
    return null;
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);
    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    try {
      contentProvider.addEntry();
    } catch (Exception e) {
      e.printStackTrace();
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();

    File file = new File(selected);
    // if the file exists, check for writeability
    if (!file.exists() || (file.exists() && file.canWrite())) {
      // 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();

      // 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();

      if (password1.equals(password2)) {
        String password = password1;
        PWListContentProvider contentProvider = (PWListContentProvider) view
            .getContentProvider();
        try {
          contentProvider.saveEncryptedFile(password, file);
        } catch (ParserConfigurationException e) {
          MessageDialog.openError(shell, "Cannot save file",
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);

    // get the content provider and fill it with an empty list
    PWListContentProvider contentProvider = (PWListContentProvider) view
        .getContentProvider();
    try {
      contentProvider.createNew();
    } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
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.