Exemplo n.º 1
0
  /** Called by application in case of new events for observer. */
  @Override
  public void handleEvent(Application pApplication, ApplicationEvent pEvent) {
    pApplication.getLogger().log(this, "Got update event " + pEvent + " from " + pApplication);

    if (pEvent instanceof ApplicationEventConnectError) {
      ApplicationEventConnectError tEvConErr = (ApplicationEventConnectError) pEvent;
      NetworkException tExc = tEvConErr.getNetworkEception();

      if (tExc instanceof RoutingException) {
        MessageBoxDialog.open(
            getSite().getShell(),
            "Routing error",
            "The routing wasn't able to find a path to " + mRelayClient.getDestination(),
            SWT.ICON_ERROR);
      } else if (tExc instanceof RequirementsException) {
        MessageBoxDialog.open(
            getSite().getShell(),
            "Requirements error",
            "The given requirements \""
                + ((RequirementsException) tExc).getRequirements()
                + "\" for the connection couldn't be fullfilled.",
            SWT.ICON_ERROR);
      } else {
        MessageBoxDialog.open(
            getSite().getShell(), "Error", "Error: " + tExc.getMessage(), SWT.ICON_ERROR);
      }
    }

    if (pEvent instanceof ApplicationEventExit) {
      EditorUtils.closeEditor(getSite(), this);
    }
  }
Exemplo n.º 2
0
 private String getUrl(EditorItem source) {
   URL url = EditorUtils.getUrl(source.getValue(), fxmlFileLocation);
   if (url == null) {
     return null;
   }
   String urlStr = url.toExternalForm();
   return urlStr;
 }
Exemplo n.º 3
0
    protected void requestFocus() {
      EditorUtils.doNextFrame(
          new Runnable() {

            @Override
            public void run() {
              stylesheetTf.requestFocus();
            }
          });
    }
Exemplo n.º 4
0
    @SuppressWarnings("LeakingThisInConstructor")
    public StylesheetItem(EditorItemDelegate editor, String url) {
      //            System.out.println("New StylesheetItem.");
      this.editor = editor;
      Parent parentRoot = EditorUtils.loadFxml("StylesheetEditorItem.fxml", this);
      assert parentRoot instanceof Pane;
      root = (Pane) parentRoot;

      initialize(url);
    }
 @Override
 public Object getValue() {
   String val = textNode.getText();
   if (i18nMode) {
     val = new PrefixedValue(PrefixedValue.Type.RESOURCE_KEY, val).toString();
   } else {
     val = EditorUtils.getPlainString(val);
   }
   return val;
 }
 private void wrapInHBox() {
   i18nHBox = new HBox();
   i18nHBox.setAlignment(Pos.CENTER);
   EditorUtils.replaceNode(textNode, i18nHBox, null);
   Label percentLabel = new Label(PERCENT_STR);
   percentLabel.getStyleClass().add("symbol-prefix"); // NOI18N
   i18nHBox.getChildren().addAll(percentLabel, textNode);
   HBox.setHgrow(percentLabel, Priority.NEVER);
   // we have to set a small pref width for the text node else it will
   // revert to it's API set pref width which is too wide
   textNode.setPrefWidth(30.0);
   HBox.setHgrow(textNode, Priority.ALWAYS);
 }
 protected void switchToTextArea() {
   if (textNode instanceof TextArea) {
     return;
   }
   // Move the node from TextField to TextArea
   TextArea textArea = new TextArea(textNode.getText());
   setTextEditorBehavior(this, textArea, valueListener);
   textArea.setPrefRowCount(5);
   setLayoutFormat(LayoutFormat.SIMPLE_LINE_TOP);
   if (textNode.getParent() != null) {
     // textNode is already in scene graph
     EditorUtils.replaceNode(textNode, textArea, getLayoutFormat());
   }
   textNode = textArea;
 }
 protected void switchToTextField() {
   if (textNode instanceof TextField) {
     return;
   }
   // Move the node from TextArea to TextField.
   // The current text is compacted to a single line.
   String val = textNode.getText().replace("\n", ""); // NOI18N
   TextField textField = new TextField(val);
   setTextEditorBehavior(this, textField, valueListener);
   setLayoutFormat(LayoutFormat.SIMPLE_LINE_CENTERED);
   if (textNode.getParent() != null) {
     // textNode is already in scene graph
     EditorUtils.replaceNode(textNode, textField, getLayoutFormat());
   }
   textNode = textField;
 }
Exemplo n.º 9
0
 private void switchType(Type type) {
   this.type = type;
   updateMenuItems();
   for (EditorItem editorItem : getEditorItems()) {
     assert editorItem instanceof StylesheetItem;
     StylesheetItem stylesheetItem = (StylesheetItem) editorItem;
     URL url = EditorUtils.getUrl(stylesheetItem.getValue(), fxmlFileLocation);
     String value = null;
     if ((url == null) || (type == Type.CLASSLOADER_RELATIVE_PATH)) {
       // In this case we empty the text field (i.e. suffix) content
       value = new PrefixedValue(type, "").toString(); // NOI18N
     } else if (type == Type.PLAIN_STRING) {
       value = url.toExternalForm();
     } else if (type == Type.DOCUMENT_RELATIVE_PATH) {
       value = PrefixedValue.makePrefixedValue(url, fxmlFileLocation).toString();
     }
     stylesheetItem.setValue(value);
     commit(stylesheetItem);
   }
 }
Exemplo n.º 10
0
  @SuppressWarnings("LeakingThisInConstructor")
  public StylesheetEditor(
      IMetadata metadata,
      ValuePropertyMetadata propMeta,
      Set<Class<?>> selectedClasses,
      URL fxmlFileLocation) {
    super(metadata, propMeta, selectedClasses);
    this.fxmlFileLocation = fxmlFileLocation;
    setLayoutFormat(PropertyEditor.LayoutFormat.DOUBLE_LINE);
    // Add initial button
    rootInitialBt = EditorUtils.loadFxml("StylesheetEditorInitialBt.fxml", this); // NOI18N
    root.getChildren().add(rootInitialBt);
    // Set the initial value to empty list (instead of null)
    valueProperty().setValue(FXCollections.observableArrayList());

    documentRelativeMenuItem.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            switchType(Type.DOCUMENT_RELATIVE_PATH);
          }
        });
    classPathRelativeMenuItem.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            switchType(Type.CLASSLOADER_RELATIVE_PATH);
          }
        });
    absoluteMenuItem.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            switchType(Type.PLAIN_STRING);
          }
        });
    getMenu()
        .getItems()
        .addAll(documentRelativeMenuItem, classPathRelativeMenuItem, absoluteMenuItem);
  }
Exemplo n.º 11
0
 /** Remove invisible direction chars on the copy text into clipboard. */
 @Override
 public String getSelectedText() {
   String st = super.getSelectedText();
   return st != null ? EditorUtils.removeDirectionChars(st) : null;
 }
 @Override
 public void requestFocus() {
   EditorUtils.doNextFrame(() -> textNode.requestFocus());
 }
 private void unwrapHBox() {
   i18nHBox.getChildren().remove(textNode);
   EditorUtils.replaceNode(i18nHBox, textNode, null);
 }