public class RasterPropertiesView extends Composite {
  private static Log log = Logging.getLog(RasterPropertiesView.class);

  private RasterPropertiesContainer rasterPropertiesContainer;

  public RasterPropertiesView(Composite parent, int style) {
    super(parent, style);

    setLayout(new FillLayout());

    rasterPropertiesContainer = new RasterPropertiesContainer(this, SWT.NONE);

    DataView.addTreeSelectionListener(
        new TreeSelectionAdapter() {
          public void onSourceDataSelectionChanged(InputSourceData selectedData) {
            if (selectedData != null && selectedData instanceof GenericRasterDataProvider) {
              GenericRasterDataProvider provider = (GenericRasterDataProvider) selectedData;
              rasterPropertiesContainer.setRasterDefinition(provider.getRasterDefinition());
            } else {
              rasterPropertiesContainer.setRasterDefinition(null);
            }
          }
        });

    ProjectContext.getInstance()
        .addProjectChangeListener(
            new ProjectChangeAdapter() {
              public void onProjectLoaded(String filePath) {
                rasterPropertiesContainer.setRasterDefinition(null);
              }
            });
  }
}
示例#2
0
public class NotifyEncoder {
  private static Log log = Logging.getLog(NotifyEncoder.class);

  public static String encode(Object notify)
      throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {

    String query = "";

    for (Method method : notify.getClass().getMethods()) {

      String name = method.getName();

      if (isNotifyProperty(name) && !name.equals("getClass")) {
        String propertyName = getPropertyName(name);
        Object value = method.invoke(notify);

        query += propertyName + "=" + encodeForUrl(value.toString()) + "&";
      }
    }

    return query;
  }

  protected static String encodeForUrl(String s) {
    // s = s.replaceAll("\\+", "%2B");
    // s = s.replaceAll(" ", "+");

    String encodedUrl = s;
    try {
      encodedUrl = URLEncoder.encode(s, "UTF-8");
    } catch (UnsupportedEncodingException ex) {
      log.warn("Error encoding string: " + s, ex);
    }
    return encodedUrl;
  }

  protected static boolean isNotifyProperty(String methodName) {
    if (methodName.startsWith("get") || methodName.startsWith("is")) {
      return true;
    } else {
      return false;
    }
  }

  protected static String getPropertyName(String methodName) {
    String propertyName = "";

    if (methodName.startsWith("get")) {
      propertyName = methodName.substring(3);
    } else if (methodName.startsWith("is")) {
      propertyName = methodName.substring(2);
    } else {
      propertyName = methodName;
    }

    return propertyName.toLowerCase();
  }
}
示例#3
0
@Deprecated
public class ResourcePointer {
  private static Log log = Logging.getLog(ResourcePointer.class);

  private String scheme;
  private int schemeType;
  private String uri;

  public ResourcePointer(String url) throws ResourceLoaderException {
    if (url.indexOf("file://") == 0) {
      scheme = "file://";
      schemeType = ResourceLoader.SCHEME_FILE;
      uri = url.substring(7);
    } else if (url.indexOf("jar://") == 0) {
      scheme = "jar://";
      schemeType = ResourceLoader.SCHEME_JAR;
      uri = url.substring(6);
    } else {
      scheme = "file://";
      schemeType = ResourceLoader.SCHEME_FILE;
      uri = url;
    }

    log.info("ResoucePointer: " + scheme + ", " + uri);
  }

  public String getScheme() {
    return scheme;
  }

  public int getSchemeType() {
    return schemeType;
  }

  public String getUri() {
    return uri;
  }
}
@SuppressWarnings("serial")
public class DockingContainerPanel extends Panel {
  private static Log log = Logging.getLog(DockingContainerPanel.class);

  private SideDockingPanel leftPanel = null;
  private SideDockingPanel rightPanel = null;
  private EmbeddedTabbedPane centerTabPanel = null;
  private EmbeddedTabbedPane southTabPanel = null;
  private SplitPane outterSplit = null;
  private SplitPane innerSplit = null;
  private SplitPane verticalSplit = null;

  private List<Component> componentList = new LinkedList<Component>();

  public DockingContainerPanel() {

    // Create components
    leftPanel = new SideDockingPanel();
    rightPanel = new SideDockingPanel();

    centerTabPanel = new EmbeddedTabbedPane();
    southTabPanel = new EmbeddedTabbedPane();

    ContainerListener containerListener =
        new ContainerListener() {

          public void componentAdded(ContainerEvent e) {
            log.info("Component Added");
            componentList.add(e.getComponent());
          }

          public void componentRemoved(ContainerEvent e) {
            log.info("Component Removed");
            componentList.remove(e.getComponent());
          }
        };

    leftPanel.addContainerListener(containerListener);
    rightPanel.addContainerListener(containerListener);
    centerTabPanel.addContainerListener(containerListener);
    southTabPanel.addContainerListener(containerListener);

    // Set Layout
    BorderLayout layout = new BorderLayout();
    setLayout(layout);

    // add(leftPanel, BorderLayout.WEST);
    // add(rightPanel, BorderLayout.EAST);
    // add(centerTabPanel, BorderLayout.CENTER);

    verticalSplit = new SplitPane(SplitPane.VERTICAL_SPLIT);
    verticalSplit.setBorder(BorderFactory.createEmptyBorder());
    verticalSplit.setResizeWeight(1);

    outterSplit = new SplitPane(SplitPane.HORIZONTAL_SPLIT);
    outterSplit.setBorder(BorderFactory.createEmptyBorder());
    outterSplit.setResizeWeight(0);
    // outterSplit.setDividerSize(5);

    innerSplit = new SplitPane(SplitPane.HORIZONTAL_SPLIT);
    innerSplit.setBorder(BorderFactory.createEmptyBorder());
    innerSplit.setResizeWeight(1);
    // innerSplit.setDividerSize(5);

    innerSplit.add(centerTabPanel);
    innerSplit.add(rightPanel);

    outterSplit.add(leftPanel);
    outterSplit.add(innerSplit);

    verticalSplit.add(outterSplit);
    verticalSplit.add(southTabPanel);

    add(verticalSplit, BorderLayout.CENTER);
  }

  public int getSelectedCenterTabIndex() {
    return centerTabPanel.getSelectedIndex();
  }

  public int getSelectedSouthTabIndex() {
    return southTabPanel.getSelectedIndex();
  }

  protected boolean containerHasComponent(Container container, Component comp) {
    for (Component _comp : container.getComponents()) {
      if (_comp == comp) {
        return true;
      }
    }
    return false;
  }

  public void setComponentVisible(Component comp) {
    if (containerHasComponent(centerTabPanel, comp)) centerTabPanel.setSelectedComponent(comp);

    if (containerHasComponent(southTabPanel, comp)) southTabPanel.setSelectedComponent(comp);
  }

  public void addLeft(Component component, boolean scroll) {
    if (scroll) {
      leftPanel.add(new DockPanel(component));
    } else {
      leftPanel.add(component);
    }
  }

  public void addRight(Component component, boolean scroll) {
    if (scroll) {
      rightPanel.add(new DockPanel(component));
    } else {
      rightPanel.add(component);
    }
  }

  public void addCenter(String title, Component component) {
    centerTabPanel.addTab(title, component);
  }

  public void addSouth(String title, Component component) {
    southTabPanel.addTab(title, component);
  }

  public void setSouth(Component component) {
    this.add(component, BorderLayout.SOUTH);
  }

  public void setLeftWidth(int width) {
    outterSplit.setDividerLocation(width);
  }

  public int getLeftWidth() {
    return outterSplit.getDividerLocation();
  }

  public void setRightWidth(int width) {
    innerSplit.setDividerLocation(innerSplit.getWidth() - width);
  }

  public int getRightWidth() {
    return innerSplit.getWidth() - innerSplit.getDividerLocation();
  }

  public void setLeftVisible(boolean v) {
    leftPanel.setVisible(v);
    if (!v) {
      outterSplit.setDividerSize(0);
    } else {
      outterSplit.setDividerSize(5);
    }
  }

  public void setRightVisible(boolean v) {
    rightPanel.setVisible(v);
    if (!v) {
      innerSplit.setDividerSize(0);
    } else {
      innerSplit.setDividerSize(5);
    }
  }

  public void setSouthVisible(boolean v) {
    southTabPanel.setVisible(v);
    if (!v) {
      verticalSplit.setDividerSize(0);
    } else {
      verticalSplit.setDividerSize(5);
    }
  }

  @Override
  public void dispose() throws ComponentException {
    super.dispose();
  }
}
示例#5
0
public class ScriptingContext implements Context {

  private static Log log = Logging.getLog(ScriptingContext.class);

  private ScriptProxy scriptProxy = null;
  private String userScript = null;
  private ScriptLanguageEnum scriptLanguage = ScriptLanguageEnum.JAVASCRIPT;

  private boolean disposed = false;

  public ScriptingContext() {}

  @Override
  public void prepare() throws ContextPrepareException {

    if (userScript != null) {
      try {
        scriptProxy = ScriptProxyFactory.createScriptProxy(scriptLanguage, userScript);
      } catch (Exception ex) {
        log.warn("Error compiling script: " + ex.getMessage(), ex);
        throw new ContextPrepareException("Error compiling script: " + ex.getMessage(), ex);
      }
    }
  }

  public ScriptProxy getScriptProxy() {
    return scriptProxy;
  }

  public void setScriptProxy(ScriptProxy scriptProxy) {
    this.scriptProxy = scriptProxy;
  }

  public String getUserScript() {
    return userScript;
  }

  public void setUserScript(String userScript) {
    this.userScript = userScript;
  }

  public ScriptLanguageEnum getScriptLanguage() {
    return scriptLanguage;
  }

  public void setScriptLanguage(ScriptLanguageEnum scriptLanguage) {
    this.scriptLanguage = scriptLanguage;
  }

  @Override
  public void dispose() throws DataSourceException {

    disposed = true;
  }

  @Override
  public boolean isDisposed() {
    return disposed;
  }

  @Override
  public ScriptingContext copy() throws DataSourceException {
    ScriptingContext copy = new ScriptingContext();
    copy.scriptLanguage = this.scriptLanguage;
    copy.userScript = this.userScript;
    copy.scriptProxy = this.scriptProxy;
    return copy;
  }
}