private void updateTable() {
   TableColumn actionColumn =
       attributesTable.getColumnModel().getColumn(DuplicatedAttributeTableModel.ACTION);
   JComboBox actionsCombo =
       Application.getWidgetFactory()
           .createComboBox(new String[] {DELETE_ACTION, RENAME_ACTION}, false);
   actionColumn.setCellEditor(Application.getWidgetFactory().createCellEditor(actionsCombo));
 }
Esempio n. 2
0
  private void initView() {
    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());

    add(toolBar, BorderLayout.NORTH);

    className =
        new TextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setClassName(text);
          }
        };

    FormLayout layout = new FormLayout("right:50dlu, 3dlu, fill:150dlu, 3dlu, fill:100", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    builder.append("Class Name:", className.getComponent(), 3);

    add(builder.getPanel(), BorderLayout.CENTER);
  }
Esempio n. 3
0
  private void initView() {
    // create widgets
    name =
        new TextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setQueryName(text);
          }
        };

    queryRoot = Application.getWidgetFactory().createComboBox();
    AutoCompletion.enable(queryRoot);
    queryRoot.setRenderer(CellRenderers.listRendererWithIcons());

    qualifier =
        new ValidatorTextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setQueryQualifier(text);
          }

          @Override
          protected void validate(String text) throws ValidationException {
            createQualifier(text);
          }
        };

    distinct = new JCheckBox();

    properties = new ObjectQueryPropertiesPanel(mediator);

    // assemble
    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "right:max(80dlu;pref), 3dlu, fill:200dlu", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();

    builder.addSeparator("SelectQuery Settings", cc.xywh(1, 1, 3, 1));
    builder.addLabel("Query Name:", cc.xy(1, 3));
    builder.add(name.getComponent(), cc.xy(3, 3));
    builder.addLabel("Query Root:", cc.xy(1, 5));
    builder.add(queryRoot, cc.xy(3, 5));
    builder.addLabel("Qualifier:", cc.xy(1, 7));
    builder.add(qualifier.getComponent(), cc.xy(3, 7));
    builder.addLabel("Distinct:", cc.xy(1, 9));
    builder.add(distinct, cc.xy(3, 9));

    this.setLayout(new BorderLayout());
    this.add(builder.getPanel(), BorderLayout.NORTH);
    this.add(properties, BorderLayout.CENTER);
  }
Esempio n. 4
0
  public TextCompoundEdit(JTextComponent editor, JTextFieldUndoListener listener) {

    this.editor = editor;
    this.listener = listener;

    EditorView editorView =
        ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();

    treePath = editorView.getProjectTreeView().getSelectionPath();

    DefaultMutableTreeNode newPath = (DefaultMutableTreeNode) treePath.getLastPathComponent();

    targetObject = newPath.getUserObject();

    if (targetObject instanceof ObjEntity) {
      tabbedPane = editorView.getObjDetailView();
    }

    if (targetObject instanceof DbEntity) {
      tabbedPane = editorView.getDbDetailView();
    }

    if (targetObject instanceof Embeddable) {
      tabbedPane = editorView.getEmbeddableView();
    }

    if (targetObject instanceof SQLTemplate) {
      tabbedPane = editorView.getSqlTemplateView();

      if (tabbedPane != null) {
        selectedItem = ((SQLTemplateTabbedView) tabbedPane).getScriptsTab().getSelectedIndex();
      }
    }

    if (targetObject instanceof EJBQLQuery) {
      tabbedPane = editorView.getEjbqlQueryView();
    }

    if (targetObject instanceof DataNodeDescriptor) {
      tabbedPane = editorView.getDataNodeView();
    }

    if (targetObject instanceof DataMap) {
      tabbedPane = editorView.getDataMapView();
    }

    if (targetObject instanceof DataChannelDescriptor) {
      tabbedPane = editorView.getDataDomainView();
    }

    if (tabbedPane != null) {
      selectedTabIndex = tabbedPane.getSelectedIndex();
    }
  }
Esempio n. 5
0
 @Override
 protected DbActionOptionsDialog createDialog(
     Collection<String> catalogs,
     Collection<String> schemas,
     String currentCatalog,
     String currentSchema) {
   return new DbActionOptionsDialog(
       Application.getFrame(),
       "Migrate DB Schema: Select Catalog and Schema",
       catalogs,
       schemas,
       currentCatalog,
       currentSchema);
 }
Esempio n. 6
0
  private void restoreSelections() {

    EditorView editorView =
        ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();

    editorView.getProjectTreeView().getSelectionModel().setSelectionPath(treePath);

    if (tabbedPane != null) {
      tabbedPane.setSelectedIndex(selectedTabIndex);

      if (tabbedPane instanceof SQLTemplateTabbedView) {
        ((SQLTemplateTabbedView) tabbedPane).getScriptsTab().setSelectedIndex(selectedItem);
      }
    }
  }
Esempio n. 7
0
  @Override
  protected boolean saveAll() throws Exception {
    Project p = getCurrentProject();

    if (p == null || p.getConfigurationResource() == null) {
      return super.saveAll();
    } else {

      String oldPath = p.getConfigurationResource().getURL().getPath();

      getProjectController().getFileChangeTracker().pauseWatching();

      ProjectSaver saver = getApplication().getInjector().getInstance(ProjectSaver.class);
      saver.save(p);

      RenamedPreferences.removeOldPreferences();

      // if change DataChanelDescriptor name - as result change name of xml file
      // we will need change preferences path
      String[] path = oldPath.split("/");
      String[] newPath = p.getConfigurationResource().getURL().getPath().split("/");

      if (!path[path.length - 1].equals(newPath[newPath.length - 1])) {
        String newName = newPath[newPath.length - 1].replace(".xml", "");
        RenamedPreferences.copyPreferences(
            newName, getProjectController().getPreferenceForProject());
        RenamedPreferences.removeOldPreferences();
      }

      getApplication()
          .getFrameController()
          .changePathInLastProjListAction(oldPath, p.getConfigurationResource().getURL().getPath());
      Application.getFrame().fireRecentFileListChanged();

      /** Reset the watcher now */
      getProjectController().getFileChangeTracker().reconfigure();
    }

    return true;
  }