📄 gantttaskpropertiesbean.java
字号:
} }); finishDatePanel.add(myEndDatePicker); //finishDatePanel.add(finishDateButton1); JPanel thirdDatePanel = new JPanel( new FlowLayout(FlowLayout.LEFT, 5, 0)); thirdDatePanel.add(thirdDateComboBox); myThirdDatePicker = createDatePicker(new ActionListener() { public void actionPerformed(ActionEvent e) { setThird(new GanttCalendar(((JXDatePicker)e.getSource()).getDate()), false); } }); thirdDatePanel.add(myThirdDatePicker); //thirdDatePanel.add(thirdDateButton1); // thirdRowPanel1.add(startDatePanel); // thirdRowPanel1.add(finishDatePanel); // thirdRowPanel1.add(thirdDatePanel); addUsingGBL(thirdRowPanel1, startDatePanel, gbc, 0, 0, 1, 1); addUsingGBL(thirdRowPanel1, finishDatePanel, gbc, 0, 1, 1, 1); addUsingGBL(thirdRowPanel1, thirdDatePanel, gbc, 0, 2, 1, 1); // fourth row JCheckBox checkBox = constructCheckBox (); lastRowPanel1 = new JPanel(flowL); if (checkBox != null) lastRowPanel1.add(checkBox); JPanel shapePanel = new JPanel(); shapePanel.setLayout(new BorderLayout()); JLabel lshape = new JLabel(" " + language.getText("shape") + " "); shapeComboBox = new JPaintCombo(ShapeConstants.PATTERN_LIST); shapePanel.add(lshape, BorderLayout.WEST); shapePanel.add(shapeComboBox, BorderLayout.CENTER); colorButton = new JButton(language.getText("colorButton")); colorButton.setBackground(selectedTasks[0].getColor()); final String colorChooserTitle = language.getText("selectColor"); colorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDialog dialog; dialog = JColorChooser.createDialog(GanttTaskPropertiesBean.this, colorChooserTitle, true, GanttDialogProperties.colorChooser, new ActionListener() { public void actionPerformed(ActionEvent e) { colorButton .setBackground(GanttDialogProperties.colorChooser .getColor()); isColorChanged = true; } } , new ActionListener() { public void actionPerformed(ActionEvent e) { // nothing to do for "Cancel" } }); /* * AbstractColorChooserPanel[] panels = * GanttDialogProperties.colorChooser.getChooserPanels(); * GanttDialogProperties.colorChooser.removeChooserPanel(panels[0]); * GanttDialogProperties.colorChooser.addChooserPanel(panels[0]); */ GanttDialogProperties.colorChooser.setColor(colorButton .getBackground()); dialog.show(); } }); colorSpace = new JButton(language.getText("defaultColor")); colorSpace.setBackground(GanttGraphicArea.taskDefaultColor); colorSpace.setToolTipText(GanttProject.getToolTip(language .getText("resetColor"))); colorSpace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { colorButton.setBackground(GanttGraphicArea.taskDefaultColor); isColorChanged = true; } }); colorPanel = new JPanel(); colorPanel.setLayout(new BorderLayout()); colorPanel.add(colorButton, "West"); colorPanel.add(colorSpace, "Center"); colorPanel.add(shapePanel, BorderLayout.EAST); lastRowPanel1.add(colorPanel); // ---Set GridBagConstraints constant gbc.anchor = GridBagConstraints.WEST; gbc.insets.right = 15; gbc.insets.left = 10; gbc.insets.top = 10; addUsingGBL(generalPanel, firstRowPanel1, gbc, 0, 0, 1, 1); addUsingGBL(generalPanel, secondRowPanel1, gbc, 0, 1, 1, 1); addUsingGBL(generalPanel, thirdRowPanel1, gbc, 0, 2, 1, 1); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridheight = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; gbc.weighty = 1; generalPanel.add(lastRowPanel1, gbc); // The panel for the web link webLinkPanel = new JPanel(flowL); lblWebLink = new JLabel(language.getText("webLink")); webLinkPanel.add(lblWebLink); tfWebLink = new JTextField(30); webLinkPanel.add(tfWebLink); bWebLink = new TestGanttRolloverButton(new ImageIcon(getClass() .getResource("/icons/web_16.gif"))); bWebLink.setToolTipText(GanttProject.getToolTip(language .getText("openWebLink"))); webLinkPanel.add(bWebLink); bWebLink.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // link to open the web link try { if (!BrowserControl.displayURL(tfWebLink.getText())) { GanttDialogInfo gdi = new GanttDialogInfo(null, GanttDialogInfo.ERROR, GanttDialogInfo.YES_OPTION, language .getText("msg4"), language .getText("error")); gdi.show(); } } catch (Exception ex) { } } }); gbc.gridy = 4; generalPanel.add(webLinkPanel, gbc); } /** Add the differents action listener on the differents widgets */ public void addActionListener(ActionListener l) { nameField1.addActionListener(l); startDateButton1.addActionListener(l); finishDateButton1.addActionListener(l); thirdDateButton1.addActionListener(l); thirdDateComboBox.addActionListener(l); durationField1.addActionListener(l); } /** Change the name of the task on all textfiled of task name */ public void changeNameOfTask() { if (nameField1 != null && nameFieldNotes != null) { String nameOfTask = nameField1.getText().trim(); nameField1.setText(nameOfTask); if (onlyOneTask) myDependenciesPanel.nameChanged(nameOfTask); myAllocationsPanel[0].nameChanged(nameOfTask); nameFieldNotes.setText(nameOfTask); } } private void constructCustomColumnPanel() { myCustomColumnPanel = new CustomColumnsPanel(Mediator .getCustomColumnsStorage()); } /** Construct the predecessors tabbed pane */ private void constructPredecessorsPanel() { myDependenciesPanel = new TaskDependenciesPanel(selectedTasks[0]); predecessorsPanel = myDependenciesPanel.getComponent(); } /** Construct the resources panel */ private void constructResourcesPanel() { myAllocationsPanel = new TaskAllocationsPanel[selectedTasks.length]; for (int i = 0; i < myAllocationsPanel.length; i++) { myAllocationsPanel[i] = new TaskAllocationsPanel(selectedTasks[i], myHumanResourceManager, myRoleManager, onlyOneTask); if (i != 0) myAllocationsPanel[i].getComponent(); } resourcesPanel = myAllocationsPanel[0].getComponent(); } /** construct the notes pannel */ private void constructNotesPanel() { notesPanel = new JPanel(new GridBagLayout()); // first row nameLabelNotes = new JLabel(language.getText("name") + ":"); nameFieldNotes = new JTextField(20); if (!onlyOneTask) { nameLabelNotes.setVisible(false); nameFieldNotes.setVisible(false); } durationLabelNotes = new JLabel(language.getText("length") + ":"); durationFieldNotes = new JTextField(8); nameFieldNotes.setEditable(false); durationFieldNotes.setEditable(false); firstRowPanelNotes = new JPanel(); setFirstRow(firstRowPanelNotes, gbc, nameLabelNotes, nameFieldNotes, durationLabelNotes, durationFieldNotes); secondRowPanelNotes = new JPanel(); secondRowPanelNotes.setBorder(new TitledBorder(new EtchedBorder(), language.getText("notesTask") + ":")); noteAreaNotes = new JTextArea(8, 40); noteAreaNotes.setLineWrap(true); noteAreaNotes.setWrapStyleWord(true); noteAreaNotes.setBackground(new Color(1.0f, 1.0f, 1.0f)); scrollPaneNotes = new JScrollPane(noteAreaNotes); secondRowPanelNotes.add(scrollPaneNotes); JButton bdate = new TestGanttRolloverButton(new ImageIcon(getClass() .getResource("/icons/clock_16.gif"))); bdate.setToolTipText(GanttProject.getToolTip(language .getText("putDate"))); bdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { noteAreaNotes.append("\n" + GanttCalendar.getDateAndTime() + "\n"); } }); secondRowPanelNotes.add(bdate); gbc.anchor = GridBagConstraints.WEST; gbc.insets.right = 15; gbc.insets.left = 10; gbc.insets.top = 10; gbc.weighty = 0; addUsingGBL(notesPanel, firstRowPanelNotes, gbc, 0, 0, 1, 1); gbc.weighty = 1; gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; notesPanel.add(secondRowPanelNotes, gbc); } /** Constructor */ public GanttTaskPropertiesBean(GanttTask[] selectedTasks, TaskManager taskManager, HumanResourceManager humanManager, RoleManager roleManager) { this.onlyOneTask = false; if (selectedTasks.length == 1) this.onlyOneTask = true; this.selectedTasks = selectedTasks; setInitialValues(selectedTasks[0]); myHumanResourceManager = humanManager; myRoleManager = roleManager; myTaskManager = taskManager;// setTree(tree); init(); // this.managerHash = managerHash; setSelectedTask(); // set predecessor comboBox // setUpPredecessorComboColumn(predecessorsTable.getColumnModel().getColumn(1), // predecessorsTable); //set column editor // setUpTypeComboColumn(predecessorsTable.getColumnModel().getColumn(2)); // //set column editor // set resources comboBox /* * setUpResourcesComboColumn(((ResourceManager)managerHash.get("HUMAN_RESOURCE")).getResources(), * resourcesTable.getColumnModel().getColumn(0)); //set column editor */ /* * tabbedPane = new JTabbedPane(); constructGeneralPanel(); * tabbedPane.add("General", generalPanel); * constructPredecessorsPanel(); tabbedPane.add("Predecessors", * predecessorsPanel); constructResourcesPanel(); * tabbedPane.add("Resources", resourcesPanel); constructNotesPanel(); * tabbedPane.add("Notes", notesPanel); add(tabbedPane); */ } private JXDatePicker createDatePicker(ActionListener listener) { ImageIcon calendarImage = new ImageIcon(getClass().getResource( "/icons/calendar_16.gif")); Icon nextMonth = new ImageIcon(getClass() .getResource("/icons/nextmonth.gif")); Icon prevMonth = new ImageIcon(getClass() .getResource("/icons/prevmonth.gif")); UIManager.put("JXDatePicker.arrowDown.image", calendarImage); UIManager.put("JXMonthView.monthUp.image", prevMonth); UIManager.put("JXMonthView.monthDown.image", nextMonth); UIManager.put("JXMonthView.monthCurrent.image", calendarImage); JXDatePicker result = new JXDatePicker(); result.addActionListener(listener); /* JPanel result = new JPanel(new BorderLayout()); JPanel contentPanel = new JPanel(new SpringLayout()); contentPanel.add(new JLabel("start")); contentPanel.add(new JXDatePicker()); SpringUtilities.makeCompactGrid(contentPanel, 1, 2, 0, 0, 0, 0); result.add(contentPanel, BorderLayout.NORTH); */ return result; } /** Init the widgets */ public void init() { tabbedPane = new JTabbedPane(); tabbedPane.getModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { changeNameOfTask(); fireDurationChanged(); } }); constructGeneralPanel(); tabbedPane.addTab(language.getText("general"), new ImageIcon(getClass() .getResource("/icons/properties_16.gif")), generalPanel); if (onlyOneTask) { constructPredecessorsPanel(); tabbedPane.addTab(language.getText("predecessors"), new ImageIcon( getClass().getResource("/icons/relashion.gif")), predecessorsPanel); } constructResourcesPanel(); tabbedPane.addTab(GanttProject.correctLabel(language.getText("human")), new ImageIcon(getClass().getResource("/icons/res_16.gif")), resourcesPanel); constructNotesPanel(); tabbedPane.addTab(language.getText("notesTask"), new ImageIcon( getClass().getResource("/icons/note_16.gif")), notesPanel); setLayout(new BorderLayout()); add(tabbedPane, BorderLayout.CENTER); constructCustomColumnPanel(); tabbedPane.addTab(language.getText("customColumns"), new ImageIcon( getClass().getResource("/icons/custom.gif")), myCustomColumnPanel); tabbedPane.addFocusListener(new FocusAdapter() { private boolean isFirstFocusGain = true; public void focusGained(FocusEvent e) { super.focusGained(e); if (isFirstFocusGain) { nameField1.requestFocus(); isFirstFocusGain = false; } } }); tabbedPane.setBorder(BorderFactory.createEmptyBorder(2,0,5,0)); } // Input methods /** * as the name indicated, it will not replace the original GanttTask in the * Tree. */ public Task[] getReturnTask() { GanttTask[] returnTask = new GanttTask[selectedTasks.length]; for (int i = 0; i < selectedTasks.length; i++) { if (myAllocationsPanel[0].getTableModel().isChanged()) { if (i != 0) copyValues(myAllocationsPanel[0].getTableModel(), myAllocationsPanel[i].getTableModel()); } myAllocationsPanel[i].getTableModel().commit(); returnTask[i] = selectedTasks[i]; // returnTask.setTaskID(selectedTask.getTaskID()); TaskMutator mutator = returnTask[i].createMutator();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -