/*
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {

    WidgetFactory factory = getWidgetFactory();

    final int gridDataStyle = GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL;
    final GridData fieldGridData = new GridData(gridDataStyle);

    Composite container = new Composite(parent, SWT.NULL);
    container.setBackground(parent.getBackground());
    container.setForeground(parent.getForeground());
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(fieldGridData);

    Label label = null;

    // Format code
    label = new Label(container, SWT.NULL);
    label.setText(Messages.getString("aaa.mdf.metadict.entity.sqlname.label"));
    label.setBackground(container.getBackground());
    mdSQLName = factory.createText(container, null);
    mdSQLName.setLayoutData(fieldGridData);
    mdSQLName.setEditable(false);

    // Format Finantial Function
    label = new Label(container, SWT.NULL);
    label.setText(Messages.getString("aaa.mdf.metadict.entity.name.label"));
    label.setBackground(container.getBackground());
    mdName = factory.createText(container, null);
    mdName.setLayoutData(fieldGridData);
    mdName.setEditable(false);

    initialize();
    setControl(container);
  }
  public void createControl(Composite parent) {
    viewer = new GalleryViewer();

    EditDomain editDomain = new EditDomain();
    editDomain.installTool(GEF.TOOL_SELECT, new TemplateGallerySelectTool());
    viewer.setEditDomain(editDomain);

    Properties properties = viewer.getProperties();
    properties.set(GalleryViewer.Horizontal, Boolean.TRUE);
    properties.set(GalleryViewer.Wrap, Boolean.TRUE);
    properties.set(GalleryViewer.TitlePlacement, GalleryViewer.TITLE_BOTTOM);
    properties.set(GalleryViewer.SingleClickToOpen, Boolean.TRUE);
    properties.set(GalleryViewer.SolidFrames, true);
    properties.set(GalleryViewer.FlatFrames, true);
    properties.set(GalleryViewer.ImageConstrained, true);
    properties.set(GalleryViewer.ImageStretched, true);
    properties.set(
        GalleryViewer.Layout,
        new GalleryLayout(
            GalleryLayout.ALIGN_CENTER,
            GalleryLayout.ALIGN_TOPLEFT,
            10,
            10,
            new Insets(5, 15, 5, 15)));
    properties.set(GalleryViewer.FrameContentSize, new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
    properties.set(GalleryViewer.ContentPaneBorderWidth, 1);
    properties.set(GalleryViewer.ContentPaneBorderColor, ColorUtils.getColor("#cccccc"));

    Control control = viewer.createControl(parent);
    control.setBackground(parent.getBackground());
    control.setForeground(parent.getForeground());

    viewer.setLabelProvider(new TemplateLabelProvider());

    viewer.setInput(getViewerInput());

    viewer.addOpenListener(
        new IOpenListener() {
          public void open(OpenEvent event) {
            if (normalOrEditMode) {
              if (!templateOpening) handleTemplateSelected(event.getSelection());
            }
          }
        });

    MindMapUI.getResourceManager().addResourceManagerListener(this);

    setControl(control);
  }
Beispiel #3
0
  private NatTable createTable(
      final Composite parent,
      final TableTheme theme,
      final RedNattableLayersFactory factory,
      final GridLayer gridLayer,
      final DataLayer dataLayer,
      final ConfigRegistry configRegistry) {
    final int style =
        SWT.NO_BACKGROUND
            | SWT.NO_REDRAW_RESIZE
            | SWT.DOUBLE_BUFFERED
            | SWT.V_SCROLL
            | SWT.H_SCROLL;
    final NatTable table = new NatTable(parent, style, gridLayer, false);
    table.setConfigRegistry(configRegistry);
    table.setLayerPainter(
        new RedNatGridLayerPainter(
            table,
            theme.getGridBorderColor(),
            theme.getHeadersBackground(),
            theme.getHeadersUnderlineColor(),
            2,
            RedNattableLayersFactory.ROW_HEIGHT));
    table.setBackground(theme.getBodyBackgroundOddRowBackground());
    table.setForeground(parent.getForeground());

    // calculate columns width
    table.addListener(
        SWT.Paint,
        factory.getColumnsWidthCalculatingPaintListener(table, dataProvider, dataLayer, 270, 200));

    addCustomStyling(table, theme);

    final Supplier<HeaderFilterMatchesCollection> matchesSupplier =
        new Supplier<HeaderFilterMatchesCollection>() {

          @Override
          public HeaderFilterMatchesCollection get() {
            return matches;
          }
        };

    // find matches configuration
    table.addConfiguration(new TableMatchesSupplierRegistryConfiguration(matchesSupplier));

    // hyperlinks configuration
    final TableCellsStrings tableStrings = new TableCellsStrings();
    table.addConfiguration(new TableStringsPositionsRegistryConfiguration(tableStrings));
    final TableHyperlinksSupport detector =
        TableHyperlinksSupport.enableHyperlinksInTable(table, tableStrings);
    detector.addDetectors(
        new TableHyperlinksToKeywordsDetector(dataProvider),
        new TableHyperlinksToVariablesDetector(dataProvider));

    // sorting
    table.addConfiguration(new HeaderSortConfiguration());
    table.addConfiguration(new CasesTableSortingConfiguration(dataProvider));

    // popup menus
    table.addConfiguration(new CasesTableMenuConfiguration(site, table, selectionProvider));

    table.configure();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);

    return table;
  }
  /** Resets the chart */
  private void resetChart() {

    if (chart != null) {
      chart.dispose();
    }
    chart = new Chart(root, SWT.NONE);
    chart.setOrientation(SWT.HORIZONTAL);

    // Show/Hide axis
    chart.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent arg0) {
            updateCategories();
          }
        });

    // TODO: Seems to not work on GTK although it did before
    chart
        .getPlotArea()
        .addListener(
            SWT.MouseMove,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                IAxisSet axisSet = chart.getAxisSet();
                StringBuilder builder = new StringBuilder();
                if (axisSet != null) {
                  IAxis xAxis = axisSet.getXAxis(0);
                  if (xAxis != null) {
                    String[] series = xAxis.getCategorySeries();
                    ISeries[] data = chart.getSeriesSet().getSeries();
                    int x = (int) Math.round(xAxis.getDataCoordinate(event.x));
                    if (x >= 0 && x < series.length) {
                      for (int i = 0; i < data.length; i++) {
                        ISeries yseries = data[i];
                        builder.append(yseries.getId());
                        builder.append("("); // $NON-NLS-1$
                        builder.append(series[x]);
                        builder.append(", "); // $NON-NLS-1$
                        builder.append(yseries.getYSeries()[x]);
                        builder.append(")"); // $NON-NLS-1$
                        if (i < data.length - 1) {
                          builder.append(", "); // $NON-NLS-1$
                        }
                      }
                    }
                  }
                }
                if (builder.length() != 0) {
                  chart.getPlotArea().setToolTipText(builder.toString());
                } else {
                  chart.getPlotArea().setToolTipText(null);
                }
              }
            });

    // Update font
    FontData[] fd = chart.getFont().getFontData();
    fd[0].setHeight(8);
    final Font font = new Font(chart.getDisplay(), fd[0]);
    chart.setFont(font);
    chart.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent arg0) {
            if (font != null && !font.isDisposed()) {
              font.dispose();
            }
          }
        });

    // Update title
    ITitle graphTitle = chart.getTitle();
    graphTitle.setText(""); // $NON-NLS-1$
    graphTitle.setFont(chart.getFont());

    // Set colors
    chart.setBackground(root.getBackground());
    chart.setForeground(root.getForeground());

    // OSX workaround
    if (System.getProperty("os.name").toLowerCase().contains("mac")) { // $NON-NLS-1$ //$NON-NLS-2$
      int r = chart.getBackground().getRed() - 13;
      int g = chart.getBackground().getGreen() - 13;
      int b = chart.getBackground().getBlue() - 13;
      r = r > 0 ? r : 0;
      r = g > 0 ? g : 0;
      r = b > 0 ? b : 0;
      final Color background = new Color(chart.getDisplay(), r, g, b);
      chart.setBackground(background);
      chart.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
              if (background != null && !background.isDisposed()) {
                background.dispose();
              }
            }
          });
    }

    // Initialize axes
    IAxisSet axisSet = chart.getAxisSet();
    IAxis yAxis = axisSet.getYAxis(0);
    IAxis xAxis = axisSet.getXAxis(0);
    ITitle xAxisTitle = xAxis.getTitle();
    xAxisTitle.setText(""); // $NON-NLS-1$
    xAxis.getTitle().setFont(chart.getFont());
    yAxis.getTitle().setFont(chart.getFont());
    xAxis.getTick().setFont(chart.getFont());
    yAxis.getTick().setFont(chart.getFont());
    xAxis.getTick().setForeground(chart.getForeground());
    yAxis.getTick().setForeground(chart.getForeground());
    xAxis.getTitle().setForeground(chart.getForeground());
    yAxis.getTitle().setForeground(chart.getForeground());

    // Initialize y-axis
    ITitle yAxisTitle = yAxis.getTitle();
    yAxisTitle.setText(Resources.getMessage("ViewRisksPlotUniquenessEstimates.0")); // $NON-NLS-1$
    chart.setEnabled(false);
    updateCategories();
  }