Beispiel #1
0
  /** reads the text from the opened editor */
  private void getText() {
    InputStream stream = EditorsManager.getInstance().getActiveEditorContentInputStream();
    if (stream == null) {
      showMessage(Messages.FriedmanGraphUI_openandselect);
      return;
    } else {
      ciphertext = InputStreamToString(stream);
    }

    analyzedFile = EditorsManager.getInstance().getActiveEditorTitle();

    if (ciphertext.hashCode() != ciphertextHash) {
      ciphertextHash = ciphertext.hashCode();
      goodCiphertext = makeFormattedString(ciphertext);
    }
  }
 private void loadEditorsAndFillEditorChooser() {
   IEditorReference activeReference = EditorsManager.getInstance().getActiveEditorReference();
   for (int i = 0; i < editorRefs.size(); i++) {
     comboEditorInputSelector.add(editorRefs.get(i).getTitle());
     if (activeReference != null && activeReference.equals(editorRefs.get(i))) {
       comboEditorInputSelector.setText(editorRefs.get(i).getTitle());
       comboEditorInputSelector.select(i);
     }
   }
   if (activeReference == null) {
     if (editorRefs.size() > 0) {
       comboEditorInputSelector.select(0);
     }
   }
 }
  private void initializeTextInput() {

    editorRefs = EditorsManager.getInstance().getEditorReferences();
    if (editorRefs.size() > 0) {
      // TODO: rename method (no loading here!)
      loadEditorsAndFillEditorChooser();
    }

    textOnlyInput =
        new TextonlyInput() {
          @Override
          public Text getTextfield() {
            return txtInputText;
          }
        };

    textInput =
        new TextWithSourceInput(editorRefs) {
          @Override
          protected Button getFileRadioButton() {
            return btnDatei;
          }

          @Override
          protected Button getBtnJctEditorOption() {
            return btnJcteditor;
          }

          @Override
          protected Button getBtnOwninput() {
            return btnZwischenablageeigeneEingabe;
          }

          @Override
          protected File getSelectedFile() {
            return fileTextInput;
          }

          @Override
          protected Combo getComboEditors() {
            return comboEditorInputSelector;
          }

          @Override
          protected Text getTextFieldForTextInput() {
            return txtInputText;
          }

          @Override
          protected IEditorReference getSelectedEditor() {
            return getCurrentlySelectedEditor();
          }

          @Override
          protected void setUIState(TextInputWithSource content, boolean b) {
            setTextInputUIState(content, b);
          }

          @Override
          protected TextInputWithSource getInitialTextObject() {
            return initTextObject;
          }

          @Override
          protected List<IEditorReference> getEditorsNotNecessarilyFresh() {
            return editorRefs;
          }

          @Override
          protected AbstractUIInput<String> getTextOnlyInput() {
            return textOnlyInput;
          }
        };

    btnJcteditor.setEnabled(editorRefs.size() > 0);
    btnDatei.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (btnDatei.getSelection()) {
              if (fileTextInput == null) fileTextInput = openFileSelectionDialogue();
              textInput.synchronizeWithUserSide();
              setTextInputUIState(textInput.getContent(), true);
            }
          }
        });
    btnJcteditor.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (btnJcteditor.getSelection()) {
              textInput.synchronizeWithUserSide();
              setTextInputUIState(textInput.getContent(), true);
            }
          }
        });
    btnZwischenablageeigeneEingabe.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (btnZwischenablageeigeneEingabe.getSelection()) {
              textInput.synchronizeWithUserSide();
              setTextInputUIState(textInput.getContent(), true);
            }
          }
        });
    comboEditorInputSelector.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            textInput.synchronizeWithUserSide();
            setTextInputUIState(textInput.getContent(), true);
          }
        });
    linkChangeFile.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fileTextInput = openFileSelectionDialogue();
            textInput.synchronizeWithUserSide();
            setTextInputUIState(textInput.getContent(), true);
          }
        });
    textInput.addObserver(
        new Observer() {
          @Override
          public void update(Observable o, Object arg) {
            preview();
          }
        });
  }