Ejemplo n.º 1
0
 @Override
 public Object getAdapter(Class adapter) {
   if (adapter.equals(IPropertySheetPage.class)) {
     propertySourceProvider = new RuntimePropertySourceProvider();
     ((RuntimePropertySourceProvider) propertySourceProvider).setEditable(true, false);
     PropertySheetPage page = new PropertySheetPage();
     page.setPropertySourceProvider(propertySourceProvider);
     return page;
   }
   return super.getAdapter(adapter);
 }
 @SuppressWarnings("rawtypes")
 @Override
 public Object getAdapter(Class adapter) {
   if (adapter.equals(IPropertySheetPage.class)) {
     PropertySheetPage propertySheetPage = new PropertySheetPage();
     propertySheetPage.setPropertySourceProvider(
         new AdapterFactoryContentProvider(
             new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)));
     return propertySheetPage;
   }
   return super.getAdapter(adapter);
 }
Ejemplo n.º 3
0
  @SuppressWarnings("deprecation")
  @Override
  public void createPartControl(Composite parent) {
    //		ProjectBuilder.addPropertyChangeListener(this);
    m_viewer = createViewer(parent);
    m_viewer.setSorter(new Sorter());
    initContextMenu();
    makeActions();
    getSite().setSelectionProvider(m_viewer);

    getActionGroup().fillActionBars(getViewSite().getActionBars());

    m_propertyPage = new PropertySheetPage();
    m_propertyPage.setPropertySourceProvider(new AttributedPropertySourceProvider());

    setInput(m_inputType);

    Workspace.getInstance().installResourceListener(this);

    Job job =
        new Job("") {
          @Override
          public IStatus run(IProgressMonitor monitor) {
            for (Project project : Workspace.getInstance().getProjects()) {
              try {
                ReconcileMessageConsumer consumer = new ReconcileMessageConsumer();
                project.reconcile(consumer, monitor);
              } catch (Exception e) {
                return Status.CANCEL_STATUS;
              }
              ;
            }

            /*Display.getDefault().asyncExec(new Runnable()
            {
            	public void run()
            	{
            		setInput(m_inputType);
            	}
            });*/

            return Status.OK_STATUS;
          }
        };
    job.schedule();
  }
Ejemplo n.º 4
0
  public IPropertySheetPage getPropertySheetPage() {
    PropertySheetPage propertySheetPage =
        new ExtendedPropertySheetPage(editingDomain) {
          @Override
          public void setSelectionToViewer(List<?> selection) {
            setSelectionToViewer(selection);
          }

          @Override
          public void setActionBars(IActionBars actionBars) {
            super.setActionBars(actionBars);
          }
        };
    propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
    propertySheetPages.add(propertySheetPage);

    return propertySheetPage;
  }
  /**
   * This accesses a cached version of the property sheet.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IPropertySheetPage getPropertySheetPage() {
    if (propertySheetPage == null) {
      propertySheetPage =
          new ExtendedPropertySheetPage(editingDomain) {
            public void setSelectionToViewer(List selection) {
              ProvervisualEditor.this.setSelectionToViewer(selection);
              ProvervisualEditor.this.setFocus();
            }

            public void setActionBars(IActionBars actionBars) {
              super.setActionBars(actionBars);
              getActionBarContributor().shareGlobalActions(this, actionBars);
            }
          };
      propertySheetPage.setPropertySourceProvider(
          new AdapterFactoryContentProvider(adapterFactory));
    }

    return propertySheetPage;
  }
 private PropertySheetPage getPropertySheetPage() {
   if (fPropertySheetPage == null) {
     final PropertySheetPage propertySheetPage = new PropertySheetPage();
     propertySheetPage.setPropertySourceProvider(
         new IPropertySourceProvider() {
           public IPropertySource getPropertySource(Object object) {
             if (object instanceof IJavaElement)
               return new JavaElementProperties((IJavaElement) object);
             else if (object instanceof IResource)
               return new ResourceProperties((IResource) object);
             else if (object instanceof IMarker) return new MarkerProperties((IMarker) object);
             else if (object instanceof IJarEntryResource)
               return new JarEntryResourceProperties((IJarEntryResource) object);
             else if (object instanceof IMemberValuePair)
               return new MemberValuePairProperties((IMemberValuePair) object);
             else if (object instanceof IClasspathEntry)
               return new ClasspathEntryProperties((IClasspathEntry) object);
             else return null;
           }
         });
     fPropertySheetPage = propertySheetPage;
   }
   return fPropertySheetPage;
 }
  @Override
  protected Control createControl(Composite parent) {
    Composite propertyComposite = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = layout.marginHeight = 0;
    propertyComposite.setLayout(layout);
    if (mPage instanceof Page) {
      ((Page) mPage)
          .init(
              new IPageSite() {
                public void registerContextMenu(
                    String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) {}

                public IActionBars getActionBars() {
                  return null;
                }

                public IWorkbenchPage getPage() {
                  return getWorkbenchWindow().getActivePage();
                }

                public ISelectionProvider getSelectionProvider() {
                  return null;
                }

                public Shell getShell() {
                  return getWorkbenchWindow().getShell();
                }

                public IWorkbenchWindow getWorkbenchWindow() {
                  return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                }

                public void setSelectionProvider(ISelectionProvider provider) {}

                @SuppressWarnings("unchecked")
                public Object getAdapter(Class adapter) {
                  return null;
                }

                @SuppressWarnings("unchecked")
                public Object getService(Class api) {
                  return null;
                }

                @SuppressWarnings("unchecked")
                public boolean hasService(Class api) {
                  return false;
                }
              });
    }
    if (mPage instanceof PropertySheetPage) {
      ((PropertySheetPage) mPage).setPropertySourceProvider(this);
    }
    mPage.createControl(propertyComposite);
    mPage.setActionBars(new DummyActionBars());
    final Control control = mPage.getControl();
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    if (control instanceof Tree) {
      final Tree tree = (Tree) control;
      data.heightHint =
          tree.getItemHeight() * 13
              + (tree.getLinesVisible() ? 12 * tree.getGridLineWidth() : 0)
              + (tree.getHeaderVisible() ? tree.getHeaderHeight() : 0)
              + 2 * tree.getBorderWidth()
              + (tree.getHorizontalBar() != null ? tree.getHorizontalBar().getSize().x : 0);
      tree.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlResized(ControlEvent e) {
              Rectangle area = tree.getClientArea();
              TreeColumn[] columns = tree.getColumns();
              if (area.width > 0) {
                columns[0].setWidth(area.width * 40 / 100);
                columns[1].setWidth(area.width - columns[0].getWidth() - 4);
              }
            }
          });
    } else if (control instanceof Composite) {
      control.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlResized(ControlEvent e) {
              ((Composite) control).layout(true, true);
            }
          });
    }
    control.setLayoutData(data);
    ISelection selection;
    if (mCurrentWidget == null) {
      Collection<InstallOptionsModelTypeDef> typeDefs =
          InstallOptionsModel.INSTANCE.getControlTypeDefs();
      if (typeDefs.size() > 0) {
        InstallOptionsModelTypeDef typeDef = typeDefs.iterator().next();
        InstallOptionsElementFactory factory =
            InstallOptionsElementFactory.getFactory(typeDef.getType());
        mCurrentWidget = (InstallOptionsWidget) factory.getNewObject();
        mDialog.addChild(mCurrentWidget);
      }
    }

    if (mCurrentWidget != null) {
      mCurrentWidget.addModelCommandListener(InstallOptionsWidgetEditorDialog.this);
      mCurrentWidget.addPropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
      if (mCurrentWidget.getParent() != null) {
        mCurrentWidget.getParent().addPropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
      }
      selection = new StructuredSelection(mCurrentWidget);
    } else {
      selection = StructuredSelection.EMPTY;
    }

    mPage.selectionChanged(null, selection);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(mPage.getControl(), HELP_CONTEXT);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyComposite, HELP_CONTEXT);

    return propertyComposite;
  }
Ejemplo n.º 8
0
  /**
   * This accesses a cached version of the property sheet.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  public IPropertySheetPage getPropertySheetPage() {
    class UnsortedPropertySheetPage extends ExtendedPropertySheetPage {
      public UnsortedPropertySheetPage(AdapterFactoryEditingDomain editingDomain) {
        super(editingDomain);
        setSorter(
            new PropertySheetSorter() {
              @Override
              public void sort(IPropertySheetEntry[] entries) {
                // Intentionally left empty
              }
            });
      }

      public void setSelectionToViewer(List selection) {
        GenfwEditor.this.setSelectionToViewer(selection);
        GenfwEditor.this.setFocus();
      }

      public void setActionBars(IActionBars actionBars) {
        super.setActionBars(actionBars);
        getActionBarContributor().shareGlobalActions(this, actionBars);
      }
    }

    if (propertySheetPage == null) {
      AdapterFactoryContentProvider provider =
          new AdapterFactoryContentProvider(adapterFactory) {
            protected IPropertySource createPropertySource(
                Object object, IItemPropertySource itemPropertySource) {
              return new PropertySource(object, itemPropertySource) {
                protected IPropertyDescriptor createPropertyDescriptor(
                    IItemPropertyDescriptor itemPropertyDescriptor) {
                  return new PropertyDescriptor(this.object, itemPropertyDescriptor) {
                    public CellEditor createPropertyEditor(Composite composite) {
                      Object genericFeature = itemPropertyDescriptor.getFeature(object);
                      if (genericFeature instanceof EStructuralFeature
                          && object instanceof EObject) {
                        final EStructuralFeature feature = (EStructuralFeature) genericFeature;
                        String editorId =
                            EcoreUtil.getAnnotation(feature, CELLEDITOR_URI, EDITOR_ID_KEY);
                        if (editorId != null && editorId.length() != 0) {
                          return new ExtendedDialogCellEditor(composite, getEditLabelProvider()) {
                            protected Object openDialogBox(Control cellEditorWindow) {
                              final Display display = cellEditorWindow.getDisplay();
                              final Font font = new Font(display, "Courier New", 10, SWT.NONE);
                              final Color color = new Color(display, 255, 0, 0);

                              Object propertyValue =
                                  itemPropertyDescriptor.getPropertyValue(object);
                              String editableValue =
                                  propertyValue == null
                                      ? null
                                      : (String)
                                          ((IItemPropertySource) propertyValue)
                                              .getEditableValue(object);

                              MultiLineDialog dialog =
                                  new MultiLineDialog(
                                      cellEditorWindow.getShell(),
                                      getEditLabelProvider(),
                                      (EObject) object,
                                      feature,
                                      editableValue,
                                      getDisplayName()) {
                                    private JavaSourceViewer viewer;

                                    @Override
                                    protected Control createTextControl(Composite parent) {
                                      String result = getResult();

                                      viewer =
                                          new JavaSourceViewer(parent, null, null, false, 0, null);
                                      viewer.setDocument(
                                          new Document(result == null ? "" : result));
                                      // viewer.setTextColor(color, 0, 10, false);

                                      Control control = viewer.getControl();
                                      control.setFont(font);
                                      return control;
                                    }

                                    @Override
                                    protected String getTextValue() {
                                      IDocument document = viewer.getDocument();
                                      return document.get();
                                    }
                                  };

                              dialog.open();
                              font.dispose();
                              color.dispose();
                              return dialog.getResult();
                            }
                          };
                        }
                      }

                      return super.createPropertyEditor(composite);
                    }
                  };
                }
              };
            }
          };

      propertySheetPage = new UnsortedPropertySheetPage(editingDomain);
      propertySheetPage.setPropertySourceProvider(provider);
    }

    return propertySheetPage;
  }