Package org.dyno.visual.swing.plugin.spi

Examples of org.dyno.visual.swing.plugin.spi.IEditor


  }

  private void startEditComponent(Component hovered, Point loc) {
    WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(hovered);
    IEditorAdapter editorAdapter = (IEditorAdapter) adapter.getAdapter(IEditorAdapter.class);
    IEditor iEditor = null;
    if (editorAdapter != null) {
      editorAdapter.setHotspot(loc);
      iEditor = editorAdapter.getEditorAt();
    }
    if (iEditor != null) {
      iEditor.setFont(adapter.getWidget().getFont());
      iEditor.setValue(editorAdapter.getWidgetValue());
      iEditor.addChangeListener(this);
      Rectangle bounds = editorAdapter.getEditorBounds();
      bounds = SwingUtilities.convertRectangle(hovered, bounds, designer);
      Component comp = iEditor.getComponent();
      Font f = adapter.getWidget().getFont();
      if (f != null) {
        comp.setFont(f);
      }
      comp.setBounds(bounds);
      comp.doLayout();
      glassPlane.add(comp);
      comp.addFocusListener(this);
      glassPlane.validate();
      glassPlane.repaint();
      comp.repaint();
      iEditor.setFocus();
      currentEditor = new EditorAdapter(adapter, iEditor);
    }
  }
View Full Code Here


  private boolean _stopEditing(boolean silence) {
    if (currentEditor != null) {
      stoppingEditing = true;
      WidgetAdapter adapter = currentEditor.getAdapter();
      IEditor iEditor = currentEditor.getEditor();
      try {
        iEditor.validateValue();
        Object newValue = iEditor.getValue();
        Object oldValue = iEditor.getOldValue();
        if (isValueChanged(oldValue, newValue)) {
          IUndoableOperation operation = new SetWidgetValueOperation(adapter, oldValue, newValue);
          IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
          operation.addContext(adapter.getUndoContext());
          operationHistory.execute(operation, null, null);
          adapter.setDirty(true);
          CompositeAdapter container = (CompositeAdapter) adapter.getParentAdapter();
          if (container != null)
            container.adjustLayout(adapter.getWidget());
          if (adapter.isSelected()) {
            designer.publishSelection();
          }
        }
        iEditor.removeChangeListener(this);
        iEditor.getComponent().removeFocusListener(this);
        iEditor.getComponent().transferFocus();
        glassPlane.remove(iEditor.getComponent());
        glassPlane.validate();
        designer.repaint();
        currentEditor = null;
        return true;
      } catch (Exception e) {
        if (silence) {
          iEditor.removeChangeListener(this);
          iEditor.getComponent().removeFocusListener(this);
          glassPlane.remove(iEditor.getComponent());
          glassPlane.validate();
          currentEditor = null;
        } else {
          final String message = e.getMessage();
          final Shell shell = JavaUtil.getEclipseShell();
          shell.getDisplay().syncExec(new Runnable() {
           
            public void run() {
              MessageDialog.openError(shell, Messages.GLASS_TARGET_VALIDATION_ERROR, message);
            }
          });
          iEditor.getComponent().requestFocus();
        }
        return false;
      } finally {
        stoppingEditing = false;
      }
View Full Code Here

TOP

Related Classes of org.dyno.visual.swing.plugin.spi.IEditor

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.