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);
 }
    public IStatus runInUIThread(IProgressMonitor monitor) {
      Object[] pages = propertySheetPages.toArray();
      propertySheetPages.clear();

      for (int i = 0; i < pages.length; i++) {
        PropertySheetPage page = (PropertySheetPage) pages[i];
        if (page.getControl() != null && !page.getControl().isDisposed()) {
          page.refresh();
        }
      }

      return Status.OK_STATUS;
    }
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;
  }
 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;
 }
Ejemplo n.º 6
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();
  }
  /**
   * 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;
  }
Ejemplo n.º 8
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void dispose() {
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this) {
      getActionBarContributor().setActiveEditor(null);
    }

    if (propertySheetPage != null) {
      propertySheetPage.dispose();
    }

    if (contentOutlinePage != null) {
      contentOutlinePage.dispose();
    }

    super.dispose();
  }
  @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;
  }
  /**
   * @param repository the repository
   * @param page the page showing the properties
   */
  public RepositoryPropertySource(Repository repository, PropertySheetPage page) {
    myPage = page;

    effectiveConfig = repository.getConfig();
    systemConfig = SystemReader.getInstance().openSystemConfig(null, FS.DETECTED);
    userHomeConfig = SystemReader.getInstance().openUserConfig(systemConfig, FS.DETECTED);

    if (effectiveConfig instanceof FileBasedConfig) {
      File configFile = ((FileBasedConfig) effectiveConfig).getFile();
      repositoryConfig = new FileBasedConfig(configFile, repository.getFS());
    } else {
      repositoryConfig = effectiveConfig;
    }

    synchronized (myPage) {
      // check if the actions are already there, if not, create them
      IActionBars bars = myPage.getSite().getActionBars();

      changeModeAction = (ActionContributionItem) bars.getToolBarManager().find(CHANGEMODEACTIONID);
      singleValueToggleAction =
          (ActionContributionItem) bars.getToolBarManager().find(SINGLEVALUEACTIONID);

      if (changeModeAction != null) {
        return;
      }

      changeModeAction =
          new ActionContributionItem(
              new Action(DisplayMode.REPO.getText(), IAction.AS_DROP_DOWN_MENU) {
                @Override
                public String getId() {
                  return CHANGEMODEACTIONID;
                }

                @Override
                public void run() {
                  MenuManager mgr = new MenuManager();
                  ToolItem item = (ToolItem) changeModeAction.getWidget();
                  ToolBar control = item.getParent();
                  final Menu ctxMenu = mgr.createContextMenu(control);

                  for (final DisplayMode aMode : DisplayMode.values()) {
                    mgr.add(
                        new Action(aMode.getText()) {
                          @Override
                          public void run() {
                            changeModeAction.getAction().setText(aMode.getText());
                            editAction.getAction().setEnabled(aMode != DisplayMode.EFFECTIVE);
                            myPage.refresh();
                          }

                          @Override
                          public boolean isEnabled() {
                            return aMode != getCurrentMode();
                          }

                          @Override
                          public boolean isChecked() {
                            return aMode == getCurrentMode();
                          }

                          @Override
                          public int getStyle() {
                            return IAction.AS_CHECK_BOX;
                          }
                        });
                  }

                  ctxMenu.setVisible(true);
                }

                @Override
                public String getToolTipText() {
                  return UIText.RepositoryPropertySource_SelectModeTooltip;
                }

                @Override
                public int getStyle() {
                  return IAction.AS_DROP_DOWN_MENU;
                }
              });

      editAction =
          new ActionContributionItem(
              new Action(UIText.RepositoryPropertySource_EditConfigButton, UIIcons.EDITCONFIG) {
                @Override
                public String getId() {
                  return EDITACTIONID;
                }

                @Override
                public void run() {

                  final StoredConfig config;

                  switch (getCurrentMode()) {
                    case EFFECTIVE:
                      return;
                    case SYSTEM:
                      config = systemConfig;
                      break;
                    case USER:
                      config = userHomeConfig;
                      break;
                    case REPO:
                      config = repositoryConfig;
                      break;
                    default:
                      return;
                  }

                  new EditDialog(
                          myPage.getSite().getShell(),
                          (FileBasedConfig) config,
                          getCurrentMode().getText())
                      .open();
                  myPage.refresh();
                }

                @Override
                public int getStyle() {
                  return IAction.AS_PUSH_BUTTON;
                }
              });

      singleValueToggleAction =
          new ActionContributionItem(
              new Action(UIText.RepositoryPropertySource_SingleValueButton) {
                @Override
                public String getId() {
                  return SINGLEVALUEACTIONID;
                }

                @Override
                public void run() {
                  myPage.refresh();
                }

                @Override
                public int getStyle() {
                  return IAction.AS_CHECK_BOX;
                }

                @Override
                public String getToolTipText() {
                  return UIText.RepositoryPropertySource_SuppressMultipleValueTooltip;
                }
              });

      bars.getToolBarManager().add(new Separator());
      bars.getToolBarManager().add(changeModeAction);
      bars.getToolBarManager().add(singleValueToggleAction);
      bars.getToolBarManager().add(editAction);

      bars.getToolBarManager().update(false);
    }
  }
 /**
  * Overwritten to register global action handlers for undo and redo.
  *
  * @see
  *     org.eclipse.ui.views.properties.PropertySheetPage#setActionBars(org.eclipse.ui.IActionBars)
  */
 public void setActionBars(IActionBars actionBars) {
   super.setActionBars(actionBars);
   // register global action handlers for undo and redo
   actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoHandler);
   actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoHandler);
 }
 /**
  * Overwritten to unregister command stack listener.
  *
  * @see org.eclipse.ui.views.properties.PropertySheetPage#dispose()
  */
 public void dispose() {
   if (commandStack != null)
     commandStack.removeCommandStackEventListener(commandStackEventListener);
   super.dispose();
 }
Ejemplo n.º 13
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;
  }
 @Override
 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
   super.selectionChanged(part, selection);
   fPart = part;
   fSelection = selection;
 }